summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/X86/xray-loop-detection.ll
diff options
context:
space:
mode:
authorDean Michael Berris <dberris@google.com>2017-05-04 01:24:26 +0000
committerDean Michael Berris <dberris@google.com>2017-05-04 01:24:26 +0000
commit22f2bcf4b929732b091a683ea01413072a424d3b (patch)
tree17fb935a132afd15abf79885a21a5944c4c2326e /llvm/test/CodeGen/X86/xray-loop-detection.ll
parentbdde34828b62893a9018e2d9e8ec2b705fd6632c (diff)
downloadbcm5719-llvm-22f2bcf4b929732b091a683ea01413072a424d3b.tar.gz
bcm5719-llvm-22f2bcf4b929732b091a683ea01413072a424d3b.zip
[XRay] Detect loops in functions being lowered
Summary: This is an implementation of the loop detection logic that XRay needs to determine whether a function might take time at runtime. Without this heuristic, XRay will tend to not instrument short functions that have loops that might have runtime dependent on inputs or external values. While this implementation doesn't do any further analysis than just figuring out whether there is a loop in the MachineFunction being code-gen'ed, we're paving the way for being able to perform more sophisticated analysis of the function in the future (for example to determine whether the trip count for the loop might be constant, and make a decision on that instead). This enables us to cover more functions with the default heuristics, and potentially identify ones that have variable runtime latency just by looking for the presence of loops. Reviewers: chandlerc, rnk, pelikan Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32274 llvm-svn: 302103
Diffstat (limited to 'llvm/test/CodeGen/X86/xray-loop-detection.ll')
-rw-r--r--llvm/test/CodeGen/X86/xray-loop-detection.ll23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/xray-loop-detection.ll b/llvm/test/CodeGen/X86/xray-loop-detection.ll
new file mode 100644
index 00000000000..3cd6b4aa6f8
--- /dev/null
+++ b/llvm/test/CodeGen/X86/xray-loop-detection.ll
@@ -0,0 +1,23 @@
+; RUN: llc -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
+; RUN: llc -filetype=asm -o - -mtriple=x86_64-darwin-unknown < %s | FileCheck %s
+
+define i32 @foo(i32 %i) nounwind noinline uwtable "xray-instruction-threshold"="1" {
+entry:
+ br label %Test
+Test:
+ %indvar = phi i32 [0, %entry], [%nextindvar, %Inc]
+ %cond = icmp eq i32 %indvar, %i
+ br i1 %cond, label %Exit, label %Inc
+Inc:
+ %nextindvar = add i32 %indvar, 1
+ br label %Test
+Exit:
+ %retval = phi i32 [%indvar, %Test]
+ ret i32 %retval
+}
+
+; CHECK-LABEL: xray_sled_0:
+; CHECK-NEXT: .ascii "\353\t"
+; CHECK-NEXT: nopw 512(%rax,%rax)
+; CHECK-LABEL: Ltmp0:
+
OpenPOWER on IntegriCloud