llvm.org GIT mirror llvm / 4f7a137
Merging r226708: ------------------------------------------------------------------------ r226708 | majnemer | 2015-01-21 14:32:04 -0800 (Wed, 21 Jan 2015) | 4 lines InstCombine: Don't strip bitcasts off of callsites marked 'thunk' The return type of a thunk is meaningless, we just want the arguments and return value to be forwarded. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_36@226854 91177308-0d34-0410-b5e6-96231b3b80d8 Hans Wennborg 4 years ago
2 changed file(s) with 15 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
13751375 dyn_cast(CS.getCalledValue()->stripPointerCasts());
13761376 if (!Callee)
13771377 return false;
1378 // The prototype of thunks are a lie, don't try to directly call such
1379 // functions.
1380 if (Callee->hasFnAttribute("thunk"))
1381 return false;
13781382 Instruction *Caller = CS.getInstruction();
13791383 const AttributeSet &CallerPAL = CS.getAttributes();
13801384
6060 %call = tail call i32 bitcast (i32 (i64)* @fn3 to i32 (i32*)*)(i32* %a)
6161 ret i32 %call
6262 }
63
64 declare i32 @fn4(i32) "thunk"
65
66 define i32 @test4(i32* %a) {
67 ; CHECK-LABEL: @test4
68 ; CHECK: %[[call:.*]] = tail call i32 bitcast (i32 (i32)* @fn4 to i32 (i32*)*)(i32* %a)
69 ; CHECK-NEXT: ret i32 %[[call]]
70 entry:
71 %call = tail call i32 bitcast (i32 (i32)* @fn4 to i32 (i32*)*)(i32* %a)
72 ret i32 %call
73 }