summaryrefslogtreecommitdiff
path: root/test/CodeGen/PowerPC
diff options
context:
space:
mode:
authorTim Shen <timshen91@gmail.com>2017-09-22 18:30:02 +0000
committerTim Shen <timshen91@gmail.com>2017-09-22 18:30:02 +0000
commit1f90df4d8876bc1420d0a37c6e3e2705ee4f4753 (patch)
tree4575498f2c04c59fa429c5c82b21aa71354af17d /test/CodeGen/PowerPC
parentbbd7d72ffd76b502d80f8c12665d007537e49ca3 (diff)
[XRay] support conditional return on PPC.
Summary: Conditional returns were not taken into consideration at all. Implement them by turning them into jumps and normal returns. This means there is a slightly higher performance penalty for conditional returns, but this is the best we can do, and it still disturbs little of the rest. Reviewers: dberris, echristo Subscribers: sanjoy, nemanjai, hiraditya, kbarton, llvm-commits Differential Revision: https://reviews.llvm.org/D38102 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314005 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/PowerPC')
-rw-r--r--test/CodeGen/PowerPC/xray-conditional-return.ll79
-rw-r--r--test/CodeGen/PowerPC/xray-ret-is-terminator.ll32
2 files changed, 111 insertions, 0 deletions
diff --git a/test/CodeGen/PowerPC/xray-conditional-return.ll b/test/CodeGen/PowerPC/xray-conditional-return.ll
new file mode 100644
index 00000000000..4454d3dc62a
--- /dev/null
+++ b/test/CodeGen/PowerPC/xray-conditional-return.ll
@@ -0,0 +1,79 @@
+; RUN: llc -filetype=asm -o - -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s
+
+define void @Foo(i32 signext %a, i32 signext %b) #0 {
+; CHECK-LABEL: @Foo
+; CHECK: cmpw [[CR:[0-9]+]]
+; CHECK-NEXT: ble [[CR]], [[LABEL:\.[a-zA-Z0-9]+]]
+; CHECK-NEXT: .p2align 3
+; CHECK-NEXT: {{\.[a-zA-Z0-9]+}}:
+; CHECK-NEXT: blr
+; CHECK-NEXT: nop
+; CHECK-NEXT: std 0
+; CHECK-NEXT: mflr 0
+; CHECK-NEXT: bl __xray_FunctionExit
+; CHECK-NEXT: nop
+; CHECK-NEXT: mtlr 0
+; CHECK-NEXT: blr
+; CHECK-NEXT: [[LABEL]]:
+entry:
+ %cmp = icmp sgt i32 %a, %b
+ br i1 %cmp, label %return, label %if.end
+
+; CHECK: .p2align 3
+; CHECK-NEXT: {{\.[a-zA-Z0-9]+}}:
+; CHECK-NEXT: blr
+; CHECK-NEXT: nop
+; CHECK-NEXT: std 0
+; CHECK-NEXT: mflr 0
+; CHECK-NEXT: bl __xray_FunctionExit
+; CHECK-NEXT: nop
+; CHECK-NEXT: mtlr 0
+; CHECK-NEXT: blr
+if.end:
+ tail call void @Bar()
+ br label %return
+
+return:
+ ret void
+}
+
+define void @Foo2(i32 signext %a, i32 signext %b) #0 {
+; CHECK-LABEL: @Foo2
+; CHECK: cmpw [[CR:[0-9]+]]
+; CHECK-NEXT: bge [[CR]], [[LABEL:\.[a-zA-Z0-9]+]]
+; CHECK-NEXT: .p2align 3
+; CHECK-NEXT: {{\.[a-zA-Z0-9]+}}:
+; CHECK-NEXT: blr
+; CHECK-NEXT: nop
+; CHECK-NEXT: std 0
+; CHECK-NEXT: mflr 0
+; CHECK-NEXT: bl __xray_FunctionExit
+; CHECK-NEXT: nop
+; CHECK-NEXT: mtlr 0
+; CHECK-NEXT: blr
+; CHECK-NEXT: [[LABEL]]:
+entry:
+ %cmp = icmp slt i32 %a, %b
+ br i1 %cmp, label %return, label %if.end
+
+; CHECK: .p2align 3
+; CHECK-NEXT: {{\.[a-zA-Z0-9]+}}:
+; CHECK-NEXT: blr
+; CHECK-NEXT: nop
+; CHECK-NEXT: std 0
+; CHECK-NEXT: mflr 0
+; CHECK-NEXT: bl __xray_FunctionExit
+; CHECK-NEXT: nop
+; CHECK-NEXT: mtlr 0
+; CHECK-NEXT: blr
+if.end:
+ tail call void @Bar()
+ br label %return
+
+return:
+ ret void
+}
+
+declare void @Bar()
+
+attributes #0 = { "function-instrument"="xray-always" }
diff --git a/test/CodeGen/PowerPC/xray-ret-is-terminator.ll b/test/CodeGen/PowerPC/xray-ret-is-terminator.ll
new file mode 100644
index 00000000000..7e63530912a
--- /dev/null
+++ b/test/CodeGen/PowerPC/xray-ret-is-terminator.ll
@@ -0,0 +1,32 @@
+; RUN: llc -o - -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s
+
+define void @ILLBeBack() #0 {
+; CHECK-LABEL @ILLBeBack
+; CHECK: beq {{[0-9]+}}, [[LABEL:\.[a-zA-Z0-9_]+]]
+; CHECK: bl __xray_FunctionExit
+; CHECK: [[LABEL]]:
+bb:
+ br i1 undef, label %bb1, label %bb8
+
+bb1:
+ %tmp = tail call i64 asm sideeffect "", "=&r,=*m,b,r,*m,~{cc}"(i64* nonnull undef, i64* nonnull undef, i64 1, i64* nonnull undef)
+ %tmp2 = icmp eq i64 %tmp, 0
+ br i1 %tmp2, label %bb3, label %bb8
+
+bb3:
+ %tmp4 = tail call i64 asm sideeffect "", "=&r,=*m,b,r,r,*m,~{cc}"(i64* undef, i64* undef, i64 0, i64 undef, i64* undef)
+ %tmp5 = icmp eq i64 0, %tmp4
+ br i1 %tmp5, label %bb6, label %bb3
+
+bb6:
+ br i1 undef, label %bb7, label %bb8
+
+bb7:
+ tail call void () undef()
+ ret void
+
+bb8:
+ ret void
+}
+
+attributes #0 = { "function-instrument"="xray-always" }