[PATCH] Refactoring gc_relocate related code in CodeGenPrepare.cpp
Sanjoy Das
sanjoy at playingwithpointers.com
Mon May 11 16:51:09 PDT 2015
REPOSITORY
rL LLVM
http://reviews.llvm.org/D9687
Files:
llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
Index: llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
+++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
@@ -598,7 +598,10 @@
continue;
// Create a Builder and replace the target callsite with a gep
- IRBuilder<> Builder(ToReplace);
+ assert(RelocatedBase->getNextNode() && "Should always have one since it's not a terminator");
+
+ // Insert after RelocatedBase
+ IRBuilder<> Builder(RelocatedBase->getNextNode());
Builder.SetCurrentDebugLocation(ToReplace->getDebugLoc());
// If gc_relocate does not match the actual type, cast it to the right type.
@@ -626,23 +629,17 @@
if (RelocatedBase->getType() != Base->getType()) {
ActualRelocatedBase =
cast<Instruction>(Builder.CreateBitCast(RelocatedBase, Base->getType()));
- ActualRelocatedBase->removeFromParent();
- ActualRelocatedBase->insertAfter(cast<Instruction>(RelocatedBase));
}
Value *Replacement = Builder.CreateGEP(
Derived->getSourceElementType(), ActualRelocatedBase, makeArrayRef(OffsetV));
Instruction *ReplacementInst = cast<Instruction>(Replacement);
- ReplacementInst->removeFromParent();
- ReplacementInst->insertAfter(ActualRelocatedBase);
Replacement->takeName(ToReplace);
// If the newly generated derived pointer's type does not match the original derived
// pointer's type, cast the new derived pointer to match it. Same reasoning as above.
Instruction *ActualReplacement = ReplacementInst;
if (ReplacementInst->getType() != ToReplace->getType()) {
ActualReplacement =
cast<Instruction>(Builder.CreateBitCast(ReplacementInst, ToReplace->getType()));
- ActualReplacement->removeFromParent();
- ActualReplacement->insertAfter(ReplacementInst);
}
ToReplace->replaceAllUsesWith(ActualReplacement);
ToReplace->eraseFromParent();
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D9687.25530.patch
Type: text/x-patch
Size: 1970 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150511/67186216/attachment.bin>
More information about the llvm-commits
mailing list