[PATCH] D25132: Invoke add-discriminator at -g0 -fsample-profile
Dehao Chen via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 7 07:03:55 PDT 2016
danielcdh updated this revision to Diff 73929.
danielcdh added a comment.
Herald added a subscriber: mehdi_amini.
Invoke add-discriminator regardless of -fsample-profile.
https://reviews.llvm.org/D25132
Files:
lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
lib/CodeGen/AsmPrinter/DwarfDebug.cpp
lib/MC/MCDwarf.cpp
lib/Transforms/Utils/AddDiscriminators.cpp
Index: lib/Transforms/Utils/AddDiscriminators.cpp
===================================================================
--- lib/Transforms/Utils/AddDiscriminators.cpp
+++ lib/Transforms/Utils/AddDiscriminators.cpp
@@ -159,10 +159,7 @@
// If the function has debug information, but the user has disabled
// discriminators, do nothing.
// Simlarly, if the function has no debug info, do nothing.
- // Finally, if this module is built with dwarf versions earlier than 4,
- // do nothing (discriminator support is a DWARF 4 feature).
- if (NoDiscriminators || !F.getSubprogram() ||
- F.getParent()->getDwarfVersion() < 4)
+ if (NoDiscriminators || !F.getSubprogram())
return false;
bool Changed = false;
Index: lib/MC/MCDwarf.cpp
===================================================================
--- lib/MC/MCDwarf.cpp
+++ lib/MC/MCDwarf.cpp
@@ -122,7 +122,8 @@
MCOS->EmitIntValue(dwarf::DW_LNS_set_column, 1);
MCOS->EmitULEB128IntValue(Column);
}
- if (Discriminator != LineEntry.getDiscriminator()) {
+ if (Discriminator != LineEntry.getDiscriminator() &&
+ MCOS->getContext().getDwarfVersion() >= 4) {
Discriminator = LineEntry.getDiscriminator();
unsigned Size = getULEB128Size(Discriminator);
MCOS->EmitIntValue(dwarf::DW_LNS_extended_op, 1);
Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1190,7 +1190,8 @@
Fn = Scope->getFilename();
Dir = Scope->getDirectory();
if (auto *LBF = dyn_cast<DILexicalBlockFile>(Scope))
- Discriminator = LBF->getDiscriminator();
+ if (DwarfVersion >= 4)
+ Discriminator = LBF->getDiscriminator();
unsigned CUID = Asm->OutStreamer->getContext().getDwarfCompileUnitID();
Src = static_cast<DwarfCompileUnit &>(*InfoHolder.getUnits()[CUID])
Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -419,7 +419,7 @@
addUInt(*ScopeDIE, dwarf::DW_AT_call_file, None,
getOrCreateSourceID(IA->getFilename(), IA->getDirectory()));
addUInt(*ScopeDIE, dwarf::DW_AT_call_line, None, IA->getLine());
- if (IA->getDiscriminator())
+ if (IA->getDiscriminator() && DD->getDwarfVersion() >= 4)
addUInt(*ScopeDIE, dwarf::DW_AT_GNU_discriminator, None,
IA->getDiscriminator());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25132.73929.patch
Type: text/x-patch
Size: 2569 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161007/cddd916b/attachment.bin>
More information about the llvm-commits
mailing list