[llvm] r253502 - ARM: make sure backend is consistent about exception handling method.

Tim Northover via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 18 13:10:40 PST 2015


Author: tnorthover
Date: Wed Nov 18 15:10:39 2015
New Revision: 253502

URL: http://llvm.org/viewvc/llvm-project?rev=253502&view=rev
Log:
ARM: make sure backend is consistent about exception handling method.

It turns out we decide whether to use SjLj exceptions or some alternative in
two separate places in the backend, and they disagreed with each other. This
led to inconsistent code and is generally a terrible idea.

So make them consistent and add an assert that they *do* match (unfortunately
MCAsmInfo isn't available in opt, so it can't be used to initialise the CodeGen
version directly).

Modified:
    llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp
    llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCAsmInfo.cpp
    llvm/trunk/test/CodeGen/ARM/eh-resume-darwin.ll
    llvm/trunk/test/CodeGen/ARM/sjljehprepare-lower-empty-struct.ll
    llvm/trunk/test/CodeGen/Thumb/thumb-shrink-wrapping.ll

Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=253502&r1=253501&r2=253502&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Wed Nov 18 15:10:39 2015
@@ -26,6 +26,7 @@
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GlobalValue.h"
+#include "llvm/MC/MCAsmInfo.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Target/TargetInstrInfo.h"
 #include "llvm/Target/TargetOptions.h"
@@ -151,8 +152,15 @@ void ARMSubtarget::initializeEnvironment
   UseNaClTrap = false;
   GenLongCalls = false;
   UnsafeFPMath = false;
-  UseSjLjEH = (isTargetDarwin() &&
-               TargetTriple.getSubArch() != Triple::ARMSubArch_v7k);
+
+  // MCAsmInfo isn't always present (e.g. in opt) so we can't initialize this
+  // directly from it, but we can try to make sure they're consistent when both
+  // available.
+  UseSjLjEH = isTargetDarwin() && !isTargetWatchOS();
+  assert((!TM.getMCAsmInfo() ||
+          (TM.getMCAsmInfo()->getExceptionHandlingType() ==
+           ExceptionHandling::SjLj) == UseSjLjEH) &&
+         "inconsistent sjlj choice between CodeGen and MC");
 }
 
 void ARMSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {

Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCAsmInfo.cpp?rev=253502&r1=253501&r2=253502&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCAsmInfo.cpp Wed Nov 18 15:10:39 2015
@@ -33,8 +33,9 @@ ARMMCAsmInfoDarwin::ARMMCAsmInfoDarwin(c
   SupportsDebugInformation = true;
 
   // Exceptions handling
-  ExceptionsType = TheTriple.isWatchOS() ? ExceptionHandling::DwarfCFI
-                                         : ExceptionHandling::SjLj;
+  ExceptionsType = TheTriple.isOSDarwin() && !TheTriple.isWatchOS()
+                       ? ExceptionHandling::SjLj
+                       : ExceptionHandling::DwarfCFI;
 
   UseIntegratedAssembler = true;
 }

Modified: llvm/trunk/test/CodeGen/ARM/eh-resume-darwin.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/eh-resume-darwin.ll?rev=253502&r1=253501&r2=253502&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/eh-resume-darwin.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/eh-resume-darwin.ll Wed Nov 18 15:10:39 2015
@@ -1,4 +1,5 @@
 ; RUN: llc < %s -mtriple=armv7-apple-ios -arm-atomic-cfg-tidy=0 | FileCheck %s -check-prefix=IOS
+; RUN: llc < %s -mtriple=armv7k-apple-ios -arm-atomic-cfg-tidy=0 | FileCheck %s -check-prefix=IOS
 ; RUN: llc < %s -mtriple=armv7k-apple-watchos -arm-atomic-cfg-tidy=0 | FileCheck %s -check-prefix=WATCHOS
 
 declare void @func()

Modified: llvm/trunk/test/CodeGen/ARM/sjljehprepare-lower-empty-struct.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/sjljehprepare-lower-empty-struct.ll?rev=253502&r1=253501&r2=253502&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/sjljehprepare-lower-empty-struct.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/sjljehprepare-lower-empty-struct.ll Wed Nov 18 15:10:39 2015
@@ -2,6 +2,7 @@
 ; RUN: llc -mtriple=armv7-apple-ios -O1 < %s | FileCheck %s
 ; RUN: llc -mtriple=armv7-apple-ios -O2 < %s | FileCheck %s
 ; RUN: llc -mtriple=armv7-apple-ios -O3 < %s | FileCheck %s
+; RUN: llc -mtriple=armv7k-apple-ios < %s | FileCheck %s
 
 ; SjLjEHPrepare shouldn't crash when lowering empty structs.
 ;

Modified: llvm/trunk/test/CodeGen/Thumb/thumb-shrink-wrapping.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/thumb-shrink-wrapping.ll?rev=253502&r1=253501&r2=253502&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/Thumb/thumb-shrink-wrapping.ll (original)
+++ llvm/trunk/test/CodeGen/Thumb/thumb-shrink-wrapping.ll Wed Nov 18 15:10:39 2015
@@ -22,7 +22,7 @@
 ;
 ; Prologue code.
 ; CHECK: push {r7, lr}
-; CHECK-NEXT: sub sp, #8
+; CHECK: sub sp, #8
 ;
 ; Compare the arguments and jump to exit.
 ; After the prologue is set.
@@ -418,7 +418,7 @@ if.end:
 ;
 ; Prologue code.
 ; CHECK: push {[[TMP:r[0-9]+]], lr}
-; CHECK-NEXT: sub sp, #16
+; CHECK: sub sp, #16
 ;
 ; DISABLE: cmp r0, #0
 ; DISABLE-NEXT: beq [[ELSE_LABEL:LBB[0-9_]+]]




More information about the llvm-commits mailing list