[llvm] r280192 - [XRay] Support multiple return instructions in a single basic block
Dean Michael Berris via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 30 22:20:09 PDT 2016
Author: dberris
Date: Wed Aug 31 00:20:08 2016
New Revision: 280192
URL: http://llvm.org/viewvc/llvm-project?rev=280192&view=rev
Log:
[XRay] Support multiple return instructions in a single basic block
Add a .mir test to catch this case, and fix the xray-instrumentation
pass to handle it appropriately.
Added:
llvm/trunk/test/CodeGen/X86/xray-multiplerets-in-blocks.mir
Modified:
llvm/trunk/lib/CodeGen/XRayInstrumentation.cpp
llvm/trunk/test/CodeGen/X86/xray-attribute-instrumentation.ll
Modified: llvm/trunk/lib/CodeGen/XRayInstrumentation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/XRayInstrumentation.cpp?rev=280192&r1=280191&r2=280192&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/XRayInstrumentation.cpp (original)
+++ llvm/trunk/lib/CodeGen/XRayInstrumentation.cpp Wed Aug 31 00:20:08 2016
@@ -79,7 +79,6 @@ bool XRayInstrumentation::runOnMachineFu
for (auto &MO : T.operands())
MIB.addOperand(MO);
Terminators.push_back(&T);
- break;
}
}
}
Modified: llvm/trunk/test/CodeGen/X86/xray-attribute-instrumentation.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/xray-attribute-instrumentation.ll?rev=280192&r1=280191&r2=280192&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/xray-attribute-instrumentation.ll (original)
+++ llvm/trunk/test/CodeGen/X86/xray-attribute-instrumentation.ll Wed Aug 31 00:20:08 2016
@@ -18,3 +18,35 @@ define i32 @foo() nounwind noinline uwta
; CHECK-LABEL: Lxray_synthetic_0:
; CHECK: .quad .Lxray_sled_0
; CHECK: .quad .Lxray_sled_1
+
+; We test multiple returns in a single function to make sure we're getting all
+; of them with XRay instrumentation.
+define i32 @bar(i32 %i) nounwind noinline uwtable "function-instrument"="xray-always" {
+; CHECK: .p2align 1, 0x90
+; CHECK-LABEL: Lxray_sled_2:
+; CHECK-NEXT: .ascii "\353\t"
+; CHECK-NEXT: nopw 512(%rax,%rax)
+; CHECK-LABEL: Ltmp1:
+Test:
+ %cond = icmp eq i32 %i, 0
+ br i1 %cond, label %IsEqual, label %NotEqual
+IsEqual:
+ ret i32 0
+; CHECK: .p2align 1, 0x90
+; CHECK-LABEL: Lxray_sled_3:
+; CHECK-NEXT: retq
+; CHECK-NEXT: nopw %cs:512(%rax,%rax)
+NotEqual:
+ ret i32 1
+; CHECK: .p2align 1, 0x90
+; CHECK-LABEL: Lxray_sled_4:
+; CHECK-NEXT: retq
+; CHECK-NEXT: nopw %cs:512(%rax,%rax)
+}
+; CHECK: .p2align 4, 0x90
+; CHECK-NEXT: .quad .Lxray_synthetic_1
+; CHECK-NEXT: .section xray_instr_map,{{.*}}
+; CHECK-LABEL: Lxray_synthetic_1:
+; CHECK: .quad .Lxray_sled_2
+; CHECK: .quad .Lxray_sled_3
+; CHECK: .quad .Lxray_sled_4
Added: llvm/trunk/test/CodeGen/X86/xray-multiplerets-in-blocks.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/xray-multiplerets-in-blocks.mir?rev=280192&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/xray-multiplerets-in-blocks.mir (added)
+++ llvm/trunk/test/CodeGen/X86/xray-multiplerets-in-blocks.mir Wed Aug 31 00:20:08 2016
@@ -0,0 +1,28 @@
+# RUN: llc -run-pass xray-instrumentation -mtriple=x86_64-unknown-linux-gnu -o - %s | FileCheck %s
+#
+# Make sure we can handle multiple ret instructions in a single basic block for
+# XRay.
+
+--- |
+
+ define i32 @foo() noinline uwtable "function-instrument"="xray-always" {
+ ret i32 0
+ ret i32 1
+ }
+
+...
+
+---
+name: foo
+tracksRegLiveness: true
+liveins:
+ - { reg: '%edi'}
+body: |
+ bb.0:
+ liveins: %edi
+ ; CHECK: PATCHABLE_FUNCTION_ENTER
+ RETQ
+ ; CHECK-NEXT: PATCHABLE_RET 2508
+ RETQ
+ ; CHECK-NEXT: PATCHABLE_RET 2508
+...
More information about the llvm-commits
mailing list