[llvm-commits] [llvm] r43083 - in /llvm/trunk: lib/Transforms/IPO/RaiseAllocations.cpp test/Transforms/RaiseAllocations/2007-10-17-InvokeFree.ll

Devang Patel dpatel at apple.com
Wed Oct 17 13:12:58 PDT 2007


Author: dpatel
Date: Wed Oct 17 15:12:58 2007
New Revision: 43083

URL: http://llvm.org/viewvc/llvm-project?rev=43083&view=rev
Log:
Do not raise free() call that is called through invoke instruction.

Added:
    llvm/trunk/test/Transforms/RaiseAllocations/2007-10-17-InvokeFree.ll
Modified:
    llvm/trunk/lib/Transforms/IPO/RaiseAllocations.cpp

Modified: llvm/trunk/lib/Transforms/IPO/RaiseAllocations.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/RaiseAllocations.cpp?rev=43083&r1=43082&r2=43083&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/RaiseAllocations.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/RaiseAllocations.cpp Wed Oct 17 15:12:58 2007
@@ -204,6 +204,8 @@
       Users.pop_back();
 
       if (Instruction *I = dyn_cast<Instruction>(U)) {
+        if (isa<InvokeInst>(I))
+          continue;
         CallSite CS = CallSite::get(I);
         if (CS.getInstruction() && !CS.arg_empty() &&
             (CS.getCalledFunction() == FreeFunc ||

Added: llvm/trunk/test/Transforms/RaiseAllocations/2007-10-17-InvokeFree.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/RaiseAllocations/2007-10-17-InvokeFree.ll?rev=43083&view=auto

==============================================================================
--- llvm/trunk/test/Transforms/RaiseAllocations/2007-10-17-InvokeFree.ll (added)
+++ llvm/trunk/test/Transforms/RaiseAllocations/2007-10-17-InvokeFree.ll Wed Oct 17 15:12:58 2007
@@ -0,0 +1,17 @@
+; RUN: llvm-as <%s | opt -raiseallocs -stats -disable-output |&  \
+; RUN:  not grep {Number of allocations raised}
+define void @foo() {
+entry:
+	%buffer = alloca i16*
+	%tmp = load i16** %buffer, align 8
+	invoke i32(...)* @free(i16* %tmp)
+		to label %invcont unwind label %unwind
+invcont:
+	br label %finally
+unwind:
+	br label %finally
+finally:
+	ret void
+}
+declare i32 @free(...)
+





More information about the llvm-commits mailing list