[llvm-commits] CVS: llvm/lib/Transforms/IPO/RaiseAllocations.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Sep 16 14:43:01 PDT 2003
Changes in directory llvm/lib/Transforms/IPO:
RaiseAllocations.cpp updated: 1.17 -> 1.18
---
Log message:
Fix bug raising allocations whose call sites were invoke instructions.
Thanks to brg for tracking down the problem so precisely!
---
Diffs of the changes:
Index: llvm/lib/Transforms/IPO/RaiseAllocations.cpp
diff -u llvm/lib/Transforms/IPO/RaiseAllocations.cpp:1.17 llvm/lib/Transforms/IPO/RaiseAllocations.cpp:1.18
--- llvm/lib/Transforms/IPO/RaiseAllocations.cpp:1.17 Sun Aug 31 22:14:56 2003
+++ llvm/lib/Transforms/IPO/RaiseAllocations.cpp Tue Sep 16 14:42:21 2003
@@ -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 @@
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 @@
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;
More information about the llvm-commits
mailing list