Before we gave up if a call through bitcast had parameter attributes. Interestingly, we allowed attributes for the return value already. We now handle both the same way, namely, we drop the ones that are incompatible with the new type and keep the rest. This cannot cause "more UB" than initially present. Differential Revision: https://reviews.llvm.org/D119967
37 lines
1.5 KiB
LLVM
37 lines
1.5 KiB
LLVM
; RUN: opt < %s -passes=instcombine -data-layout="p:32:32" -S | FileCheck %s --check-prefixes=CHECK,CHECK32
|
|
; RUN: opt < %s -passes=instcombine -data-layout="p:64:64" -S | FileCheck %s --check-prefixes=CHECK,CHECK64
|
|
|
|
define signext i32 @b(i32* inreg %x) {
|
|
ret i32 0
|
|
}
|
|
|
|
define void @c(...) {
|
|
ret void
|
|
}
|
|
|
|
declare void @useit(i32)
|
|
|
|
define void @d(i32 %x, ...) {
|
|
call void @useit(i32 %x)
|
|
ret void
|
|
}
|
|
|
|
define void @g(i32* %y) {
|
|
call i32 bitcast (i32 (i32*)* @b to i32 (i32)*)(i32 zeroext 0)
|
|
call void bitcast (void (...)* @c to void (i32*)*)(i32* %y)
|
|
call void bitcast (void (...)* @c to void (i32*)*)(i32* sret(i32) %y)
|
|
call void bitcast (void (i32, ...)* @d to void (i32, i32*)*)(i32 0, i32* sret(i32) %y)
|
|
call void bitcast (void (i32, ...)* @d to void (i32, i32*)*)(i32 0, i32* nocapture %y)
|
|
call void bitcast (void (i32, ...)* @d to void (i32*)*)(i32* nocapture noundef %y)
|
|
ret void
|
|
}
|
|
; CHECK-LABEL: define void @g(i32* %y)
|
|
; CHECK: call i32 bitcast (i32 (i32*)* @b to i32 (i32)*)(i32 zeroext 0)
|
|
; CHECK: call void (...) @c(i32* %y)
|
|
; CHECK: call void bitcast (void (...)* @c to void (i32*)*)(i32* sret(i32) %y)
|
|
; CHECK: call void bitcast (void (i32, ...)* @d to void (i32, i32*)*)(i32 0, i32* sret(i32) %y)
|
|
; CHECK: call void (i32, ...) @d(i32 0, i32* nocapture %y)
|
|
; CHECK32: %2 = ptrtoint i32* %y to i32
|
|
; CHECK32: call void (i32, ...) @d(i32 noundef %2)
|
|
; CHECK64: call void bitcast (void (i32, ...)* @d to void (i32*)*)(i32* nocapture noundef %y)
|