summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/CodeExtractor.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2018-11-06 19:05:53 +0000
committerVedant Kumar <vsk@apple.com>2018-11-06 19:05:53 +0000
commit09b7aa443d6b40b0bc4dc7d43f61dcf1d420fd3b (patch)
treeec1289a7c2154ec5fad3b1f956bbf3263b5996a5 /llvm/lib/Transforms/Utils/CodeExtractor.cpp
parentc6613879ce57e9e9947b9a91f9f0a9ef7382fb2c (diff)
downloadbcm5719-llvm-09b7aa443d6b40b0bc4dc7d43f61dcf1d420fd3b.tar.gz
bcm5719-llvm-09b7aa443d6b40b0bc4dc7d43f61dcf1d420fd3b.zip
[CodeExtractor] Erase use-without-def debug intrinsics in parent func
When CodeExtractor moves instructions to a new function, debug intrinsics referring to those instructions within the parent function become invalid. This results in the same verifier failure which motivated r344545, about function-local metadata being used in the wrong function. llvm-svn: 346255
Diffstat (limited to 'llvm/lib/Transforms/Utils/CodeExtractor.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/CodeExtractor.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
index 462dc588cd5..4e48910b03c 100644
--- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -57,6 +57,7 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
+#include "llvm/Transforms/Utils/Local.h"
#include <cassert>
#include <cstdint>
#include <iterator>
@@ -1305,12 +1306,20 @@ Function *CodeExtractor::extractCodeRegion() {
// for the new function.
for (BasicBlock &BB : *newFunction) {
auto BlockIt = BB.begin();
+ // Remove debug info intrinsics from the new function.
while (BlockIt != BB.end()) {
Instruction *Inst = &*BlockIt;
++BlockIt;
if (isa<DbgInfoIntrinsic>(Inst))
Inst->eraseFromParent();
}
+ // Remove debug info intrinsics which refer to values in the new function
+ // from the old function.
+ SmallVector<DbgVariableIntrinsic *, 4> DbgUsers;
+ for (Instruction &I : BB)
+ findDbgUsers(DbgUsers, &I);
+ for (DbgVariableIntrinsic *DVI : DbgUsers)
+ DVI->eraseFromParent();
}
LLVM_DEBUG(if (verifyFunction(*newFunction))
OpenPOWER on IntegriCloud