<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 5, 2017 at 12:55 PM, Joerg Sonnenberger via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: joerg<br>
Date: Thu Jan  5 14:55:28 2017<br>
New Revision: 291172<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=291172&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=291172&view=rev</a><br>
Log:<br>
PR 31534: When emitting both DWARF unwind tables and debug information,<br>
do not use .cfi_sections. This requires checking if any non-declaration<br>
function in the module needs an unwind table.<br>
<br>
Added:<br>
    llvm/trunk/test/CodeGen/<wbr>Generic/cfi-sections.ll<br>
Modified:<br>
    llvm/trunk/include/llvm/<wbr>CodeGen/AsmPrinter.h<br>
    llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/ARMException.cpp<br>
    llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/AsmPrinter.cpp<br>
    llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/DwarfCFIException.<wbr>cpp<br>
<br>
Modified: llvm/trunk/include/llvm/<wbr>CodeGen/AsmPrinter.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=291172&r1=291171&r2=291172&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/CodeGen/AsmPrinter.h?rev=<wbr>291172&r1=291171&r2=291172&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/<wbr>CodeGen/AsmPrinter.h (original)<br>
+++ llvm/trunk/include/llvm/<wbr>CodeGen/AsmPrinter.h Thu Jan  5 14:55:28 2017<br>
@@ -140,6 +140,9 @@ private:<br>
   /// If the target supports dwarf debug info, this pointer is non-null.<br>
   DwarfDebug *DD;<br>
<br>
+  /// If the current module uses dwarf CFI annotations strictly for debugging.<br>
+  bool isCFIMoveForDebugging;<br>
+<br></blockquote><div><br></div><div>capitalize.</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 protected:<br>
   explicit AsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer);<br>
<br>
@@ -262,6 +265,10 @@ public:<br>
   enum CFIMoveType { CFI_M_None, CFI_M_EH, CFI_M_Debug };<br>
   CFIMoveType needsCFIMoves();<br>
<br>
+  /// Returns false if needsCFIMoves() == CFI_M_EH for any function<br>
+  /// in the module.<br>
+  bool needsOnlyDebugCFIMoves() const { return isCFIMoveForDebugging; }<br>
+<br>
   bool needsSEHMoves();<br>
<br>
   /// Print to the current output stream assembly representations of the<br>
<br>
Modified: llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/ARMException.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/ARMException.cpp?rev=291172&r1=291171&r2=291172&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>CodeGen/AsmPrinter/<wbr>ARMException.cpp?rev=291172&<wbr>r1=291171&r2=291172&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/ARMException.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/ARMException.cpp Thu Jan  5 14:55:28 2017<br>
@@ -53,7 +53,8 @@ void ARMException::beginFunction(<wbr>const M<br>
<br>
   if (MoveType == AsmPrinter::CFI_M_Debug) {<br>
     if (!hasEmittedCFISections) {<br>
-      Asm->OutStreamer-><wbr>EmitCFISections(false, true);<br>
+      if (Asm->needsOnlyDebugCFIMoves()<wbr>)<br>
+        Asm->OutStreamer-><wbr>EmitCFISections(false, true);<br>
       hasEmittedCFISections = true;<br>
     }<br>
<br>
<br>
Modified: llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/AsmPrinter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=291172&r1=291171&r2=291172&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>CodeGen/AsmPrinter/AsmPrinter.<wbr>cpp?rev=291172&r1=291171&r2=<wbr>291172&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/AsmPrinter.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/AsmPrinter.cpp Thu Jan  5 14:55:28 2017<br>
@@ -108,7 +108,7 @@ static unsigned getGVAlignmentLog2(const<br>
 AsmPrinter::AsmPrinter(<wbr>TargetMachine &tm, std::unique_ptr<MCStreamer> Streamer)<br>
     : MachineFunctionPass(ID), TM(tm), MAI(tm.getMCAsmInfo()),<br>
       OutContext(Streamer-><wbr>getContext()), OutStreamer(std::move(<wbr>Streamer)),<br>
-      LastMI(nullptr), LastFn(0), Counter(~0U) {<br>
+      isCFIMoveForDebugging(false), LastMI(nullptr), LastFn(0), Counter(~0U) {<br>
   DD = nullptr;<br>
   MMI = nullptr;<br>
   LI = nullptr;<br>
@@ -264,6 +264,28 @@ bool AsmPrinter::doInitialization(<wbr>Module<br>
     }<br>
   }<br>
<br>
+  switch (MAI-><wbr>getExceptionHandlingType()) {<br>
+  case ExceptionHandling::SjLj:<br>
+  case ExceptionHandling::DwarfCFI:<br>
+  case ExceptionHandling::ARM:<br>
+    isCFIMoveForDebugging = true;<br>
+    if (MAI-><wbr>getExceptionHandlingType() != ExceptionHandling::DwarfCFI)<br>
+      break;<br>
+    for (auto &F: M.getFunctionList()) {<br>
+      // If the module contains any function with unwind data,<br>
+      // .eh_frame has to be emitted.<br>
+      // Ignore functions that won't get emitted.<br>
+      if (!F.isDeclarationForLinker() && F.needsUnwindTableEntry()) {<br>
+        isCFIMoveForDebugging = false;<br>
+        break;<br>
+      }<br>
+    }<br>
+    break;<br>
+  default:<br>
+    isCFIMoveForDebugging = false;<br>
+    break;<br>
+  }<br>
+<br>
   EHStreamer *ES = nullptr;<br>
   switch (MAI-><wbr>getExceptionHandlingType()) {<br>
   case ExceptionHandling::None:<br>
<br>
Modified: llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/DwarfCFIException.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCFIException.cpp?rev=291172&r1=291171&r2=291172&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>CodeGen/AsmPrinter/<wbr>DwarfCFIException.cpp?rev=<wbr>291172&r1=291171&r2=291172&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/DwarfCFIException.<wbr>cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/<wbr>AsmPrinter/DwarfCFIException.<wbr>cpp Thu Jan  5 14:55:28 2017<br>
@@ -137,7 +137,7 @@ void DwarfCFIException::<wbr>beginFragment(co<br>
     return;<br>
<br>
   if (!hasEmittedCFISections) {<br>
-    if (Asm->needsCFIMoves() == AsmPrinter::CFI_M_Debug)<br>
+    if (Asm->needsOnlyDebugCFIMoves()<wbr>)<br>
       Asm->OutStreamer-><wbr>EmitCFISections(false, true);<br>
     hasEmittedCFISections = true;<br>
   }<br>
<br>
Added: llvm/trunk/test/CodeGen/<wbr>Generic/cfi-sections.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Generic/cfi-sections.ll?rev=291172&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/test/<wbr>CodeGen/Generic/cfi-sections.<wbr>ll?rev=291172&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/test/CodeGen/<wbr>Generic/cfi-sections.ll (added)<br>
+++ llvm/trunk/test/CodeGen/<wbr>Generic/cfi-sections.ll Thu Jan  5 14:55:28 2017<br>
@@ -0,0 +1,39 @@<br>
+; When using Itanium ABI, do not emit .debug_frame.<br>
+; RUNT: llc -mtriple=i386--linux -o - < %s | FileCheck %s -check-prefix=WITHOUT<br>
+; RUNT: llc -mtriple=armv7-netbsd-eabi -o - < %s | FileCheck %s -check-prefix=WITHOUT<br>
+<br>
+; When using EHABI, do emit .debug_frame.<br>
+; RUN: llc -mtriple=arm-linux -mcpu=cortex-a7 -mattr=v7 -o - < %s | FileCheck %s -check-prefix=WITH<br>
+<br>
+; REQUIRES: x86-registered-target<br>
+; REQUIRES: arm-registered-target<br>
+<br>
+; WITH:        .cfi_sections .debug_frame<br>
+; WITHOUT-NOT: .cfi_sections<br>
+<br>
+define i32 @foo() #0 !dbg !7 {<br>
+  %1 = call i32 @bar()<br>
+  %2 = call i32 @bar()<br>
+  %3 = add nsw i32 %1, %2<br>
+  ret i32 %3<br>
+}<br>
+<br>
+declare i32 @bar() #1<br>
+<br>
+attributes #0 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-<wbr>leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="<wbr>false" "stack-protector-buffer-size"=<wbr>"8" "target-cpu"="arm7tdmi" "target-features"="+soft-<wbr>float,+strict-align,-crypto,-<wbr>neon" "unsafe-fp-math"="false" "use-soft-float"="true" }<br>
+attributes #1 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-<wbr>leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="<wbr>false" "stack-protector-buffer-size"=<wbr>"8" "target-cpu"="arm7tdmi" "target-features"="+soft-<wbr>float,+strict-align,-crypto,-<wbr>neon" "unsafe-fp-math"="false" "use-soft-float"="true" }<br>
+<br>
+!<a href="http://llvm.dbg.cu" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!0}<br>
+!llvm.module.flags = !{!3, !4, !5, !6}<br>
+<br>
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)<br>
+!1 = !DIFile(filename: "cfi-sections.cc", directory: ".")<br>
+!2 = !{}<br>
+!3 = !{i32 2, !"Dwarf Version", i32 4}<br>
+!4 = !{i32 2, !"Debug Info Version", i32 3}<br>
+!5 = !{i32 1, !"wchar_size", i32 4}<br>
+!6 = !{i32 1, !"min_enum_size", i32 4}<br>
+!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)<br>
+!8 = !DISubroutineType(types: !9)<br>
+!9 = !{!10}<br>
+!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>