[llvm-commits] [llvm] r71676 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/nothrow.ll

Chris Lattner sabre at nondot.org
Wed May 13 10:39:34 PDT 2009


Author: lattner
Date: Wed May 13 12:39:14 2009
New Revision: 71676

URL: http://llvm.org/viewvc/llvm-project?rev=71676&view=rev
Log:
calls in nothrow functions can be marked nothrow even if the callee
is not known to be nothrow.  This allows readnone/readonly functions
to be deleted even if we don't know whether the callee can throw.

Added:
    llvm/trunk/test/Transforms/InstCombine/nothrow.ll
Modified:
    llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp?rev=71676&r1=71675&r2=71676&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InstructionCombining.cpp Wed May 13 12:39:14 2009
@@ -9578,6 +9578,16 @@
 /// the heavy lifting.
 ///
 Instruction *InstCombiner::visitCallInst(CallInst &CI) {
+  // If the caller function is nounwind, mark the call as nounwind, even if the
+  // callee isn't.
+  if (CI.getParent()->getParent()->doesNotThrow() &&
+      !CI.doesNotThrow()) {
+    CI.setDoesNotThrow();
+    return &CI;
+  }
+  
+  
+  
   IntrinsicInst *II = dyn_cast<IntrinsicInst>(&CI);
   if (!II) return visitCallSite(&CI);
   

Added: llvm/trunk/test/Transforms/InstCombine/nothrow.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/nothrow.ll?rev=71676&view=auto

==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/nothrow.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/nothrow.ll Wed May 13 12:39:14 2009
@@ -0,0 +1,8 @@
+; RUN: llvm-as < %s | opt -instcombine | llvm-dis | not grep call
+; rdar://6880732
+declare double @t1(i32) readonly
+
+define void @t2() nounwind {
+  call double @t1(i32 42)  ;; dead call even though callee is not nothrow.
+  ret void
+}





More information about the llvm-commits mailing list