[llvm] r282075 - DeadArgElim: Don't mark swifterror arguments as unused

Arnold Schwaighofer via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 21 08:29:09 PDT 2016


Author: arnolds
Date: Wed Sep 21 10:29:08 2016
New Revision: 282075

URL: http://llvm.org/viewvc/llvm-project?rev=282075&view=rev
Log:
DeadArgElim: Don't mark swifterror arguments as unused

Replacing swifterror arguments with undef creates invalid IR.

rdar://28300490

Modified:
    llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
    llvm/trunk/test/Transforms/DeadArgElim/deadexternal.ll

Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=282075&r1=282074&r2=282075&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Wed Sep 21 10:29:08 2016
@@ -270,7 +270,7 @@ bool DeadArgumentEliminationPass::Remove
 
   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());
   }
 

Modified: llvm/trunk/test/Transforms/DeadArgElim/deadexternal.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadArgElim/deadexternal.ll?rev=282075&r1=282074&r2=282075&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/DeadArgElim/deadexternal.ll (original)
+++ llvm/trunk/test/Transforms/DeadArgElim/deadexternal.ll Wed Sep 21 10:29:08 2016
@@ -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
+}




More information about the llvm-commits mailing list