This is an archive of the discontinued LLVM Phabricator instance.

[NVPTX] Emit .noreturn directive
ClosedPublic

Authored by pavelkopyl on Dec 16 2022, 11:21 AM.

Diff Detail

Event Timeline

pavelkopyl created this revision.Dec 16 2022, 11:21 AM
pavelkopyl requested review of this revision.Dec 16 2022, 11:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 16 2022, 11:21 AM
  • Fix typo in commit msg.
pavelkopyl retitled this revision from [NVPTX] Emit .noreturn directive` to [NVPTX] Emit .noreturn directive.Dec 16 2022, 11:38 AM
pavelkopyl added a reviewer: tra.
tra accepted this revision.Dec 16 2022, 12:09 PM

LGTM. Thank you for the patch.

Just curious, does it buy us any measurable improvements?

llvm/lib/Target/NVPTX/NVPTXUtilities.cpp
342

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);
}
This revision is now accepted and ready to land.Dec 16 2022, 12:09 PM

LGTM. Thank you for the patch.

Just curious, does it buy us any measurable improvements?

Actually, I haven't tried to measure perf improvements on real tests. Here I fully relay on PTX documentation. I hope this will be beneficial in some cases.

pavelkopyl added inline comments.Dec 16 2022, 3:39 PM
llvm/lib/Target/NVPTX/NVPTXUtilities.cpp
342

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.

  • Added fixes according to review comments
  • Rebased
  • Added run of ptxas to the test
This revision was landed with ongoing or failed builds.Dec 28 2022, 10:46 AM
Closed by commit rGfa023e0fe816: [NVPTX] Emit .noreturn directive (authored by pavelkopyl, committed by asavonic). · Explain Why
This revision was automatically updated to reflect the committed changes.