Do not raise free() call that is called through invoke instruction.
authorDevang Patel <dpatel@apple.com>
Wed, 17 Oct 2007 20:12:58 +0000 (20:12 +0000)
committerDevang Patel <dpatel@apple.com>
Wed, 17 Oct 2007 20:12:58 +0000 (20:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43083 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/IPO/RaiseAllocations.cpp
test/Transforms/RaiseAllocations/2007-10-17-InvokeFree.ll [new file with mode: 0644]

index 44702bc81792f1fe53cbdc5fd5dcae10aaf1e904..e6d8723f457b3d2df2994af749d616df9b8a1ae1 100644 (file)
@@ -204,6 +204,8 @@ bool RaiseAllocations::runOnModule(Module &M) {
       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 ||
diff --git a/test/Transforms/RaiseAllocations/2007-10-17-InvokeFree.ll b/test/Transforms/RaiseAllocations/2007-10-17-InvokeFree.ll
new file mode 100644 (file)
index 0000000..513cf6f
--- /dev/null
@@ -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(...)
+