forked from OSchip/llvm-project
[DeadArgElim] Guard against function type mismatch
If the call function type and function type don't match, we should consider the function live (there is effectively a bitcast sitting in between).
This commit is contained in:
parent
cf18ec445d
commit
3ec44c22b1
|
@ -560,7 +560,8 @@ void DeadArgumentEliminationPass::SurveyFunction(const Function &F) {
|
|||
// If the function is PASSED IN as an argument, its address has been
|
||||
// taken.
|
||||
const auto *CB = dyn_cast<CallBase>(U.getUser());
|
||||
if (!CB || !CB->isCallee(&U)) {
|
||||
if (!CB || !CB->isCallee(&U) ||
|
||||
CB->getFunctionType() != F.getFunctionType()) {
|
||||
MarkLive(F);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -21,3 +21,21 @@ define void @caller() {
|
|||
call void @callee(i32 42, i32 24)
|
||||
ret void
|
||||
}
|
||||
|
||||
define internal i16 @callee2(i16 %p1, i16 %p2) {
|
||||
; CHECK-LABEL: define {{[^@]+}}@callee2
|
||||
; CHECK-SAME: (i16 [[P1:%.*]], i16 [[P2:%.*]]) {
|
||||
; CHECK-NEXT: ret i16 [[P2]]
|
||||
;
|
||||
ret i16 %p2
|
||||
}
|
||||
|
||||
define i16 @caller2(i16 %a) {
|
||||
; CHECK-LABEL: define {{[^@]+}}@caller2
|
||||
; CHECK-SAME: (i16 [[A:%.*]]) {
|
||||
; CHECK-NEXT: [[CALL:%.*]] = call i16 @callee2(i16 [[A]], i32 42)
|
||||
; CHECK-NEXT: ret i16 [[CALL]]
|
||||
;
|
||||
%call = call i16 @callee2(i16 %a, i32 42)
|
||||
ret i16 %call
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue