From: Dean Michael Berris Date: Wed, 31 Aug 2016 05:20:08 +0000 (+0000) Subject: [XRay] Support multiple return instructions in a single basic block X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=047669f18c7bc8d0572fe207874f3cc2a4f31b9a;p=platform%2Fupstream%2Fllvm.git [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. llvm-svn: 280192 --- diff --git a/llvm/lib/CodeGen/XRayInstrumentation.cpp b/llvm/lib/CodeGen/XRayInstrumentation.cpp index 1f95708..714c069 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 d949b8f..7dfab65 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 0000000..4625d44 --- /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 +...