[PATCH] D79794: Change the INLINEASM_BR MachineInstr to be a non-terminating instruction.

Bill Wendling via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 14 21:51:43 PDT 2020


void added a comment.

I think you need the following patch. We shouldn't allow instructions to be rescheduled after an `INLINEASM_BR`, because all values who's definition dominate the `INLINEASM_BR` are assumed to be valid on the indirect branch.

  diff --git a/llvm/lib/CodeGen/MachineScheduler.cpp b/llvm/lib/CodeGen/MachineScheduler.cpp
  index 0f21c97a30f..8cbbd79b661 100644
  --- a/llvm/lib/CodeGen/MachineScheduler.cpp
  +++ b/llvm/lib/CodeGen/MachineScheduler.cpp
  @@ -443,7 +443,8 @@ static bool isSchedBoundary(MachineBasicBlock::iterator MI,
                               MachineBasicBlock *MBB,
                               MachineFunction *MF,
                               const TargetInstrInfo *TII) {
  -  return MI->isCall() || TII->isSchedulingBoundary(*MI, MBB, *MF);
  +  return MI->isCall() || TII->isSchedulingBoundary(*MI, MBB, *MF) ||
  +      (MI->isInlineAsm() && MI->getOpcode() == TargetOpcode::INLINEASM_BR);
   }
   
   /// A region of an MBB for scheduling.
  diff --git a/llvm/test/CodeGen/X86/callbr-asm-outputs.ll b/llvm/test/CodeGen/X86/callbr-asm-outputs.ll
  index 61baa31074e..a4447bc15f1 100644
  --- a/llvm/test/CodeGen/X86/callbr-asm-outputs.ll
  +++ b/llvm/test/CodeGen/X86/callbr-asm-outputs.ll
  @@ -41,6 +41,7 @@ define i32 @test2(i32 %out1, i32 %out2) {
   ; CHECK-NEXT:    .cfi_offset %edi, -8
   ; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %edi
   ; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %esi
  +; CHECK-NEXT:    movl $-1, %eax
   ; CHECK-NEXT:    cmpl %edi, %esi
   ; CHECK-NEXT:    jge .LBB1_2
   ; CHECK-NEXT:  # %bb.1: # %if.then
  @@ -49,7 +50,6 @@ define i32 @test2(i32 %out1, i32 %out2) {
   ; CHECK-NEXT:    testl %edi, %esi
   ; CHECK-NEXT:    jne .Ltmp1
   ; CHECK-NEXT:    #NO_APP
  -; CHECK-NEXT:    movl $-1, %eax
   ; CHECK-NEXT:    jmp .LBB1_3
   ; CHECK-NEXT:  .LBB1_2: # %if.else
   ; CHECK-NEXT:    #APP
  @@ -57,7 +57,6 @@ define i32 @test2(i32 %out1, i32 %out2) {
   ; CHECK-NEXT:    testl %esi, %edi
   ; CHECK-NEXT:    jne .Ltmp2
   ; CHECK-NEXT:    #NO_APP
  -; CHECK-NEXT:    movl $-1, %eax
   ; CHECK-NEXT:  .LBB1_3:
   ; CHECK-NEXT:    movl %esi, %eax
   ; CHECK-NEXT:    addl %edi, %eax


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79794/new/

https://reviews.llvm.org/D79794





More information about the llvm-commits mailing list