[llvm] r283565 - Invoke add-discriminator at -g0 -fsample-profile
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 10 11:29:15 PDT 2016
On Fri, Oct 7, 2016 at 8:30 AM Dehao Chen via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: dehao
>
> Date: Fri Oct 7 10:21:31 2016
>
> New Revision: 283565
>
>
>
> URL: http://llvm.org/viewvc/llvm-project?rev=283565&view=rev
>
> Log:
>
> Invoke add-discriminator at -g0 -fsample-profile
>
>
>
> Summary: -fsample-profile needs discriminator, which will not be added if
> built with -g0. This patch makes sure the discriminator is added for
> sample-profile at -g0. A followup patch will be send out to update clang
> tests.
>
>
>
> Reviewers: davidxl, dblaikie, echristo, dnovillo
>
>
>
> Subscribers: mehdi_amini, probinson, llvm-commits
>
>
>
> Differential Revision: https://reviews.llvm.org/D25132
>
>
>
> Modified:
>
> llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
>
> llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>
> llvm/trunk/lib/MC/MCDwarf.cpp
>
> llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp
>
>
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
>
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=283565&r1=283564&r2=283565&view=diff
>
>
> ==============================================================================
>
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
>
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Fri Oct 7
> 10:21:31 2016
>
> @@ -419,7 +419,7 @@ DIE *DwarfCompileUnit::constructInlinedS
>
> 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)
>
Does this have test coverage? (if I remove this check for DwarfVersion,
will a test fail)
>
> addUInt(*ScopeDIE, dwarf::DW_AT_GNU_discriminator, None,
>
> IA->getDiscriminator());
>
>
>
>
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
>
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=283565&r1=283564&r2=283565&view=diff
>
>
> ==============================================================================
>
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
>
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri Oct 7 10:21:31
> 2016
>
> @@ -1190,7 +1190,8 @@ void DwarfDebug::recordSourceLine(unsign
>
> 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])
>
>
>
> Modified: llvm/trunk/lib/MC/MCDwarf.cpp
>
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=283565&r1=283564&r2=283565&view=diff
>
>
> ==============================================================================
>
> --- llvm/trunk/lib/MC/MCDwarf.cpp (original)
>
> +++ llvm/trunk/lib/MC/MCDwarf.cpp Fri Oct 7 10:21:31 2016
>
> @@ -122,7 +122,8 @@ EmitDwarfLineTable(MCObjectStreamer *MCO
>
> 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);
>
>
>
> Modified: llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp
>
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp?rev=283565&r1=283564&r2=283565&view=diff
>
>
> ==============================================================================
>
> --- llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp (original)
>
> +++ llvm/trunk/lib/Transforms/Utils/AddDiscriminators.cpp Fri Oct 7
> 10:21:31 2016
>
> @@ -159,10 +159,7 @@ static bool addDiscriminators(Function &
>
> // 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;
>
>
>
>
>
> _______________________________________________
>
> llvm-commits mailing list
>
> llvm-commits at lists.llvm.org
>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161010/c342d8ad/attachment.html>
More information about the llvm-commits
mailing list