diff options
-rw-r--r-- | llvm/lib/CodeGen/XRayInstrumentation.cpp | 1 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll | 32 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/xray-multiplerets-in-blocks.mir | 28 |
3 files changed, 60 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/XRayInstrumentation.cpp b/llvm/lib/CodeGen/XRayInstrumentation.cpp index 1f9570895f9..714c0696173 100644 --- a/llvm/lib/CodeGen/XRayInstrumentation.cpp +++ b/llvm/lib/CodeGen/XRayInstrumentation.cpp @@ -79,7 +79,6 @@ bool XRayInstrumentation::runOnMachineFunction(MachineFunction &MF) { for (auto &MO : T.operands()) MIB.addOperand(MO); Terminators.push_back(&T); - break; } } } diff --git a/llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll b/llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll index d949b8fd96e..7dfab650fbc 100644 --- a/llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll +++ b/llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll @@ -18,3 +18,35 @@ define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always" ; 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 diff --git a/llvm/test/CodeGen/X86/xray-multiplerets-in-blocks.mir b/llvm/test/CodeGen/X86/xray-multiplerets-in-blocks.mir new file mode 100644 index 00000000000..4625d4452bb --- /dev/null +++ b/llvm/test/CodeGen/X86/xray-multiplerets-in-blocks.mir @@ -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 +... |