diff options
author | Chris Lattner <sabre@nondot.org> | 2003-09-16 19:42:21 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-09-16 19:42:21 +0000 |
commit | cc838348fc4eb60b09f6ef9cd248be347112c7a9 (patch) | |
tree | 0686f326f1d66163665b6d895694882b8d5988de /lib/Transforms/IPO | |
parent | 1cbcd0fd48869afd12eedf9017dbb545b360c37f (diff) | |
download | external_llvm-cc838348fc4eb60b09f6ef9cd248be347112c7a9.zip external_llvm-cc838348fc4eb60b09f6ef9cd248be347112c7a9.tar.gz external_llvm-cc838348fc4eb60b09f6ef9cd248be347112c7a9.tar.bz2 |
Fix bug raising allocations whose call sites were invoke instructions.
Thanks to brg for tracking down the problem so precisely!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8568 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO')
-rw-r--r-- | lib/Transforms/IPO/RaiseAllocations.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp index 62355be..d214d2e 100644 --- a/lib/Transforms/IPO/RaiseAllocations.cpp +++ b/lib/Transforms/IPO/RaiseAllocations.cpp @@ -9,6 +9,7 @@ #include "llvm/Module.h" #include "llvm/DerivedTypes.h" #include "llvm/iMemory.h" +#include "llvm/iTerminators.h" #include "llvm/iOther.h" #include "llvm/Pass.h" #include "llvm/Support/CallSite.h" @@ -130,6 +131,13 @@ bool RaiseAllocations::run(Module &M) { std::string Name(I->getName()); I->setName(""); MallocInst *MI = new MallocInst(Type::SByteTy, Source, Name, I); I->replaceAllUsesWith(MI); + + // If the old instruction was an invoke, add an unconditional branch + // before the invoke, which will become the new terminator. + if (InvokeInst *II = dyn_cast<InvokeInst>(I)) + new BranchInst(II->getNormalDest(), I); + + // Delete the old call site MI->getParent()->getInstList().erase(I); Changed = true; ++NumRaised; @@ -160,6 +168,13 @@ bool RaiseAllocations::run(Module &M) { Source = new CastInst(Source, PointerType::get(Type::SByteTy), "FreePtrCast", I); new FreeInst(Source, I); + + // If the old instruction was an invoke, add an unconditional branch + // before the invoke, which will become the new terminator. + if (InvokeInst *II = dyn_cast<InvokeInst>(I)) + new BranchInst(II->getNormalDest(), I); + + // Delete the old call site I->getParent()->getInstList().erase(I); Changed = true; ++NumRaised; |