[llvm] r291172 - PR 31534: When emitting both DWARF unwind tables and debug information,

Sean Silva via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 6 16:33:05 PST 2017


On Thu, Jan 5, 2017 at 12:55 PM, Joerg Sonnenberger via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: joerg
> Date: Thu Jan  5 14:55:28 2017
> New Revision: 291172
>
> URL: http://llvm.org/viewvc/llvm-project?rev=291172&view=rev
> Log:
> PR 31534: When emitting both DWARF unwind tables and debug information,
> do not use .cfi_sections. This requires checking if any non-declaration
> function in the module needs an unwind table.
>
> Added:
>     llvm/trunk/test/CodeGen/Generic/cfi-sections.ll
> Modified:
>     llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
>     llvm/trunk/lib/CodeGen/AsmPrinter/ARMException.cpp
>     llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
>     llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
>
> Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/
> llvm/CodeGen/AsmPrinter.h?rev=291172&r1=291171&r2=291172&view=diff
> ============================================================
> ==================
> --- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Thu Jan  5 14:55:28 2017
> @@ -140,6 +140,9 @@ private:
>    /// If the target supports dwarf debug info, this pointer is non-null.
>    DwarfDebug *DD;
>
> +  /// If the current module uses dwarf CFI annotations strictly for
> debugging.
> +  bool isCFIMoveForDebugging;
> +
>

capitalize.

-- Sean Silva


>  protected:
>    explicit AsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer>
> Streamer);
>
> @@ -262,6 +265,10 @@ public:
>    enum CFIMoveType { CFI_M_None, CFI_M_EH, CFI_M_Debug };
>    CFIMoveType needsCFIMoves();
>
> +  /// Returns false if needsCFIMoves() == CFI_M_EH for any function
> +  /// in the module.
> +  bool needsOnlyDebugCFIMoves() const { return isCFIMoveForDebugging; }
> +
>    bool needsSEHMoves();
>
>    /// Print to the current output stream assembly representations of the
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/ARMException.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> CodeGen/AsmPrinter/ARMException.cpp?rev=291172&
> r1=291171&r2=291172&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/ARMException.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/ARMException.cpp Thu Jan  5
> 14:55:28 2017
> @@ -53,7 +53,8 @@ void ARMException::beginFunction(const M
>
>    if (MoveType == AsmPrinter::CFI_M_Debug) {
>      if (!hasEmittedCFISections) {
> -      Asm->OutStreamer->EmitCFISections(false, true);
> +      if (Asm->needsOnlyDebugCFIMoves())
> +        Asm->OutStreamer->EmitCFISections(false, true);
>        hasEmittedCFISections = true;
>      }
>
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> CodeGen/AsmPrinter/AsmPrinter.cpp?rev=291172&r1=291171&r2=291172&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Thu Jan  5 14:55:28
> 2017
> @@ -108,7 +108,7 @@ static unsigned getGVAlignmentLog2(const
>  AsmPrinter::AsmPrinter(TargetMachine &tm, std::unique_ptr<MCStreamer>
> Streamer)
>      : MachineFunctionPass(ID), TM(tm), MAI(tm.getMCAsmInfo()),
>        OutContext(Streamer->getContext()), OutStreamer(std::move(
> Streamer)),
> -      LastMI(nullptr), LastFn(0), Counter(~0U) {
> +      isCFIMoveForDebugging(false), LastMI(nullptr), LastFn(0),
> Counter(~0U) {
>    DD = nullptr;
>    MMI = nullptr;
>    LI = nullptr;
> @@ -264,6 +264,28 @@ bool AsmPrinter::doInitialization(Module
>      }
>    }
>
> +  switch (MAI->getExceptionHandlingType()) {
> +  case ExceptionHandling::SjLj:
> +  case ExceptionHandling::DwarfCFI:
> +  case ExceptionHandling::ARM:
> +    isCFIMoveForDebugging = true;
> +    if (MAI->getExceptionHandlingType() != ExceptionHandling::DwarfCFI)
> +      break;
> +    for (auto &F: M.getFunctionList()) {
> +      // If the module contains any function with unwind data,
> +      // .eh_frame has to be emitted.
> +      // Ignore functions that won't get emitted.
> +      if (!F.isDeclarationForLinker() && F.needsUnwindTableEntry()) {
> +        isCFIMoveForDebugging = false;
> +        break;
> +      }
> +    }
> +    break;
> +  default:
> +    isCFIMoveForDebugging = false;
> +    break;
> +  }
> +
>    EHStreamer *ES = nullptr;
>    switch (MAI->getExceptionHandlingType()) {
>    case ExceptionHandling::None:
>
> Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> CodeGen/AsmPrinter/DwarfCFIException.cpp?rev=291172&r1=291171&r2=291172&
> view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp (original)
> +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp Thu Jan  5
> 14:55:28 2017
> @@ -137,7 +137,7 @@ void DwarfCFIException::beginFragment(co
>      return;
>
>    if (!hasEmittedCFISections) {
> -    if (Asm->needsCFIMoves() == AsmPrinter::CFI_M_Debug)
> +    if (Asm->needsOnlyDebugCFIMoves())
>        Asm->OutStreamer->EmitCFISections(false, true);
>      hasEmittedCFISections = true;
>    }
>
> Added: llvm/trunk/test/CodeGen/Generic/cfi-sections.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/
> CodeGen/Generic/cfi-sections.ll?rev=291172&view=auto
> ============================================================
> ==================
> --- llvm/trunk/test/CodeGen/Generic/cfi-sections.ll (added)
> +++ llvm/trunk/test/CodeGen/Generic/cfi-sections.ll Thu Jan  5 14:55:28
> 2017
> @@ -0,0 +1,39 @@
> +; When using Itanium ABI, do not emit .debug_frame.
> +; RUNT: llc -mtriple=i386--linux -o - < %s | FileCheck %s
> -check-prefix=WITHOUT
> +; RUNT: llc -mtriple=armv7-netbsd-eabi -o - < %s | FileCheck %s
> -check-prefix=WITHOUT
> +
> +; When using EHABI, do emit .debug_frame.
> +; RUN: llc -mtriple=arm-linux -mcpu=cortex-a7 -mattr=v7 -o - < %s |
> FileCheck %s -check-prefix=WITH
> +
> +; REQUIRES: x86-registered-target
> +; REQUIRES: arm-registered-target
> +
> +; WITH:        .cfi_sections .debug_frame
> +; WITHOUT-NOT: .cfi_sections
> +
> +define i32 @foo() #0 !dbg !7 {
> +  %1 = call i32 @bar()
> +  %2 = call i32 @bar()
> +  %3 = add nsw i32 %1, %2
> +  ret i32 %3
> +}
> +
> +declare i32 @bar() #1
> +
> +attributes #0 = { "disable-tail-calls"="false"
> "less-precise-fpmad"="false" "no-frame-pointer-elim"="true"
> "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false"
> "no-jump-tables"="false" "no-nans-fp-math"="false"
> "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8"
> "target-cpu"="arm7tdmi" "target-features"="+soft-
> float,+strict-align,-crypto,-neon" "unsafe-fp-math"="false"
> "use-soft-float"="true" }
> +attributes #1 = { "disable-tail-calls"="false"
> "less-precise-fpmad"="false" "no-frame-pointer-elim"="true"
> "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false"
> "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false"
> "stack-protector-buffer-size"="8" "target-cpu"="arm7tdmi"
> "target-features"="+soft-float,+strict-align,-crypto,-neon"
> "unsafe-fp-math"="false" "use-soft-float"="true" }
> +
> +!llvm.dbg.cu = !{!0}
> +!llvm.module.flags = !{!3, !4, !5, !6}
> +
> +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1,
> producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind:
> FullDebug, enums: !2)
> +!1 = !DIFile(filename: "cfi-sections.cc", directory: ".")
> +!2 = !{}
> +!3 = !{i32 2, !"Dwarf Version", i32 4}
> +!4 = !{i32 2, !"Debug Info Version", i32 3}
> +!5 = !{i32 1, !"wchar_size", i32 4}
> +!6 = !{i32 1, !"min_enum_size", i32 4}
> +!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2,
> type: !8, isLocal: false, isDefinition: true, scopeLine: 2, flags:
> DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
> +!8 = !DISubroutineType(types: !9)
> +!9 = !{!10}
> +!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding:
> DW_ATE_signed)
>
>
> _______________________________________________
> 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/20170106/a7467add/attachment.html>


More information about the llvm-commits mailing list