[PATCH] D51161: Allow inconsistent offsets for 'noreturn' basic blocks when '-verify-cfiinstrs'

Vladimir Stefanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 23 06:46:18 PDT 2018


vstefanovic added a comment.

C code to reproduce the issue, built with

  '-O2 -mllvm -tail-merge-size=1 -mllvm -verify-cfiinstrs':

  void foo1(int v) __attribute__((noreturn)) {
    if (v == 1) {
      __builtin_trap();
    }
    if (foo2(v)) {
      __builtin_trap();
    }
  }

Machine IR before branch-folder:

  bb.0.entry:
    CMP32ri8 $edi, 1
    JNE_1 %bb.2
    JMP_1 %bb.1
  
  bb.1.if.then:
    TRAP
  
  bb.2.if.end:
    PUSH64r $rax
    CFI_INSTRUCTION def_cfa_offset 16
    $eax = MOV32r0
    CALL64pcrel32 @foo2
    TRAP

(No stack adjustment after foo() because it's noreturn block.)

Then branch-folder merges TRAPs:

  bb.0.entry:
    CMP32ri8 $edi, 1
    JE_1 %bb.2
  
  bb.1.if.end:
    PUSH64r $rax
    CFI_INSTRUCTION def_cfa_offset 16
    $eax = MOV32r0
    CALL64pcrel32 @foo2
  
  bb.2.if.then:
    TRAP

So bb.0 and bb.1 become direct predecessors of bb.2 with different outgoing offsets.


Repository:
  rL LLVM

https://reviews.llvm.org/D51161





More information about the llvm-commits mailing list