From b3dac3f5d9fcb4936aca385795abace8ed7600ef Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Wed, 17 Oct 2007 20:12:58 +0000 Subject: [PATCH] Do not raise free() call that is called through invoke instruction. llvm-svn: 43083 --- llvm/lib/Transforms/IPO/RaiseAllocations.cpp | 2 ++ .../RaiseAllocations/2007-10-17-InvokeFree.ll | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 llvm/test/Transforms/RaiseAllocations/2007-10-17-InvokeFree.ll diff --git a/llvm/lib/Transforms/IPO/RaiseAllocations.cpp b/llvm/lib/Transforms/IPO/RaiseAllocations.cpp index 44702bc81792..e6d8723f457b 100644 --- a/llvm/lib/Transforms/IPO/RaiseAllocations.cpp +++ b/llvm/lib/Transforms/IPO/RaiseAllocations.cpp @@ -204,6 +204,8 @@ bool RaiseAllocations::runOnModule(Module &M) { Users.pop_back(); if (Instruction *I = dyn_cast(U)) { + if (isa(I)) + continue; CallSite CS = CallSite::get(I); if (CS.getInstruction() && !CS.arg_empty() && (CS.getCalledFunction() == FreeFunc || diff --git a/llvm/test/Transforms/RaiseAllocations/2007-10-17-InvokeFree.ll b/llvm/test/Transforms/RaiseAllocations/2007-10-17-InvokeFree.ll new file mode 100644 index 000000000000..513cf6f339b1 --- /dev/null +++ b/llvm/test/Transforms/RaiseAllocations/2007-10-17-InvokeFree.ll @@ -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(...) +