[PATCH] D139883: [llvm][CallBrPrepare] add llvm.callbr.landingpad intrinsic

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 15 12:38:41 PST 2022


nickdesaulniers added inline comments.


================
Comment at: llvm/lib/IR/Verifier.cpp:5774
+  }
   };
 }
----------------
We should also check that the landingpad is the first instruction (isFirstNonPhi or non debug or some such). Otherwise you could have:
```
declare i64 @foo(i64)
define i64 @test_callbr_landingpad_not_first_inst() {
entry:
  ; Specifically, output into %rdi
  %0 = callbr i64 asm "", "={di},!i"()
          to label %asm.fallthrough [label %landingpad]

asm.fallthrough:
  ret i64 42

landingpad:
  ; By the calling convention on x86_64-linux-gnu, 42 must be passed in %rdi.
  %foo = call i64 @foo(i64 42)
  %out = call i64 @llvm.callbr.landingpad.i64()
  ret i64 %out
}

declare i64 @llvm.callbr.landingpad.i64()
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139883



More information about the llvm-commits mailing list