DeadArgElim: Don't mark swifterror arguments as unused

Replacing swifterror arguments with undef creates invalid IR.

rdar://28300490

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282075 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Arnold Schwaighofer 2016-09-21 15:29:08 +00:00
parent cbe1f9e0e2
commit e9993d5a21
2 changed files with 16 additions and 1 deletions

View File

@ -270,7 +270,7 @@ bool DeadArgumentEliminationPass::RemoveDeadArgumentsFromCallers(Function &Fn) {
SmallVector<unsigned, 8> UnusedArgs;
for (Argument &Arg : Fn.args()) {
if (Arg.use_empty() && !Arg.hasByValOrInAllocaAttr())
if (!Arg.hasSwiftErrorAttr() && Arg.use_empty() && !Arg.hasByValOrInAllocaAttr())
UnusedArgs.push_back(Arg.getArgNo());
}

View File

@ -50,3 +50,18 @@ entry:
ret void
}
%swift_error = type opaque
define void @unused_swifterror_arg(%swift_error** swifterror %dead_arg) {
tail call void @sideeffect() nounwind
ret void
}
; CHECK-LABEL: @dont_replace_by_undef
; CHECK-NOT: call void @unused_swifterror_arg({{.*}}undef)
define void @dont_replace_by_undef() {
%error_ptr_ref = alloca swifterror %swift_error*
store %swift_error* null, %swift_error** %error_ptr_ref
call void @unused_swifterror_arg(%swift_error** %error_ptr_ref)
ret void
}