summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp32
1 files changed, 9 insertions, 23 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 62ad356e7f8..c6457f3626d 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -1100,8 +1100,14 @@ void CodeViewDebug::emitDebugInfoForFunction(const Function *GV,
}
for (auto HeapAllocSite : FI.HeapAllocSites) {
- const MCSymbol *BeginLabel = std::get<0>(HeapAllocSite);
- const MCSymbol *EndLabel = std::get<1>(HeapAllocSite);
+ MCSymbol *BeginLabel = std::get<0>(HeapAllocSite);
+ MCSymbol *EndLabel = std::get<1>(HeapAllocSite);
+
+ // The labels might not be defined if the instruction was replaced
+ // somewhere in the codegen pipeline.
+ if (!BeginLabel->isDefined() || !EndLabel->isDefined())
+ continue;
+
const DIType *DITy = std::get<2>(HeapAllocSite);
MCSymbol *HeapAllocEnd = beginSymbolRecord(SymbolKind::S_HEAPALLOCSITE);
OS.AddComment("Call site offset");
@@ -1421,16 +1427,6 @@ void CodeViewDebug::beginFunctionImpl(const MachineFunction *MF) {
DebugLoc FnStartDL = PrologEndLoc.getFnDebugLoc();
maybeRecordLocation(FnStartDL, MF);
}
-
- // Find heap alloc sites and emit labels around them.
- for (const auto &MBB : *MF) {
- for (const auto &MI : MBB) {
- if (MI.getHeapAllocMarker()) {
- requestLabelBeforeInsn(&MI);
- requestLabelAfterInsn(&MI);
- }
- }
- }
}
static bool shouldEmitUdt(const DIType *T) {
@@ -2854,18 +2850,8 @@ void CodeViewDebug::endFunctionImpl(const MachineFunction *MF) {
return;
}
- // Find heap alloc sites and add to list.
- for (const auto &MBB : *MF) {
- for (const auto &MI : MBB) {
- if (MDNode *MD = MI.getHeapAllocMarker()) {
- CurFn->HeapAllocSites.push_back(std::make_tuple(getLabelBeforeInsn(&MI),
- getLabelAfterInsn(&MI),
- dyn_cast<DIType>(MD)));
- }
- }
- }
-
CurFn->Annotations = MF->getCodeViewAnnotations();
+ CurFn->HeapAllocSites = MF->getCodeViewHeapAllocSites();
CurFn->End = Asm->getFunctionEnd();
OpenPOWER on IntegriCloud