mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-07 20:40:46 +00:00
f37c8a6b19
This was a real restriction in the original version of SinkIfThenCodeToEnd. Now it's been rewritten, the restriction can be lifted. As part of this, we handle a very common and useful case where one of the incoming branches is actually conditional. Consider: if (a) x(1); else if (b) x(2); This produces the following CFG: [if] / \ [x(1)] [if] | | \ | | \ | [x(2)] | \ | / [ end ] [end] has two unconditional predecessor arcs and one conditional. The conditional refers to the implicit empty 'else' arc. This same pattern can also be caused by an empty default block in a switch. We can't sink the call to x() down to end because no call to x() happens on the third incoming arc (assume that x() has sideeffects for the sake of argument; if something is safe to speculate we could indeed sink nevertheless but this cannot happen in the general case and causes many extra selects). We are now able to detect this case and split off the unconditional arcs to a common successor: [if] / \ [x(1)] [if] | | \ | | \ | [x(2)] | \ / | [sink.split] | \ / [ end ] Now we can sink the call to x() into %sink.split. This can cause significant code simplification in many testcases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280364 91177308-0d34-0410-b5e6-96231b3b80d8
112 lines
2.7 KiB
LLVM
112 lines
2.7 KiB
LLVM
;; RUN: llc -verify-machineinstrs \
|
|
;; RUN: -mtriple=armv7-linux-gnueabi -filetype=obj %s -o - | \
|
|
;; RUN: llvm-readobj -t | FileCheck -check-prefix=ARM %s
|
|
|
|
;; RUN: llc -verify-machineinstrs \
|
|
;; RUN: -mtriple=thumbv7-linux-gnueabi -filetype=obj %s -o - | \
|
|
;; RUN: llvm-readobj -t | FileCheck -check-prefix=TMB %s
|
|
|
|
;; Ensure that if a jump table is generated that it has Mapping Symbols
|
|
;; marking the data-in-code region.
|
|
|
|
define void @foo(i32* %ptr, i32 %b) nounwind ssp {
|
|
%tmp = load i32, i32* %ptr, align 4
|
|
switch i32 %tmp, label %exit [
|
|
i32 0, label %bb0
|
|
i32 1, label %bb1
|
|
i32 2, label %bb2
|
|
i32 3, label %bb3
|
|
]
|
|
bb0:
|
|
store i32 %b, i32* %ptr, align 4
|
|
br label %exit
|
|
bb1:
|
|
store i32 1, i32* %ptr, align 4
|
|
br label %exit
|
|
bb2:
|
|
store i32 2, i32* %ptr, align 4
|
|
br label %exit
|
|
bb3:
|
|
store i32 3, i32* %ptr, align 4
|
|
br label %exit
|
|
exit:
|
|
ret void
|
|
}
|
|
|
|
;; ARM: Symbol {
|
|
;; ARM: Name: $a
|
|
;; ARM-NEXT: Value: 0x0
|
|
;; ARM-NEXT: Size: 0
|
|
;; ARM-NEXT: Binding: Local
|
|
;; ARM-NEXT: Type: None
|
|
;; ARM-NEXT: Other:
|
|
;; ARM-NEXT: Section: [[MIXED_SECT:[^ ]+]]
|
|
|
|
;; ARM: Symbol {
|
|
;; ARM: Name: $a
|
|
;; ARM-NEXT: Value: 0x{{[0-9A-F]+}}
|
|
;; ARM-NEXT: Size: 0
|
|
;; ARM-NEXT: Binding: Local
|
|
;; ARM-NEXT: Type: None
|
|
;; ARM-NEXT: Other:
|
|
;; ARM-NEXT: Section: [[MIXED_SECT]]
|
|
|
|
;; ARM: Symbol {
|
|
;; ARM: Name: $d
|
|
;; ARM-NEXT: Value: 0x{{[0-9A-F]+}}
|
|
;; ARM-NEXT: Size: 0
|
|
;; ARM-NEXT: Binding: Local
|
|
;; ARM-NEXT: Type: None
|
|
;; ARM-NEXT: Other:
|
|
;; ARM-NEXT: Section: [[MIXED_SECT]]
|
|
|
|
;; ARM: Symbol {
|
|
;; ARM: Name: $d
|
|
;; ARM-NEXT: Value: 0x0
|
|
;; ARM-NEXT: Size: 0
|
|
;; ARM-NEXT: Binding: Local (0x0)
|
|
;; ARM-NEXT: Type: None (0x0)
|
|
;; ARM-NEXT: Other: 0
|
|
;; ARM-NEXT: Section: .ARM.exidx
|
|
;; ARM-NEXT: }
|
|
|
|
;; ARM: Symbol {
|
|
;; ARM: Name: $d
|
|
;; ARM-NEXT: Value: 0
|
|
;; ARM-NEXT: Size: 0
|
|
;; ARM-NEXT: Binding: Local
|
|
;; ARM-NEXT: Type: None
|
|
|
|
;; ARM-NOT: ${{[atd]}}
|
|
|
|
;; TMB: Symbol {
|
|
;; TMB: Name: $d.1
|
|
;; TMB-NEXT: Value: 0x{{[0-9A-F]+}}
|
|
;; TMB-NEXT: Size: 0
|
|
;; TMB-NEXT: Binding: Local
|
|
;; TMB-NEXT: Type: None
|
|
;; TMB-NEXT: Other:
|
|
;; TMB-NEXT: Section: [[MIXED_SECT:[^ ]+]]
|
|
|
|
;; TMB: Symbol {
|
|
;; TMB: Name: $t
|
|
;; TMB-NEXT: Value: 0x0
|
|
;; TMB-NEXT: Size: 0
|
|
;; TMB-NEXT: Binding: Local
|
|
;; TMB-NEXT: Type: None
|
|
;; TMB-NEXT: Other:
|
|
;; TMB-NEXT: Section: [[MIXED_SECT]]
|
|
|
|
;; TMB: Symbol {
|
|
;; TMB: Name: $t
|
|
;; TMB-NEXT: Value: 0x{{[0-9A-F]+}}
|
|
;; TMB-NEXT: Size: 0
|
|
;; TMB-NEXT: Binding: Local
|
|
;; TMB-NEXT: Type: None
|
|
;; TMB-NEXT: Other:
|
|
;; TMB-NEXT: Section: [[MIXED_SECT]]
|
|
|
|
|
|
;; TMB-NOT: ${{[atd]}}
|
|
|