summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils/CodeExtractor.cpp
diff options
context:
space:
mode:
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