[DWARF] Pick the DWARF5 OP_entry_value opcode on Darwin
Use the GNU extension for OP_entry_value consistently (i.e. whenever GNU
extensions are used for TAG_call_site).
llvm-svn: 369966
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 46c8bd8..4ed452d 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -892,9 +892,13 @@
ContextCU->addDIEEntry(*AbsDef, dwarf::DW_AT_object_pointer, *ObjectPointer);
}
+/// Whether to use the GNU analog for a DWARF5 tag, attribute, or location atom.
+static bool useGNUAnalogForDwarf5Feature(DwarfDebug *DD) {
+ return DD->getDwarfVersion() == 4 && DD->tuneForGDB();
+}
+
dwarf::Tag DwarfCompileUnit::getDwarf5OrGNUCallSiteTag(dwarf::Tag Tag) const {
- bool ApplyGNUExtensions = DD->getDwarfVersion() == 4 && DD->tuneForGDB();
- if (!ApplyGNUExtensions)
+ if (!useGNUAnalogForDwarf5Feature(DD))
return Tag;
switch (Tag) {
case dwarf::DW_TAG_call_site:
@@ -908,8 +912,7 @@
dwarf::Attribute
DwarfCompileUnit::getDwarf5OrGNUCallSiteAttr(dwarf::Attribute Attr) const {
- bool ApplyGNUExtensions = DD->getDwarfVersion() == 4 && DD->tuneForGDB();
- if (!ApplyGNUExtensions)
+ if (!useGNUAnalogForDwarf5Feature(DD))
return Attr;
switch (Attr) {
case dwarf::DW_AT_call_all_calls:
@@ -929,6 +932,18 @@
}
}
+dwarf::LocationAtom
+DwarfCompileUnit::getDwarf5OrGNULocationAtom(dwarf::LocationAtom Loc) const {
+ if (!useGNUAnalogForDwarf5Feature(DD))
+ return Loc;
+ switch (Loc) {
+ case dwarf::DW_OP_entry_value:
+ return dwarf::DW_OP_GNU_entry_value;
+ default:
+ llvm_unreachable("DWARF5 location atom with no GNU analog");
+ }
+}
+
DIE &DwarfCompileUnit::constructCallSiteEntryDIE(
DIE &ScopeDIE, const DISubprogram *CalleeSP, bool IsTail,
const MCSymbol *PCAddr, const MCExpr *PCOffset, unsigned CallReg) {