[llvm] 98dc3e8 - [ARM] [MinGW] Default to WinEH exception handling instead of Dwarf

Martin Storsjö via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 6 13:28:11 PDT 2022


Author: Martin Storsjö
Date: 2022-06-06T23:27:19+03:00
New Revision: 98dc3e86fd0f22093f1431457c058c70af1db35d

URL: https://github.com/llvm/llvm-project/commit/98dc3e86fd0f22093f1431457c058c70af1db35d
DIFF: https://github.com/llvm/llvm-project/commit/98dc3e86fd0f22093f1431457c058c70af1db35d.diff

LOG: [ARM] [MinGW] Default to WinEH exception handling instead of Dwarf

Switching this target to WinEH also seems to affect the `-windows-itanium`
target.

Differential Revision: https://reviews.llvm.org/D126870

Added: 
    

Modified: 
    llvm/lib/MC/MCObjectFileInfo.cpp
    llvm/lib/Target/ARM/MCTargetDesc/ARMMCAsmInfo.cpp
    llvm/test/CodeGen/ARM/Windows/dbzchk.ll
    llvm/test/CodeGen/ARM/Windows/mingw-refptr.ll
    llvm/test/CodeGen/ARM/Windows/powi.ll
    llvm/test/CodeGen/ARM/ehabi.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index d56f72cfc388f..0d08976d98942 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -564,8 +564,9 @@ void MCObjectFileInfo::initCOFFMCObjectFileInfo(const Triple &T) {
       ".rdata", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ,
       SectionKind::getReadOnly());
 
-  if (T.getArch() == Triple::x86_64 || T.getArch() == Triple::aarch64) {
-    // On Windows 64 with SEH, the LSDA is emitted into the .xdata section
+  if (T.getArch() == Triple::x86_64 || T.getArch() == Triple::aarch64 ||
+      T.getArch() == Triple::arm || T.getArch() == Triple::thumb) {
+    // On Windows with SEH, the LSDA is emitted into the .xdata section
     LSDASection = nullptr;
   } else {
     LSDASection = Ctx->getCOFFSection(".gcc_except_table",

diff  --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCAsmInfo.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCAsmInfo.cpp
index a7d50cb303557..febd8ab8bbc0b 100644
--- a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCAsmInfo.cpp
+++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCAsmInfo.cpp
@@ -111,7 +111,8 @@ ARMCOFFMCAsmInfoGNU::ARMCOFFMCAsmInfoGNU() {
   PrivateLabelPrefix = ".L";
 
   SupportsDebugInformation = true;
-  ExceptionsType = ExceptionHandling::DwarfCFI;
+  ExceptionsType = ExceptionHandling::WinEH;
+  WinEHEncodingType = WinEH::EncodingType::Itanium;
   UseParensForSymbolVariant = true;
 
   DwarfRegNumForCFI = false;

diff  --git a/llvm/test/CodeGen/ARM/Windows/dbzchk.ll b/llvm/test/CodeGen/ARM/Windows/dbzchk.ll
index 365951080d418..74267e826de90 100644
--- a/llvm/test/CodeGen/ARM/Windows/dbzchk.ll
+++ b/llvm/test/CodeGen/ARM/Windows/dbzchk.ll
@@ -131,9 +131,9 @@ attributes #0 = { optsize }
 ; CHECK-CFG-DAG: t__brkdiv0
 
 ; CHECK-CFG-ASM-LABEL: h:
-; CHECK-CFG-ASM: cbz r{{[0-9]}}, .LBB2_4
+; CHECK-CFG-ASM: cbz r{{[0-9]}}, .LBB2_5
 ; CHECK-CFG-ASM: bl __rt_udiv
-; CHECK-CFG-ASM-LABEL: .LBB2_4:
+; CHECK-CFG-ASM-LABEL: .LBB2_5:
 ; CHECK-CFG-ASM: __brkdiv0
 
 ; RUN: llc -O1 -mtriple thumbv7--windows-itanium -verify-machineinstrs -filetype asm -o - %s | FileCheck %s -check-prefix CHECK-WIN__DBZCHK

diff  --git a/llvm/test/CodeGen/ARM/Windows/mingw-refptr.ll b/llvm/test/CodeGen/ARM/Windows/mingw-refptr.ll
index 06b3536b7db96..adc2ed6275b63 100644
--- a/llvm/test/CodeGen/ARM/Windows/mingw-refptr.ll
+++ b/llvm/test/CodeGen/ARM/Windows/mingw-refptr.ll
@@ -65,7 +65,7 @@ entry:
 
 define dso_local void @callFunc() {
 ; CHECK-LABEL: callFunc:
-; CHECK:    b otherFunc
+; CHECK:    b.w otherFunc
 entry:
   tail call void @otherFunc()
   ret void

diff  --git a/llvm/test/CodeGen/ARM/Windows/powi.ll b/llvm/test/CodeGen/ARM/Windows/powi.ll
index 7db6327cf53e2..89955467cece3 100644
--- a/llvm/test/CodeGen/ARM/Windows/powi.ll
+++ b/llvm/test/CodeGen/ARM/Windows/powi.ll
@@ -12,7 +12,7 @@ entry:
 ; CHECK-LABEL: d:
 ; CHECK: vmov s[[REGISTER:[0-9]+]], r0
 ; CHECK-NEXT: vcvt.f64.s32 d1, s[[REGISTER]]
-; CHECK-NEXT: b pow
+; CHECK-NEXT: b.w pow
 ; CHECK-NOT: __powisf2
 
 define arm_aapcs_vfpcc float @f(float %f, i32 %i) {
@@ -24,7 +24,7 @@ entry:
 ; CHECK-LABEL: f:
 ; CHECK: vmov s[[REGISTER:[0-9]+]], r0
 ; CHECK-NEXT: vcvt.f32.s32 s1, s[[REGISTER]]
-; CHECK-NEXT: b pow
+; CHECK-NEXT: b.w pow
 ; CHECK-NOT: __powisf2
 
 define arm_aapcs_vfpcc float @g(double %d, i32 %i) {

diff  --git a/llvm/test/CodeGen/ARM/ehabi.ll b/llvm/test/CodeGen/ARM/ehabi.ll
index c8c0b5b61980a..0b70f243d08d4 100644
--- a/llvm/test/CodeGen/ARM/ehabi.ll
+++ b/llvm/test/CodeGen/ARM/ehabi.ll
@@ -83,9 +83,13 @@
 ; RUN:   | FileCheck %s --check-prefix=DWARF-V7-FP-ELIM
 
 ; RUN: llc -mtriple thumbv7-windows-gnu \
-; RUN:     -filetype=asm -o - %s \
+; RUN:     -filetype=asm -exception-model=dwarf -o - %s \
 ; RUN:   | FileCheck %s --check-prefix=DWARF-WIN-FP-ELIM
 
+; RUN: llc -mtriple thumbv7-windows-gnu \
+; RUN:     -filetype=asm -o - %s \
+; RUN:   | FileCheck %s --check-prefix=SEH-WIN-FP-ELIM
+
 ;-------------------------------------------------------------------------------
 ; Test 1
 ;-------------------------------------------------------------------------------
@@ -311,6 +315,26 @@ declare void @_ZSt9terminatev()
 ; DWARF-WIN-FP-ELIM:    pop {r4, pc}
 ; DWARF-WIN-FP-ELIM:    .cfi_endproc
 
+; SEH-WIN-FP-ELIM-LABEL: _Z4testiiiiiddddd:
+; SEH-WIN-FP-ELIM:    .seh_proc _Z4testiiiiiddddd
+; SEH-WIN-FP-ELIM:    .seh_handler __gxx_personality_v0, %unwind, %except
+; SEH-WIN-FP-ELIM:    push {r4, lr}
+; SEH-WIN-FP-ELIM:    .seh_save_regs {r4, lr}
+; SEH-WIN-FP-ELIM:    vpush {d8, d9, d10, d11, d12}
+; SEH-WIN-FP-ELIM:    .seh_save_fregs {d8-d12}
+; SEH-WIN-FP-ELIM:    sub sp, #8
+; SEH-WIN-FP-ELIM:    .seh_stackalloc 8
+; SEH-WIN-FP-ELIM:    .seh_endprologue
+; SEH-WIN-FP-ELIM:    .seh_startepilogue
+; SEH-WIN-FP-ELIM:    add sp, #8
+; SEH-WIN-FP-ELIM:    .seh_stackalloc 8
+; SEH-WIN-FP-ELIM:    vpop {d8, d9, d10, d11, d12}
+; SEH-WIN-FP-ELIM:    .seh_save_fregs {d8-d12}
+; SEH-WIN-FP-ELIM:    pop {r4, pc}
+; SEH-WIN-FP-ELIM:    .seh_save_regs {r4, lr}
+; SEH-WIN-FP-ELIM:    .seh_endepilogue
+; SEH-WIN-FP-ELIM:    .seh_endproc
+
 ;-------------------------------------------------------------------------------
 ; Test 2
 ;-------------------------------------------------------------------------------
@@ -408,6 +432,16 @@ entry:
 ; DWARF-WIN-FP-ELIM:    pop.w  {r11, pc}
 ; DWARF-WIN-FP-ELIM:    .cfi_endproc
 
+; SEH-WIN-FP-ELIM-LABEL: test2:
+; SEH-WIN-FP-ELIM:    .seh_proc test2
+; SEH-WIN-FP-ELIM:    push.w {r11, lr}
+; SEH-WIN-FP-ELIM:    .seh_save_regs_w {r11, lr}
+; SEH-WIN-FP-ELIM:    .seh_endprologue
+; SEH-WIN-FP-ELIM:    .seh_startepilogue
+; SEH-WIN-FP-ELIM:    pop.w  {r11, pc}
+; SEH-WIN-FP-ELIM:    .seh_endepilogue
+; SEH-WIN-FP-ELIM:    .seh_endproc
+
 
 ;-------------------------------------------------------------------------------
 ; Test 3
@@ -525,6 +559,17 @@ entry:
 ; DWARF-WIN-FP-ELIM:    pop.w  {r4, r5, r11, pc}
 ; DWARF-WIN-FP-ELIM:    .cfi_endproc
 
+; SEH-WIN-FP-ELIM-LABEL: test3:
+; SEH-WIN-FP-ELIM:    .seh_proc test3
+; SEH-WIN-FP-ELIM:    push.w {r4, r5, r11, lr}
+; SEH-WIN-FP-ELIM:    .seh_save_regs_w {r4-r5, r11, lr}
+; SEH-WIN-FP-ELIM:    .seh_endprologue
+; SEH-WIN-FP-ELIM:    .seh_startepilogue
+; SEH-WIN-FP-ELIM:    pop.w  {r4, r5, r11, pc}
+; SEH-WIN-FP-ELIM:    .seh_save_regs_w {r4-r5, r11, lr}
+; SEH-WIN-FP-ELIM:    .seh_endepilogue
+; SEH-WIN-FP-ELIM:    .seh_endproc
+
 
 ;-------------------------------------------------------------------------------
 ; Test 4
@@ -587,3 +632,8 @@ entry:
 ; DWARF-WIN-FP-ELIM-NOT: .cfi_startproc
 ; DWARF-WIN-FP-ELIM:     bx lr
 ; DWARF-WIN-FP-ELIM-NOT: .cfi_endproc
+
+; SEH-WIN-FP-ELIM-LABEL: test4:
+; SEH-WIN-FP-ELIM-NOT: .seh_proc test4
+; SEH-WIN-FP-ELIM:     bx lr
+; SEH-WIN-FP-ELIM-NOT: .seh_endproc


        


More information about the llvm-commits mailing list