From cf57e1b7d10cc77bff7e0d093f705ee59735d2e9 Mon Sep 17 00:00:00 2001 From: Francis Visoiu Mistrih Date: Thu, 12 Jul 2018 14:36:43 +0000 Subject: [PATCH] [XRay] Fix machine verifier issues in X86 I'm not sure if this fix is the right thing to do, but it seemed to me that PATCHABLE_RET and PATCHABLE_TAIL_CALL don't have any defs. Running the following: ``` LLVM_ENABLE_MACHINE_VERIFIER=1 ./build/bin/llvm-lit -v -a test/CodeGen/X86/xray-* ``` results in the following tests to fail (along others): ``` LLVM :: CodeGen/X86/xray-attribute-instrumentation.ll LLVM :: CodeGen/X86/xray-custom-log.ll LLVM :: CodeGen/X86/xray-log-args.ll LLVM :: CodeGen/X86/xray-loop-detection.ll LLVM :: CodeGen/X86/xray-multiplerets-in-blocks.mir LLVM :: CodeGen/X86/xray-section-group.ll LLVM :: CodeGen/X86/xray-selective-instrumentation.ll LLVM :: CodeGen/X86/xray-tail-call-sled.ll LLVM :: CodeGen/X86/xray-typed-event-log.ll ``` The errors are: ``` *** Bad machine code: Explicit definition must be a register *** - function: fn - basic block: %bb.0 (0x7fa31a84d908) - instruction: PATCHABLE_RET 2560, $eax - operand 0: 2560 ``` and ``` *** Bad machine code: Explicit definition must be a register *** - function: caller - basic block: %bb.0 (0x7fbff3044108) - instruction: PATCHABLE_TAIL_CALL 3009, @callee, , implicit $rsp, implicit $ssp, implicit $rsp, implicit $ssp, implicit $edi - operand 0: 3009 ``` Differential Revision: https://reviews.llvm.org/D49187 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@336906 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/Target.td | 4 ++-- test/CodeGen/X86/xray-attribute-instrumentation.ll | 8 ++++---- test/CodeGen/X86/xray-custom-log.ll | 6 +++--- test/CodeGen/X86/xray-log-args.ll | 4 ++-- test/CodeGen/X86/xray-loop-detection.ll | 4 ++-- test/CodeGen/X86/xray-multiplerets-in-blocks.mir | 2 +- test/CodeGen/X86/xray-section-group.ll | 4 ++-- test/CodeGen/X86/xray-selective-instrumentation.ll | 2 +- test/CodeGen/X86/xray-tail-call-sled.ll | 4 ++-- test/CodeGen/X86/xray-typed-event-log.ll | 4 ++-- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/llvm/Target/Target.td b/include/llvm/Target/Target.td index 4bfa655cc58..dc1728de1f6 100644 --- a/include/llvm/Target/Target.td +++ b/include/llvm/Target/Target.td @@ -1117,7 +1117,7 @@ def PATCHABLE_FUNCTION_ENTER : StandardPseudoInstruction { let hasSideEffects = 0; } def PATCHABLE_RET : StandardPseudoInstruction { - let OutOperandList = (outs unknown:$dst); + let OutOperandList = (outs); let InOperandList = (ins variable_ops); let AsmString = "# XRay Function Patchable RET."; let usesCustomInserter = 1; @@ -1134,7 +1134,7 @@ def PATCHABLE_FUNCTION_EXIT : StandardPseudoInstruction { let isReturn = 0; // Original return instruction will follow } def PATCHABLE_TAIL_CALL : StandardPseudoInstruction { - let OutOperandList = (outs unknown:$dst); + let OutOperandList = (outs); let InOperandList = (ins variable_ops); let AsmString = "# XRay Tail Call Exit."; let usesCustomInserter = 1; diff --git a/test/CodeGen/X86/xray-attribute-instrumentation.ll b/test/CodeGen/X86/xray-attribute-instrumentation.ll index 7fa2c0e1180..e032e65a6c6 100644 --- a/test/CodeGen/X86/xray-attribute-instrumentation.ll +++ b/test/CodeGen/X86/xray-attribute-instrumentation.ll @@ -1,7 +1,7 @@ -; RUN: llc -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s -; RUN: llc -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu \ -; RUN: -relocation-model=pic < %s | FileCheck %s -; RUN: llc -filetype=asm -o - -mtriple=x86_64-darwin-unknown < %s | FileCheck %s +; RUN: llc -verify-machineinstrs -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s +; RUN: llc -verify-machineinstrs -filetype=asm -o - \ +; RUN: -mtriple=x86_64-unknown-linux-gnu -relocation-model=pic < %s | FileCheck %s +; RUN: llc -verify-machineinstrs -filetype=asm -o - -mtriple=x86_64-darwin-unknown < %s | FileCheck %s define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always" { ; CHECK: .p2align 1, 0x90 diff --git a/test/CodeGen/X86/xray-custom-log.ll b/test/CodeGen/X86/xray-custom-log.ll index 023dd338f2f..e60c76a4ec5 100644 --- a/test/CodeGen/X86/xray-custom-log.ll +++ b/test/CodeGen/X86/xray-custom-log.ll @@ -1,6 +1,6 @@ -; RUN: llc -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s -; RUN: llc -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu \ -; RUN: -relocation-model=pic < %s | FileCheck %s -check-prefix=PIC +; RUN: llc -verify-machineinstrs -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s +; RUN: llc -verify-machineinstrs -filetype=asm -o - \ +; RUN: -mtriple=x86_64-unknown-linux-gnu -relocation-model=pic < %s | FileCheck %s -check-prefix=PIC define i32 @fn() nounwind noinline uwtable "function-instrument"="xray-always" { %eventptr = alloca i8 diff --git a/test/CodeGen/X86/xray-log-args.ll b/test/CodeGen/X86/xray-log-args.ll index 09d2b10f3d7..de0833a41b7 100644 --- a/test/CodeGen/X86/xray-log-args.ll +++ b/test/CodeGen/X86/xray-log-args.ll @@ -1,7 +1,7 @@ ; When logging arguments is specified, emit the entry sled accordingly. -; 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 +; RUN: llc -verify-machineinstrs -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s +; RUN: llc -verify-machineinstrs -filetype=asm -o - -mtriple=x86_64-darwin-unknown < %s | FileCheck %s define i32 @callee(i32 %arg) nounwind noinline uwtable "function-instrument"="xray-always" "xray-log-args"="1" { ret i32 %arg diff --git a/test/CodeGen/X86/xray-loop-detection.ll b/test/CodeGen/X86/xray-loop-detection.ll index 12904d76770..c47592eef02 100644 --- a/test/CodeGen/X86/xray-loop-detection.ll +++ b/test/CodeGen/X86/xray-loop-detection.ll @@ -1,5 +1,5 @@ -; 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 +; RUN: llc -verify-machineinstrs -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s +; RUN: llc -verify-machineinstrs -filetype=asm -o - -mtriple=x86_64-darwin-unknown < %s | FileCheck %s define i32 @foo(i32 %i) nounwind noinline uwtable "xray-instruction-threshold"="1" { entry: diff --git a/test/CodeGen/X86/xray-multiplerets-in-blocks.mir b/test/CodeGen/X86/xray-multiplerets-in-blocks.mir index 8cb15a4f1e6..d8f08104a9e 100644 --- a/test/CodeGen/X86/xray-multiplerets-in-blocks.mir +++ b/test/CodeGen/X86/xray-multiplerets-in-blocks.mir @@ -1,4 +1,4 @@ -# RUN: llc -run-pass xray-instrumentation -mtriple=x86_64-unknown-linux-gnu -o - %s | FileCheck %s +# RUN: llc -verify-machineinstrs -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. diff --git a/test/CodeGen/X86/xray-section-group.ll b/test/CodeGen/X86/xray-section-group.ll index fc06fd4a0dd..831e6bac8b9 100644 --- a/test/CodeGen/X86/xray-section-group.ll +++ b/test/CodeGen/X86/xray-section-group.ll @@ -1,5 +1,5 @@ -; RUN: llc -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu -function-sections < %s | FileCheck %s -; RUN: llc -filetype=obj -o %t -mtriple=x86_64-unknown-linux-gnu -function-sections < %s +; RUN: llc -verify-machineinstrs -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu -function-sections < %s | FileCheck %s +; RUN: llc -verify-machineinstrs -filetype=obj -o %t -mtriple=x86_64-unknown-linux-gnu -function-sections < %s ; RUN: llvm-objdump -triple x86_64-unknown-linux-gnu -disassemble-all %t | FileCheck %s --check-prefix=CHECK-OBJ define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always" { diff --git a/test/CodeGen/X86/xray-selective-instrumentation.ll b/test/CodeGen/X86/xray-selective-instrumentation.ll index 4368161a2b3..13f8578e7cf 100644 --- a/test/CodeGen/X86/xray-selective-instrumentation.ll +++ b/test/CodeGen/X86/xray-selective-instrumentation.ll @@ -1,4 +1,4 @@ -; RUN: llc -mcpu=nehalem < %s | grep xray_sled_ +; RUN: llc -verify-machineinstrs -mcpu=nehalem < %s | grep xray_sled_ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128" target triple = "x86_64-apple-darwin8" diff --git a/test/CodeGen/X86/xray-tail-call-sled.ll b/test/CodeGen/X86/xray-tail-call-sled.ll index 59ab8ea5995..b3a7e24cc3e 100644 --- a/test/CodeGen/X86/xray-tail-call-sled.ll +++ b/test/CodeGen/X86/xray-tail-call-sled.ll @@ -1,5 +1,5 @@ -; 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 +; RUN: llc -verify-machineinstrs -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s +; RUN: llc -verify-machineinstrs -filetype=asm -o - -mtriple=x86_64-darwin-unknown < %s | FileCheck %s define i32 @callee() nounwind noinline uwtable "function-instrument"="xray-always" { ; CHECK: .p2align 1, 0x90 diff --git a/test/CodeGen/X86/xray-typed-event-log.ll b/test/CodeGen/X86/xray-typed-event-log.ll index cbdcce9e9cf..a69206ed7e7 100644 --- a/test/CodeGen/X86/xray-typed-event-log.ll +++ b/test/CodeGen/X86/xray-typed-event-log.ll @@ -1,5 +1,5 @@ -; RUN: llc -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s -; RUN: llc -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu \ +; RUN: llc -verify-machineinstrs -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s +; RUN: llc -verify-machineinstrs -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu \ ; RUN: -relocation-model=pic < %s | FileCheck %s -check-prefix=PIC define i32 @fn() nounwind noinline uwtable "function-instrument"="xray-always" { -- 2.11.0