[PATCH] D140238: [NVPTX] Emit .noreturn directive
Pavel Kopyl via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 16 15:39:36 PST 2022
pavelkopyl added inline comments.
================
Comment at: llvm/lib/Target/NVPTX/NVPTXUtilities.cpp:342
+
+ assert(isa<Function>(V) && "Expect either a call instruction or a function");
+
----------------
tra wrote:
> Nit: The mismatch between assertion condition and the message looks a bit odd. Correct, but odd.
>
> How about restructuring the code like this:
> ```
> assert(isa<Function> || isa<CallInst> ...)
> if (const CallInst *CallI = dyn_cast<CallInst>(V)) {
> return CallI->doesNotReturn() &&
> CallI->getFunctionType()->getReturnType()->isVoidTy();
> } else {
> const Function *F = cast<Function>(V);
> return F->doesNotReturn() &&
> F->getFunctionType()->getReturnType()->isVoidTy() &&
> !isKernelFunction(*F);
> }
> ```
I agree, thank you. I moved the assert up. But I think I will be better to leave check for "cast<Function>" unconditional to avoid else-after-return.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140238/new/
https://reviews.llvm.org/D140238
More information about the llvm-commits
mailing list