mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
MachO: trap unreachable instructions
Debugability is more important than saving 4 bytes to let us to fall through to nonense. llvm-svn: 330073
This commit is contained in:
parent
319405d79c
commit
ab39f1740c
@ -244,6 +244,9 @@ AArch64TargetMachine::AArch64TargetMachine(const Target &T, const Triple &TT,
|
||||
TLOF(createTLOF(getTargetTriple())), isLittle(LittleEndian) {
|
||||
initAsmInfo();
|
||||
|
||||
if (TT.isOSBinFormatMachO())
|
||||
this->Options.TrapUnreachable = true;
|
||||
|
||||
// Enable GlobalISel at or below EnableGlobalISelAt0.
|
||||
if (getOptLevel() <= EnableGlobalISelAtO)
|
||||
setGlobalISel(true);
|
||||
|
@ -238,6 +238,9 @@ ARMBaseTargetMachine::ARMBaseTargetMachine(const Target &T, const Triple &TT,
|
||||
this->Options.EABIVersion = EABI::EABI5;
|
||||
}
|
||||
|
||||
if (TT.isOSBinFormatMachO())
|
||||
this->Options.TrapUnreachable = true;
|
||||
|
||||
initAsmInfo();
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,8 @@ X86TargetMachine::X86TargetMachine(const Target &T, const Triple &TT,
|
||||
// The check here for 64-bit windows is a bit icky, but as we're unlikely
|
||||
// to ever want to mix 32 and 64-bit windows code in a single module
|
||||
// this should be fine.
|
||||
if ((TT.isOSWindows() && TT.getArch() == Triple::x86_64) || TT.isPS4())
|
||||
if ((TT.isOSWindows() && TT.getArch() == Triple::x86_64) || TT.isPS4() ||
|
||||
TT.isOSBinFormatMachO())
|
||||
this->Options.TrapUnreachable = true;
|
||||
|
||||
initAsmInfo();
|
||||
|
7
test/CodeGen/AArch64/macho-trap.ll
Normal file
7
test/CodeGen/AArch64/macho-trap.ll
Normal file
@ -0,0 +1,7 @@
|
||||
; RUN: llc -mtriple=aarch64-apple-ios7.0 %s -o - | FileCheck %s
|
||||
|
||||
define void @test_unreachable() {
|
||||
; CHECK-LABEL: test_unreachable:
|
||||
; CHECK: brk #0x1
|
||||
unreachable
|
||||
}
|
@ -19,7 +19,7 @@ bb:
|
||||
%tmp4 = lshr i32 %tmp3, 2
|
||||
%tmp10 = lshr i32 %tmp9, 2
|
||||
call void @foo(i32 %tmp10, i32 %tmp4)
|
||||
unreachable
|
||||
ret i32 undef
|
||||
}
|
||||
|
||||
attributes #0 = { minsize }
|
||||
|
10
test/CodeGen/ARM/macho-trap.ll
Normal file
10
test/CodeGen/ARM/macho-trap.ll
Normal file
@ -0,0 +1,10 @@
|
||||
; RUN: llc -mtriple=armv7-apple-ios7.0 %s -o - | FileCheck %s
|
||||
; RUN: llc -mtriple=thumbv7-apple-ios7.0 %s -o - | FileCheck %s
|
||||
; RUN: llc -mtriple=thumbv7m-apple-macho %s -o - | FileCheck %s
|
||||
; RUN: llc -mtriple=thumbv6m-apple-macho %s -o - | FileCheck %s
|
||||
|
||||
define void @test_unreachable() {
|
||||
; CHECK-LABEL: test_unreachable:
|
||||
; CHECK: trap
|
||||
unreachable
|
||||
}
|
@ -72,7 +72,7 @@ entry:
|
||||
|
||||
cond_true: ; preds = %entry
|
||||
tail call void @abort( )
|
||||
unreachable
|
||||
ret void
|
||||
|
||||
cond_false: ; preds = %entry
|
||||
ret void
|
||||
@ -82,7 +82,7 @@ define fastcc void @t2() nounwind {
|
||||
entry:
|
||||
; CHECK-LABEL: t2:
|
||||
; CHECK: cmp r0, #0
|
||||
; CHECK: %growMapping.exit
|
||||
; CHECK: trap
|
||||
br i1 undef, label %bb.i.i3, label %growMapping.exit
|
||||
|
||||
bb.i.i3: ; preds = %entry
|
||||
|
@ -19,6 +19,7 @@ define i32 @test(float %a, float %b) {
|
||||
; CHECK-NEXT: jmp LBB0_2
|
||||
; CHECK-NEXT: LBB0_1: ## %L_0
|
||||
; CHECK-NEXT: callq ___assert_rtn
|
||||
; CHECK-NEXT: ud2
|
||||
; CHECK-NEXT: LBB0_2: ## %L_1
|
||||
; CHECK-NEXT: xorl %eax, %eax
|
||||
; CHECK-NEXT: popq %rcx
|
||||
|
@ -5,8 +5,7 @@
|
||||
; RUN: llc -mtriple=x86_64-scei-ps4 < %s | FileCheck -check-prefix=PS4 %s
|
||||
|
||||
; X64_DARWIN: orq
|
||||
; X64_DARWIN-NEXT: jne
|
||||
; X64_DARWIN-NEXT: %bb8.i329
|
||||
; X64-DARWIN-NEXT: ud2
|
||||
|
||||
; X64_LINUX: orq %rax, %rcx
|
||||
; X64_LINUX-NEXT: jne
|
||||
|
@ -2,6 +2,7 @@
|
||||
; Test that we don't emit a row that extends beyond the FDE's range_size.
|
||||
;
|
||||
; CHECK: movq %rsp, %rbp
|
||||
; CHECK: ud2
|
||||
; CHECK-NEXT: .cfi_endproc
|
||||
; CHECK-NOT: .cfi
|
||||
|
||||
|
@ -11,7 +11,7 @@ entry:
|
||||
; MachO cannot handle an empty function.
|
||||
; CHECK-NO-FP: _func:
|
||||
; CHECK-NO-FP-NEXT: .cfi_startproc
|
||||
; CHECK-NO-FP: nop
|
||||
; CHECK-NO-FP: ud2
|
||||
; CHECK-NO-FP-NEXT: .cfi_endproc
|
||||
|
||||
; CHECK-FP: _func:
|
||||
@ -21,7 +21,8 @@ entry:
|
||||
; CHECK-FP-NEXT: .cfi_def_cfa_offset 16
|
||||
; CHECK-FP-NEXT: .cfi_offset %rbp, -16
|
||||
; CHECK-FP-NEXT: movq %rsp, %rbp
|
||||
; CHECK-FP-NEXT: .cfi_endproc
|
||||
; CHECK-FP: ud2
|
||||
; CHECK-FP: .cfi_endproc
|
||||
|
||||
; An empty function is perfectly fine on ELF.
|
||||
; LINUX-NO-FP: func:
|
||||
|
7
test/CodeGen/X86/macho-trap.ll
Normal file
7
test/CodeGen/X86/macho-trap.ll
Normal file
@ -0,0 +1,7 @@
|
||||
; RUN: llc -mtriple=x86_64-apple-macosx10.11 %s -o - | FileCheck %s
|
||||
|
||||
define void @test_unreachable() {
|
||||
; CHECK-LABEL: test_unreachable:
|
||||
; CHECK: ud2
|
||||
unreachable
|
||||
}
|
@ -14,6 +14,7 @@ define void @thread_selfcounts() noimplicitfloat noredzone nounwind {
|
||||
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
|
||||
; X86-NEXT: movl %ecx, {{[0-9]+}}(%esp)
|
||||
; X86-NEXT: movl %eax, {{[0-9]+}}(%esp)
|
||||
; X86-NEXT: ud2
|
||||
; X86-NEXT: ## -- End function
|
||||
;
|
||||
; X64-LABEL: thread_selfcounts:
|
||||
@ -23,6 +24,7 @@ define void @thread_selfcounts() noimplicitfloat noredzone nounwind {
|
||||
; X64-NEXT: movq {{[0-9]+}}(%rsp), %rcx
|
||||
; X64-NEXT: movq %rax, (%rsp)
|
||||
; X64-NEXT: movq %rcx, {{[0-9]+}}(%rsp)
|
||||
; X64-NEXT: ud2
|
||||
; X64-NEXT: ## -- End function
|
||||
entry:
|
||||
%counts = alloca [2 x i64], align 16
|
||||
|
@ -10,14 +10,14 @@ define internal fastcc void @empty_function() {
|
||||
unreachable
|
||||
}
|
||||
; CHECK-T1: SectionData (
|
||||
; CHECK-T1: 0000: C046 |.F|
|
||||
; CHECK-T1: 0000: FEDE |..|
|
||||
; CHECK-T1: )
|
||||
; CHECK-T2: SectionData (
|
||||
; CHECK-T2: 0000: 00BF |..|
|
||||
; CHECK-T2: 0000: FEDE |..|
|
||||
; CHECK-T2: )
|
||||
; CHECK-ARM: SectionData (
|
||||
; CHECK-ARM: 0000: 0000A0E1 |....|
|
||||
; CHECK-ARM: 0000: FEDEFFE7 |....|
|
||||
; CHECK-ARM: )
|
||||
; CHECK-ARMV7: SectionData (
|
||||
; CHECK-ARMV7: 0000: 00F020E3 |.. .|
|
||||
; CHECK-ARMV7: 0000: FEDEFFE7 |....|
|
||||
; CHECK-ARMV7: )
|
||||
|
Loading…
Reference in New Issue
Block a user