xref: /aosp_15_r20/external/llvm/test/Transforms/Inline/inline-musttail-varargs.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -inline -instcombine -S | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; We can't inline this thunk yet, but one day we will be able to.  And when we
4*9880d681SAndroid Build Coastguard Worker; do, this test case will be ready.
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workerdeclare void @ext_method(i8*, i32)
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Workerdefine linkonce_odr void @thunk(i8* %this, ...) {
9*9880d681SAndroid Build Coastguard Worker  %this_adj = getelementptr i8, i8* %this, i32 4
10*9880d681SAndroid Build Coastguard Worker  musttail call void (i8*, ...) bitcast (void (i8*, i32)* @ext_method to void (i8*, ...)*)(i8* %this_adj, ...)
11*9880d681SAndroid Build Coastguard Worker  ret void
12*9880d681SAndroid Build Coastguard Worker}
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Workerdefine void @thunk_caller(i8* %p) {
15*9880d681SAndroid Build Coastguard Worker  call void (i8*, ...) @thunk(i8* %p, i32 42)
16*9880d681SAndroid Build Coastguard Worker  ret void
17*9880d681SAndroid Build Coastguard Worker}
18*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: define void @thunk_caller(i8* %p)
19*9880d681SAndroid Build Coastguard Worker; CHECK: call void (i8*, ...) @thunk(i8* %p, i32 42)
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard Worker; FIXME: Inline the thunk. This should be significantly easier than inlining
22*9880d681SAndroid Build Coastguard Worker; general varargs functions.
23