llvm.org GIT mirror llvm / 3fca788
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 Renato Golin 6 years ago
23 changed file(s) with 63 addition(s) and 58 deletion(s). Raw diff Collapse all Expand all
3535 #include "llvm/Target/TargetRegisterInfo.h"
3636 using namespace llvm;
3737
38 static cl::opt
39 EnableARMEHABIDescriptors("arm-enable-ehabi-descriptors", cl::Hidden,
40 cl::desc("Generate ARM EHABI tables with unwinding descriptors"),
41 cl::init(false));
42
43
4438 ARMException::ARMException(AsmPrinter *A)
4539 : DwarfException(A) {}
4640
7367 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("eh_func_end",
7468 Asm->getFunctionNumber()));
7569
76 if (EnableARMEHABIDescriptors) {
77 // Map all labels and get rid of any dead landing pads.
78 MMI->TidyLandingPads();
70 // Map all labels and get rid of any dead landing pads.
71 MMI->TidyLandingPads();
7972
80 if (!MMI->getLandingPads().empty()) {
81 // Emit references to personality.
82 if (const Function * Personality =
83 MMI->getPersonalities()[MMI->getPersonalityIndex()]) {
84 MCSymbol *PerSym = Asm->getSymbol(Personality);
85 Asm->OutStreamer.EmitSymbolAttribute(PerSym, MCSA_Global);
86 ATS.emitPersonality(PerSym);
87 }
73 if (!MMI->getLandingPads().empty()) {
74 // Emit references to personality.
75 if (const Function * Personality =
76 MMI->getPersonalities()[MMI->getPersonalityIndex()]) {
77 MCSymbol *PerSym = Asm->getSymbol(Personality);
78 Asm->OutStreamer.EmitSymbolAttribute(PerSym, MCSA_Global);
79 ATS.emitPersonality(PerSym);
80 }
8881
89 // Emit .handlerdata directive.
90 ATS.emitHandlerData();
82 // Emit .handlerdata directive.
83 ATS.emitHandlerData();
9184
92 // Emit actual exception table
93 EmitExceptionTable();
94 }
85 // Emit actual exception table
86 EmitExceptionTable();
9587 }
9688 }
9789
480480 default:
481481 llvm_unreachable("Not implemented relocation type!");
482482
483 case ELF::R_ARM_NONE:
484 break;
483485 // Write a 32bit value to relocation address, taking into account the
484486 // implicit addend encoded in the target.
487 case ELF::R_ARM_PREL31:
485488 case ELF::R_ARM_TARGET1:
486489 case ELF::R_ARM_ABS32:
487490 *TargetPtr = *Placeholder + Value;
11051105 }
11061106 }
11071107
1108 extern cl::opt EnableARMEHABI;
1108 extern cl::opt DisableARMEHABI;
11091109
11101110 // Simple pseudo-instructions have their lowering (with expansion to real
11111111 // instructions) auto-generated.
11211121 }
11221122
11231123 // Emit unwinding stuff for frame-related instructions
1124 if (EnableARMEHABI && MI->getFlag(MachineInstr::FrameSetup))
1124 if (Subtarget->isTargetEHABICompatible() && !DisableARMEHABI &&
1125 MI->getFlag(MachineInstr::FrameSetup))
11251126 EmitUnwindingInstruction(MI);
11261127
11271128 // Do any auto-generated pseudo lowerings.
327327 !isTargetDarwin();
328328 }
329329
330 // ARM Targets that support EHABI exception handling standard
331 // Darwin uses SjLj. Other targets might need more checks.
332 bool isTargetEHABICompatible() const {
333 return (TargetTriple.getEnvironment() == Triple::EABI ||
334 TargetTriple.getEnvironment() == Triple::GNUEABI ||
335 TargetTriple.getEnvironment() == Triple::EABIHF ||
336 TargetTriple.getEnvironment() == Triple::GNUEABIHF) &&
337 !isTargetDarwin();
338 }
339
330340 bool isTargetHardFloat() const {
331341 return TargetTriple.getEnvironment() == Triple::GNUEABIHF ||
332342 TargetTriple.getEnvironment() == Triple::EABIHF;
1515
1616 using namespace llvm;
1717
18 // ARM EHABI is experimental but the quality is good enough
19 // to be turned on by default on non-Darwin ARM targets.
1820 cl::opt
19 EnableARMEHABI("arm-enable-ehabi", cl::Hidden,
20 cl::desc("Generate ARM EHABI tables"),
21 DisableARMEHABI("arm-disable-ehabi", cl::Hidden,
22 cl::desc("Disable ARM experimental exception handling"),
2123 cl::init(false));
2224
2325
5153 SupportsDebugInformation = true;
5254
5355 // Exceptions handling
54 if (EnableARMEHABI)
56 if (!DisableARMEHABI)
5557 ExceptionsType = ExceptionHandling::ARM;
5658
5759 // foo(plt) instead of foo@plt
None ; RUN: llc -mtriple=armv7-none-linux-gnueabi -arm-enable-ehabi -arm-enable-ehabi-descriptors < %s | FileCheck %s
0 ; RUN: llc -mtriple=armv7-none-linux-gnueabi < %s | FileCheck %s
11
22 @_ZTVN10__cxxabiv117__class_type_infoE = external global i8*
33 @_ZTS3Foo = linkonce_odr constant [5 x i8] c"3Foo\00"
None ; RUN: llc -arm-enable-ehabi -arm-enable-ehabi-descriptors < %s | FileCheck %s
0 ; RUN: llc < %s | FileCheck %s
11 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"
22 target triple = "armv7-none-linux-gnueabi"
33
None ; RUN: llc < %s -mtriple=armv7-unknown-linux-gnueabi \
1 ; RUN: -arm-enable-ehabi -arm-enable-ehabi-descriptors | FileCheck %s
0 ; RUN: llc < %s -mtriple=armv7-unknown-linux-gnueabi | FileCheck %s
21
32 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"
43 target triple = "armv7-unknown-linux-gnueabi"
0 ; Test that the EHABI unwind instruction generator does not encounter any
11 ; unfamiliar instructions.
2 ; RUN: llc < %s -mtriple=thumbv7 -arm-enable-ehabi -disable-fp-elim
3 ; RUN: llc < %s -mtriple=thumbv7 -arm-enable-ehabi
4 ; RUN: llc < %s -mtriple=thumbv7 -arm-enable-ehabi -arm-enable-ehabi-descriptors
2 ; RUN: llc < %s -mtriple=thumbv7 -disable-fp-elim
3 ; RUN: llc < %s -mtriple=thumbv7
54
65 define void @_Z1fv() nounwind {
76 entry:
1818 ; (4) armv7 without -disable-fp-elim
1919
2020 ; RUN: llc -mtriple arm-unknown-linux-gnueabi \
21 ; RUN: -arm-enable-ehabi -arm-enable-ehabi-descriptors \
2221 ; RUN: -disable-fp-elim -filetype=asm -o - %s \
2322 ; RUN: | FileCheck %s --check-prefix=CHECK-FP
2423
2524 ; RUN: llc -mtriple arm-unknown-linux-gnueabi \
26 ; RUN: -arm-enable-ehabi -arm-enable-ehabi-descriptors \
2725 ; RUN: -filetype=asm -o - %s \
2826 ; RUN: | FileCheck %s --check-prefix=CHECK-FP-ELIM
2927
3028 ; RUN: llc -mtriple armv7-unknown-linux-gnueabi \
31 ; RUN: -arm-enable-ehabi -arm-enable-ehabi-descriptors \
3229 ; RUN: -disable-fp-elim -filetype=asm -o - %s \
3330 ; RUN: | FileCheck %s --check-prefix=CHECK-V7-FP
3431
3532 ; RUN: llc -mtriple armv7-unknown-linux-gnueabi \
36 ; RUN: -arm-enable-ehabi -arm-enable-ehabi-descriptors \
3733 ; RUN: -filetype=asm -o - %s \
3834 ; RUN: | FileCheck %s --check-prefix=CHECK-V7-FP-ELIM
3935
None ; RUN: llc < %s -mcpu=cortex-a8 -march=arm -asm-verbose=false | FileCheck %s
0 ; RUN: llc < %s -mcpu=cortex-a8 -march=arm -asm-verbose=false -arm-disable-ehabi | FileCheck %s
11
22 define zeroext i1 @test0(i32 %x) nounwind {
33 ; CHECK-LABEL: test0:
None ; RUN: llc < %s -march=arm -mcpu=cortex-a8 -O0 -filetype=obj -o %t.o
1 ; RUN: llc < %s -march=thumb -mcpu=cortex-a8 -O0 -filetype=obj -o %t.o
2 ; RUN: llc < %s -march=arm -mcpu=cortex-a8 -O2 -filetype=obj -verify-machineinstrs -o %t.o
3 ; RUN: llc < %s -march=thumb -mcpu=cortex-a8 -O2 -filetype=obj -verify-machineinstrs -o %t.o
0 ; RUN: llc < %s -march=arm -mcpu=cortex-a8 -O0 -filetype=obj -o %t.o -arm-disable-ehabi
1 ; RUN: llc < %s -march=thumb -mcpu=cortex-a8 -O0 -filetype=obj -o %t.o -arm-disable-ehabi
2 ; RUN: llc < %s -march=arm -mcpu=cortex-a8 -O2 -filetype=obj -verify-machineinstrs -o %t.o -arm-disable-ehabi
3 ; RUN: llc < %s -march=thumb -mcpu=cortex-a8 -O2 -filetype=obj -verify-machineinstrs -o %t.o -arm-disable-ehabi
44 target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32-S32"
55 target triple = "thumbv7-apple-ios"
66
0 declare i32 @FA()
11
2 define i32 @FB() {
2 define i32 @FB() nounwind {
33 %r = call i32 @FA( ) ; [#uses=1]
44 ret i32 %r
55 }
0 declare i32 @FC()
11
2 define i32 @FB() {
2 define i32 @FB() nounwind {
33 %r = call i32 @FC( ) ; [#uses=1]
44 ret i32 %r
55 }
None define i32 @FC() {
0 define i32 @FC() nounwind {
11 ret i32 0
22 }
33
11
22 declare i32 @FB()
33
4 define i32 @FA() {
4 define i32 @FA() nounwind {
55 ret i32 0
66 }
77
8 define i32 @main() {
8 define i32 @main() nounwind {
99 %r = call i32 @FB( ) ; [#uses=1]
1010 ret i32 %r
1111 }
12
11
22 declare i32 @FB()
33
4 define i32 @main() {
4 define i32 @main() nounwind {
55 %r = call i32 @FB( ) ; [#uses=1]
66 ret i32 %r
77 }
0 ; RUN: %lli_mcjit -remote-mcjit -mcjit-remote-process=lli-child-target%exeext %s > /dev/null
11
2 define i32 @bar() {
2 define i32 @bar() nounwind {
33 ret i32 0
44 }
55
6 define i32 @main() {
6 define i32 @main() nounwind {
77 %r = call i32 @bar( ) ; [#uses=1]
88 ret i32 %r
99 }
22 ; Check that a variable is always aligned as specified.
33
44 @var = global i32 0, align 32
5 define i32 @main() {
5 define i32 @main() nounwind {
66 %addr = ptrtoint i32* @var to i64
77 %mask = and i64 %addr, 31
88 %tst = icmp eq i64 %mask, 0
0 ; RUN: %lli_mcjit -remote-mcjit -mcjit-remote-process=lli-child-target%exeext %s > /dev/null
11
2 define double @test(double* %DP, double %Arg) {
2 define double @test(double* %DP, double %Arg) nounwind {
33 %D = load double* %DP ; [#uses=1]
44 %V = fadd double %D, 1.000000e+00 ; [#uses=2]
55 %W = fsub double %V, %V ; [#uses=3]
1111 ret double %Y
1212 }
1313
14 define i32 @main() {
14 define i32 @main() nounwind {
1515 %X = alloca double ; [#uses=2]
1616 store double 0.000000e+00, double* %X
1717 call double @test( double* %X, double 2.000000e+00 ) ; :1 [#uses=0]
11
22 @count = global i32 1, align 4
33
4 define i32 @main() nounwind uwtable {
4 define i32 @main() nounwind {
55 entry:
66 %retval = alloca i32, align 4
77 %i = alloca i32, align 4
None ;; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort \
0 ;; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort -arm-disable-ehabi \
11 ;; RUN: -mtriple=armv7-linux-gnueabi -filetype=obj %s -o - | \
22 ;; RUN: llvm-readobj -t | FileCheck -check-prefix=ARM %s
33
4 ;; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort \
4 ;; RUN: llc -O0 -verify-machineinstrs -fast-isel-abort -arm-disable-ehabi \
55 ;; RUN: -mtriple=thumbv7-linux-gnueabi -filetype=obj %s -o - | \
66 ;; RUN: llvm-readobj -t | FileCheck -check-prefix=TMB %s
77
3131 ; CHECK-NEXT: Section (2) .rel.text {
3232 ; CHECK-NEXT: 0x8 R_ARM_THM_CALL foo 0x0
3333 ; CHECK-NEXT: }
34 ; CHECK-NEXT: Section (7) .rel.ARM.exidx {
35 ; CHECK-NEXT: 0x0 R_ARM_PREL31 .text 0x0
36 ; CHECK-NEXT: 0x8 R_ARM_PREL31 .text 0x0
37 ; CHECK-NEXT: }
3438 ; CHECK-NEXT: ]
3539
3640 ; make sure foo is thumb function: bit 0 = 1