Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 3fca788

Browse files
committed
Enable EHABI by default
After all hard work to implement the EHABI and with the test-suite passing, it's time to turn it on by default and allow users to disable it as a work-around while we fix the eventual bugs that show up. This commit also remove the -arm-enable-ehabi-descriptors, since we want the tables to be printed every time the EHABI is turned on for non-Darwin ARM targets. Although MCJIT EHABI is not working yet (needs linking with the right libraries), this commit also fixes some relocations on MCJIT regarding the EH tables/lib calls, and update some tests to avoid using EH tables when none are needed. The EH tests in the test-suite that were previously disabled on ARM now pass with these changes, so a follow-up commit on the test-suite will re-enable them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200388 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent b04ddad commit 3fca788

23 files changed

+63
-58
lines changed

lib/CodeGen/AsmPrinter/ARMException.cpp

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@
3636
#include "llvm/Target/TargetRegisterInfo.h"
3737
using namespace llvm;
3838

39-
static cl::opt<bool>
40-
EnableARMEHABIDescriptors("arm-enable-ehabi-descriptors", cl::Hidden,
41-
cl::desc("Generate ARM EHABI tables with unwinding descriptors"),
42-
cl::init(false));
43-
44-
4539
ARMException::ARMException(AsmPrinter *A)
4640
: DwarfException(A) {}
4741

@@ -74,25 +68,23 @@ void ARMException::endFunction(const MachineFunction *) {
7468
Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_end",
7569
Asm->getFunctionNumber()));
7670

77-
if (EnableARMEHABIDescriptors) {
78-
// Map all labels and get rid of any dead landing pads.
79-
MMI->TidyLandingPads();
71+
// Map all labels and get rid of any dead landing pads.
72+
MMI->TidyLandingPads();
8073

81-
if (!MMI->getLandingPads().empty()) {
82-
// Emit references to personality.
83-
if (const Function * Personality =
84-
MMI->getPersonalities()[MMI->getPersonalityIndex()]) {
85-
MCSymbol *PerSym = Asm->getSymbol(Personality);
86-
Asm->OutStreamer.EmitSymbolAttribute(PerSym, MCSA_Global);
87-
ATS.emitPersonality(PerSym);
88-
}
74+
if (!MMI->getLandingPads().empty()) {
75+
// Emit references to personality.
76+
if (const Function * Personality =
77+
MMI->getPersonalities()[MMI->getPersonalityIndex()]) {
78+
MCSymbol *PerSym = Asm->getSymbol(Personality);
79+
Asm->OutStreamer.EmitSymbolAttribute(PerSym, MCSA_Global);
80+
ATS.emitPersonality(PerSym);
81+
}
8982

90-
// Emit .handlerdata directive.
91-
ATS.emitHandlerData();
83+
// Emit .handlerdata directive.
84+
ATS.emitHandlerData();
9285

93-
// Emit actual exception table
94-
EmitExceptionTable();
95-
}
86+
// Emit actual exception table
87+
EmitExceptionTable();
9688
}
9789
}
9890

lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,11 @@ void RuntimeDyldELF::resolveARMRelocation(const SectionEntry &Section,
481481
default:
482482
llvm_unreachable("Not implemented relocation type!");
483483

484+
case ELF::R_ARM_NONE:
485+
break;
484486
// Write a 32bit value to relocation address, taking into account the
485487
// implicit addend encoded in the target.
488+
case ELF::R_ARM_PREL31:
486489
case ELF::R_ARM_TARGET1:
487490
case ELF::R_ARM_ABS32:
488491
*TargetPtr = *Placeholder + Value;

lib/Target/ARM/ARMAsmPrinter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ void ARMAsmPrinter::EmitUnwindingInstruction(const MachineInstr *MI) {
11061106
}
11071107
}
11081108

1109-
extern cl::opt<bool> EnableARMEHABI;
1109+
extern cl::opt<bool> DisableARMEHABI;
11101110

11111111
// Simple pseudo-instructions have their lowering (with expansion to real
11121112
// instructions) auto-generated.
@@ -1122,7 +1122,8 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
11221122
}
11231123

11241124
// Emit unwinding stuff for frame-related instructions
1125-
if (EnableARMEHABI && MI->getFlag(MachineInstr::FrameSetup))
1125+
if (Subtarget->isTargetEHABICompatible() && !DisableARMEHABI &&
1126+
MI->getFlag(MachineInstr::FrameSetup))
11261127
EmitUnwindingInstruction(MI);
11271128

11281129
// Do any auto-generated pseudo lowerings.

lib/Target/ARM/ARMSubtarget.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,16 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
328328
!isTargetDarwin();
329329
}
330330

331+
// ARM Targets that support EHABI exception handling standard
332+
// Darwin uses SjLj. Other targets might need more checks.
333+
bool isTargetEHABICompatible() const {
334+
return (TargetTriple.getEnvironment() == Triple::EABI ||
335+
TargetTriple.getEnvironment() == Triple::GNUEABI ||
336+
TargetTriple.getEnvironment() == Triple::EABIHF ||
337+
TargetTriple.getEnvironment() == Triple::GNUEABIHF) &&
338+
!isTargetDarwin();
339+
}
340+
331341
bool isTargetHardFloat() const {
332342
return TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
333343
TargetTriple.getEnvironment() == Triple::EABIHF;

lib/Target/ARM/MCTargetDesc/ARMMCAsmInfo.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616

1717
using namespace llvm;
1818

19+
// ARM EHABI is experimental but the quality is good enough
20+
// to be turned on by default on non-Darwin ARM targets.
1921
cl::opt<bool>
20-
EnableARMEHABI("arm-enable-ehabi", cl::Hidden,
21-
cl::desc("Generate ARM EHABI tables"),
22+
DisableARMEHABI("arm-disable-ehabi", cl::Hidden,
23+
cl::desc("Disable ARM experimental exception handling"),
2224
cl::init(false));
2325

2426

@@ -52,7 +54,7 @@ ARMELFMCAsmInfo::ARMELFMCAsmInfo() {
5254
SupportsDebugInformation = true;
5355

5456
// Exceptions handling
55-
if (EnableARMEHABI)
57+
if (!DisableARMEHABI)
5658
ExceptionsType = ExceptionHandling::ARM;
5759

5860
// foo(plt) instead of foo@plt

test/CodeGen/ARM/arm-ttype-target2.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llc -mtriple=armv7-none-linux-gnueabi -arm-enable-ehabi -arm-enable-ehabi-descriptors < %s | FileCheck %s
1+
; RUN: llc -mtriple=armv7-none-linux-gnueabi < %s | FileCheck %s
22

33
@_ZTVN10__cxxabiv117__class_type_infoE = external global i8*
44
@_ZTS3Foo = linkonce_odr constant [5 x i8] c"3Foo\00"

test/CodeGen/ARM/ehabi-filters.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
; RUN: llc -arm-enable-ehabi -arm-enable-ehabi-descriptors < %s | FileCheck %s
1+
; RUN: llc < %s | FileCheck %s
22
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32-S64"
33
target triple = "armv7-none-linux-gnueabi"
44

test/CodeGen/ARM/ehabi-no-landingpad.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
; RUN: llc < %s -mtriple=armv7-unknown-linux-gnueabi \
2-
; RUN: -arm-enable-ehabi -arm-enable-ehabi-descriptors | FileCheck %s
1+
; RUN: llc < %s -mtriple=armv7-unknown-linux-gnueabi | FileCheck %s
32

43
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32-S64"
54
target triple = "armv7-unknown-linux-gnueabi"

test/CodeGen/ARM/ehabi-unwind.ll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
; Test that the EHABI unwind instruction generator does not encounter any
22
; unfamiliar instructions.
3-
; RUN: llc < %s -mtriple=thumbv7 -arm-enable-ehabi -disable-fp-elim
4-
; RUN: llc < %s -mtriple=thumbv7 -arm-enable-ehabi
5-
; RUN: llc < %s -mtriple=thumbv7 -arm-enable-ehabi -arm-enable-ehabi-descriptors
3+
; RUN: llc < %s -mtriple=thumbv7 -disable-fp-elim
4+
; RUN: llc < %s -mtriple=thumbv7
65

76
define void @_Z1fv() nounwind {
87
entry:

test/CodeGen/ARM/ehabi.ll

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,18 @@
1919
; (4) armv7 without -disable-fp-elim
2020

2121
; RUN: llc -mtriple arm-unknown-linux-gnueabi \
22-
; RUN: -arm-enable-ehabi -arm-enable-ehabi-descriptors \
2322
; RUN: -disable-fp-elim -filetype=asm -o - %s \
2423
; RUN: | FileCheck %s --check-prefix=CHECK-FP
2524

2625
; RUN: llc -mtriple arm-unknown-linux-gnueabi \
27-
; RUN: -arm-enable-ehabi -arm-enable-ehabi-descriptors \
2826
; RUN: -filetype=asm -o - %s \
2927
; RUN: | FileCheck %s --check-prefix=CHECK-FP-ELIM
3028

3129
; RUN: llc -mtriple armv7-unknown-linux-gnueabi \
32-
; RUN: -arm-enable-ehabi -arm-enable-ehabi-descriptors \
3330
; RUN: -disable-fp-elim -filetype=asm -o - %s \
3431
; RUN: | FileCheck %s --check-prefix=CHECK-V7-FP
3532

3633
; RUN: llc -mtriple armv7-unknown-linux-gnueabi \
37-
; RUN: -arm-enable-ehabi -arm-enable-ehabi-descriptors \
3834
; RUN: -filetype=asm -o - %s \
3935
; RUN: | FileCheck %s --check-prefix=CHECK-V7-FP-ELIM
4036

0 commit comments

Comments
 (0)