forked from OSchip/llvm-project
[DeadArgElim] Check that function type is the same
If the function types differ, the call arguments don't necessarily correspon to the function arguments. It's likely not worthwhile to handle this more precisely, but at least we shouldn't crash.
This commit is contained in:
parent
c72fdad71b
commit
41c5a762e5
|
@ -306,7 +306,8 @@ bool DeadArgumentEliminationPass::RemoveDeadArgumentsFromCallers(Function &Fn) {
|
|||
|
||||
for (Use &U : Fn.uses()) {
|
||||
CallBase *CB = dyn_cast<CallBase>(U.getUser());
|
||||
if (!CB || !CB->isCallee(&U))
|
||||
if (!CB || !CB->isCallee(&U) ||
|
||||
CB->getFunctionType() != Fn.getFunctionType())
|
||||
continue;
|
||||
|
||||
// Now go through all unused args and replace them with "undef".
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature
|
||||
; RUN: opt -S -passes=deadargelim -opaque-pointers < %s | FileCheck %s
|
||||
|
||||
define void @callee(i32 %unused) {
|
||||
; CHECK-LABEL: define {{[^@]+}}@callee
|
||||
; CHECK-SAME: (i32 [[UNUSED:%.*]]) {
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @caller() {
|
||||
; CHECK-LABEL: define {{[^@]+}}@caller() {
|
||||
; CHECK-NEXT: call void @callee(i32 undef)
|
||||
; CHECK-NEXT: call void @callee()
|
||||
; CHECK-NEXT: call void @callee(i32 42, i32 24)
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
call void @callee(i32 42)
|
||||
call void @callee()
|
||||
call void @callee(i32 42, i32 24)
|
||||
ret void
|
||||
}
|
Loading…
Reference in New Issue