[PATCH] D61105: [MS] Emit S_HEAPALLOCSITE debug info in SelectionDAG
Amy Huang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 24 17:07:45 PDT 2019
akhuang created this revision.
akhuang added a reviewer: rnk.
Herald added subscribers: llvm-commits, hiraditya, aprantl, MatzeB.
Herald added a project: LLVM.
This emits labels around heapallocsite calls in SelectionDAG.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D61105
Files:
llvm/include/llvm/CodeGen/SelectionDAG.h
llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/label-heapallocsite.ll
Index: llvm/test/CodeGen/X86/label-heapallocsite.ll
===================================================================
--- llvm/test/CodeGen/X86/label-heapallocsite.ll
+++ llvm/test/CodeGen/X86/label-heapallocsite.ll
@@ -1,5 +1,5 @@
+; RUN: llc < %s | FileCheck %s
; RUN: llc -O0 < %s | FileCheck %s
-; FIXME: Add test for llc with optimizations once it is implemented.
; Source to regenerate:
; $ clang --target=x86_64-windows-msvc -S heapallocsite.c -g -gcodeview -o t.ll \
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -4095,6 +4095,11 @@
}
InFlag = Chain.getValue(1);
+ // Save heapallocsite metadata.
+ if (CLI.CS && CLI.CS->getMetadata("heapallocsite"))
+ CLI.DAG.addHeapAllocSite(Chain.getNode(),
+ CLI.CS->getMetadata("heapallocsite"));
+
// Create the CALLSEQ_END node.
unsigned NumBytesForCalleeToPop;
if (X86::isCalleePop(CallConv, Is64Bit, isVarArg,
Index: llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
+++ llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
@@ -903,6 +903,10 @@
// Remember the source order of the inserted instruction.
if (HasDbg)
ProcessSourceNode(N, DAG, Emitter, VRBaseMap, Orders, Seen, NewInsn);
+
+ if (MDNode* MD = DAG->getHeapAllocSite(N))
+ MF.addCodeViewHeapAllocSite(NewInsn, MD);
+
GluedNodes.pop_back();
}
auto NewInsn =
@@ -911,6 +915,8 @@
if (HasDbg)
ProcessSourceNode(SU->getNode(), DAG, Emitter, VRBaseMap, Orders, Seen,
NewInsn);
+ if (MDNode* MD = DAG->getHeapAllocSite(SU->getNode()))
+ MF.addCodeViewHeapAllocSite(NewInsn, MD);
}
// Insert all the dbg_values which have not already been inserted in source
Index: llvm/include/llvm/CodeGen/SelectionDAG.h
===================================================================
--- llvm/include/llvm/CodeGen/SelectionDAG.h
+++ llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -267,6 +267,9 @@
/// Tracks dbg_value and dbg_label information through SDISel.
SDDbgInfo *DbgInfo;
+ /// Save nodes with heapallocsite metadata.
+ DenseMap<const SDNode*, MDNode*> CodeViewHeapAllocSites;
+
uint16_t NextPersistentId = 0;
public:
@@ -1626,6 +1629,18 @@
isConstantFPBuildVectorOrConstantFP(N);
}
+ void addHeapAllocSite(const SDNode* Node, MDNode* MD) {
+ CodeViewHeapAllocSites.insert({Node, MD});
+ }
+
+ /// Return the HeapAllocSite type associated with the SDNode, if it exists.
+ MDNode *getHeapAllocSite(const SDNode* Node) {
+ if (CodeViewHeapAllocSites.find(Node) == CodeViewHeapAllocSites.end())
+ return nullptr;
+ return CodeViewHeapAllocSites[Node];
+ }
+
+
private:
void InsertNode(SDNode *N);
bool RemoveNodeFromCSEMaps(SDNode *N);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61105.196556.patch
Type: text/x-patch
Size: 3042 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190425/cdb3fd4b/attachment.bin>
More information about the llvm-commits
mailing list