summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen
diff options
context:
space:
mode:
authorAmaury Sechet <deadalnix@gmail.com>2016-04-07 21:29:39 +0000
committerAmaury Sechet <deadalnix@gmail.com>2016-04-07 21:29:39 +0000
commitc53ad4f3b2b001e476010690e6cc42e8a3ea458e (patch)
tree004937107c422bad6d74e6e6b4c4773a4c846311 /llvm/test/CodeGen
parent846219ae105f30081973b4b65a3b49cf87f8be4b (diff)
downloadbcm5719-llvm-c53ad4f3b2b001e476010690e6cc42e8a3ea458e.tar.gz
bcm5719-llvm-c53ad4f3b2b001e476010690e6cc42e8a3ea458e.zip
Do not select EhPad BB in MachineBlockPlacement when there is regular BB to schedule
Summary: EHPad BB are not entered the classic way and therefor do not need to be placed after their predecessors. This patch make sure EHPad BB are not chosen amongst successors to form chains, and are selected as last resort when selecting the best candidate. EHPad are scheduled in reverse probability order in order to have them flow into each others naturally. Reviewers: chandlerc, majnemer, rafael, MatzeB, escha, silvas Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D17625 llvm-svn: 265726
Diffstat (limited to 'llvm/test/CodeGen')
-rw-r--r--llvm/test/CodeGen/PowerPC/pr25802.ll52
-rw-r--r--llvm/test/CodeGen/X86/block-placement.ll93
-rw-r--r--llvm/test/CodeGen/X86/seh-safe-div-win32.ll4
-rw-r--r--llvm/test/CodeGen/X86/seh-safe-div.ll8
-rw-r--r--llvm/test/CodeGen/X86/win-catchpad.ll10
5 files changed, 104 insertions, 63 deletions
diff --git a/llvm/test/CodeGen/PowerPC/pr25802.ll b/llvm/test/CodeGen/PowerPC/pr25802.ll
deleted file mode 100644
index 99c6bfab089..00000000000
--- a/llvm/test/CodeGen/PowerPC/pr25802.ll
+++ /dev/null
@@ -1,52 +0,0 @@
-; RUN: llc < %s | FileCheck %s
-; CHECK: .long .Ltmp9-.Ltmp8 # Call between .Ltmp8 and .Ltmp9
-
-; We used to crash in filetype=obj when computing a negative value.
-; RUN: llc -filetype=obj < %s
-
-target triple = "powerpc--netbsd"
-@_ZTI1I = external constant { i8*, i8* }
-define void @f(i8 %foo, i32 %bar) personality i8* bitcast (void ()* @g to i8*) {
- invoke void @g()
- to label %try.cont unwind label %lpad
-lpad: ; preds = %0
- %tmp = landingpad { i8*, i32 }
- catch i8* bitcast ({ i8*, i8* }* @_ZTI1I to i8*)
- br i1 undef, label %catch10, label %catch
-catch10: ; preds = %lpad
- %tmp8 = load i32, i32* undef, align 4
- %conv.i.i = zext i8 %foo to i32
- %cond.i.i = select i1 undef, i32 %conv.i.i, i32 %tmp8
- invoke void @_Z24__put_character_sequenceIccEvR1AIT_T0_Ej(i32 %cond.i.i)
- to label %invoke.cont20 unwind label %lpad15
-invoke.cont20: ; preds = %catch10
- ret void
-try.cont: ; preds = %0
- ret void
-catch: ; preds = %lpad
- %tmp14 = load i32, i32* undef, align 4
- %conv.i.i34 = zext i8 %foo to i32
- %cond.i.i35 = select i1 undef, i32 %conv.i.i34, i32 %tmp14
- invoke void @_Z24__put_character_sequenceIccEvR1AIT_T0_Ej(i32 %cond.i.i35)
- to label %invoke.cont8 unwind label %lpad3
-invoke.cont8: ; preds = %call2.i.i.noexc36
- ret void
-lpad3: ; preds = %call2.i.i.noexc36, %catch
- %tmp16 = landingpad { i8*, i32 }
- cleanup
- invoke void @g()
- to label %eh.resume unwind label %terminate.lpad
-lpad15: ; preds = %catch10
- %tmp19 = landingpad { i8*, i32 }
- cleanup
- invoke void @g()
- to label %eh.resume unwind label %terminate.lpad
-eh.resume: ; preds = %lpad15, %lpad3
- ret void
-terminate.lpad: ; preds = %lpad15, %lpad3
- %tmp22 = landingpad { i8*, i32 }
- catch i8* null
- ret void
-}
-declare void @g()
-declare void @_Z24__put_character_sequenceIccEvR1AIT_T0_Ej(i32)
diff --git a/llvm/test/CodeGen/X86/block-placement.ll b/llvm/test/CodeGen/X86/block-placement.ll
index 6fe11bfe8bd..d08d15ab2d1 100644
--- a/llvm/test/CodeGen/X86/block-placement.ll
+++ b/llvm/test/CodeGen/X86/block-placement.ll
@@ -1083,3 +1083,96 @@ exit:
%ret = phi i32 [ %val1, %then ], [ %val2, %else ]
ret i32 %ret
}
+
+; Make sure we put landingpads out of the way.
+declare i32 @pers(...)
+
+declare i32 @foo();
+
+declare i32 @bar();
+
+define i32 @test_lp(i32 %a) personality i32 (...)* @pers {
+; CHECK-LABEL: test_lp:
+; CHECK: %entry
+; CHECK: %hot
+; CHECK: %then
+; CHECK: %cold
+; CHECK: %coldlp
+; CHECK: %hotlp
+; CHECK: %lpret
+entry:
+ %0 = icmp sgt i32 %a, 1
+ br i1 %0, label %hot, label %cold, !prof !4
+
+hot:
+ %1 = invoke i32 @foo()
+ to label %then unwind label %hotlp
+
+cold:
+ %2 = invoke i32 @bar()
+ to label %then unwind label %coldlp
+
+then:
+ %3 = phi i32 [ %1, %hot ], [ %2, %cold ]
+ ret i32 %3
+
+hotlp:
+ %4 = landingpad { i8*, i32 }
+ cleanup
+ br label %lpret
+
+coldlp:
+ %5 = landingpad { i8*, i32 }
+ cleanup
+ br label %lpret
+
+lpret:
+ %6 = phi i32 [-1, %hotlp], [-2, %coldlp]
+ %7 = add i32 %6, 42
+ ret i32 %7
+}
+
+!4 = !{!"branch_weights", i32 65536, i32 0}
+
+; Make sure that ehpad are scheduled from the least probable one
+; to the most probable one. See selectBestCandidateBlock as to why.
+declare void @clean();
+
+define void @test_flow_unwind() personality i32 (...)* @pers {
+; CHECK-LABEL: test_flow_unwind:
+; CHECK: %entry
+; CHECK: %then
+; CHECK: %exit
+; CHECK: %innerlp
+; CHECK: %outerlp
+; CHECK: %outercleanup
+entry:
+ %0 = invoke i32 @foo()
+ to label %then unwind label %outerlp
+
+then:
+ %1 = invoke i32 @bar()
+ to label %exit unwind label %innerlp
+
+exit:
+ ret void
+
+innerlp:
+ %2 = landingpad { i8*, i32 }
+ cleanup
+ br label %innercleanup
+
+outerlp:
+ %3 = landingpad { i8*, i32 }
+ cleanup
+ br label %outercleanup
+
+outercleanup:
+ %4 = phi { i8*, i32 } [%2, %innercleanup], [%3, %outerlp]
+ call void @clean()
+ resume { i8*, i32 } %4
+
+innercleanup:
+ call void @clean()
+ br label %outercleanup
+}
diff --git a/llvm/test/CodeGen/X86/seh-safe-div-win32.ll b/llvm/test/CodeGen/X86/seh-safe-div-win32.ll
index 643af3a472f..3d46e386762 100644
--- a/llvm/test/CodeGen/X86/seh-safe-div-win32.ll
+++ b/llvm/test/CodeGen/X86/seh-safe-div-win32.ll
@@ -65,13 +65,13 @@ __try.cont:
; Landing pad code
-; CHECK: [[handler0:LBB0_[0-9]+]]: # %handler0
+; CHECK: [[handler1:LBB0_[0-9]+]]: # %handler1
; Restore SP
; CHECK: movl {{.*}}(%ebp), %esp
; CHECK: calll _puts
; CHECK: jmp [[cont_bb]]
-; CHECK: [[handler1:LBB0_[0-9]+]]: # %handler1
+; CHECK: [[handler0:LBB0_[0-9]+]]: # %handler0
; Restore SP
; CHECK: movl {{.*}}(%ebp), %esp
; CHECK: calll _puts
diff --git a/llvm/test/CodeGen/X86/seh-safe-div.ll b/llvm/test/CodeGen/X86/seh-safe-div.ll
index 60918cf0705..d46e235c59a 100644
--- a/llvm/test/CodeGen/X86/seh-safe-div.ll
+++ b/llvm/test/CodeGen/X86/seh-safe-div.ll
@@ -67,14 +67,14 @@ __try.cont:
; Landing pad code
-; CHECK: [[handler0:\.LBB0_[0-9]+]]: # %handler0
+; CHECK: [[handler1:\.LBB0_[0-9]+]]: # %handler1
; CHECK: callq puts
-; CHECK: movl $-1, [[rloc]]
+; CHECK: movl $-2, [[rloc]]
; CHECK: jmp [[cont_bb]]
-; CHECK: [[handler1:\.LBB0_[0-9]+]]: # %handler1
+; CHECK: [[handler0:\.LBB0_[0-9]+]]: # %handler0
; CHECK: callq puts
-; CHECK: movl $-2, [[rloc]]
+; CHECK: movl $-1, [[rloc]]
; CHECK: jmp [[cont_bb]]
; CHECK: .seh_handlerdata
diff --git a/llvm/test/CodeGen/X86/win-catchpad.ll b/llvm/test/CodeGen/X86/win-catchpad.ll
index 34b8b032b4f..48866490c16 100644
--- a/llvm/test/CodeGen/X86/win-catchpad.ll
+++ b/llvm/test/CodeGen/X86/win-catchpad.ll
@@ -63,17 +63,17 @@ try.cont:
; X86: [[contbb:LBB0_[0-9]+]]: # %try.cont
; X86: retl
-; X86: [[restorebb1:LBB0_[0-9]+]]: # Block address taken
-; X86-NEXT: # %handler1
-; X86-NEXT: addl $12, %ebp
-; X86: jmp [[contbb]]
-
; FIXME: These should be de-duplicated.
; X86: [[restorebb2:LBB0_[0-9]+]]: # Block address taken
; X86-NEXT: # %handler2
; X86-NEXT: addl $12, %ebp
; X86: jmp [[contbb]]
+; X86: [[restorebb1:LBB0_[0-9]+]]: # Block address taken
+; X86-NEXT: # %handler1
+; X86-NEXT: addl $12, %ebp
+; X86: jmp [[contbb]]
+
; X86: "?catch$[[catch1bb:[0-9]+]]@?0?try_catch_catch@4HA":
; X86: LBB0_[[catch1bb]]: # %handler1{{$}}
; X86: pushl %ebp
OpenPOWER on IntegriCloud