1 ; RUN: opt < %s -ipconstprop -S -o - | FileCheck %s
3 ; The original C source looked like this:
5 ; long long a101, b101, e101;
9 ; static inline int bar(p1, p2)
14 ; void foo(unsigned p1)
16 ; long long *f = &b101, *g = &e101;
18 ; (void)((*f |= a101) - (*g = bar(d101)));
19 ; c101 = (*f |= a101 &= p1) == d101;
22 ; When compiled with Clang it gives a warning
23 ; warning: too few arguments in call to 'bar'
25 ; This ll reproducer has been reduced to only include tha call.
27 ; Note that -lint will report this as UB, but it passes -verify.
29 ; This test is just to verify that we do not crash/assert due to mismatch in
30 ; argument count between the caller and callee.
32 define dso_local void @foo(i16 %a) {
34 ; CHECK-NEXT: [[CALL:%.*]] = call i16 bitcast (i16 (i16, i16)* @bar to i16 (i16)*)(i16 [[A:%.*]])
35 ; CHECK-NEXT: ret void
37 %call = call i16 bitcast (i16 (i16, i16) * @bar to i16 (i16) *)(i16 %a)
41 define internal i16 @bar(i16 %p1, i16 %p2) {
43 ; CHECK-NEXT: ret i16 0
48 ;-------------------------------------------------------------------------------
49 ; Additional tests to verify that we still optimize when having a mismatch
50 ; in argument count due to varargs (as long as all non-variadic arguments have
53 define dso_local void @vararg_tests(i16 %a) {
54 %call1 = call i16 (i16, ...) @vararg_prop(i16 7, i16 8, i16 %a)
55 %call2 = call i16 bitcast (i16 (i16, i16, ...) * @vararg_no_prop to i16 (i16) *) (i16 7)
59 define internal i16 @vararg_prop(i16 %p1, ...) {
60 ; CHECK-LABEL: define internal i16 @vararg_prop(
61 ; CHECK-NEXT: ret i16 7
66 define internal i16 @vararg_no_prop(i16 %p1, i16 %p2, ...) {
67 ; CHECK-LABEL: define internal i16 @vararg_no_prop(
68 ; CHECK-NEXT: ret i16 [[P1:%.*]]