mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-11 21:57:55 +00:00
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/trunk@226708 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a7a4b836a3
commit
c070e4e528
@ -1381,6 +1381,10 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
|
||||
dyn_cast<Function>(CS.getCalledValue()->stripPointerCasts());
|
||||
if (!Callee)
|
||||
return false;
|
||||
// The prototype of thunks are a lie, don't try to directly call such
|
||||
// functions.
|
||||
if (Callee->hasFnAttribute("thunk"))
|
||||
return false;
|
||||
Instruction *Caller = CS.getInstruction();
|
||||
const AttributeSet &CallerPAL = CS.getAttributes();
|
||||
|
||||
|
@ -61,3 +61,14 @@ entry:
|
||||
%call = tail call i32 bitcast (i32 (i64)* @fn3 to i32 (i32*)*)(i32* %a)
|
||||
ret i32 %call
|
||||
}
|
||||
|
||||
declare i32 @fn4(i32) "thunk"
|
||||
|
||||
define i32 @test4(i32* %a) {
|
||||
; CHECK-LABEL: @test4
|
||||
; CHECK: %[[call:.*]] = tail call i32 bitcast (i32 (i32)* @fn4 to i32 (i32*)*)(i32* %a)
|
||||
; CHECK-NEXT: ret i32 %[[call]]
|
||||
entry:
|
||||
%call = tail call i32 bitcast (i32 (i32)* @fn4 to i32 (i32*)*)(i32* %a)
|
||||
ret i32 %call
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user