[PATCH] D93946: [FuncAttrs] Infer noreturn
Madhur Amilkanthwar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 30 09:11:30 PST 2020
madhur13490 added inline comments.
================
Comment at: llvm/lib/Transforms/IPO/FunctionAttrs.cpp:1400
+
+ bool CanReturn = false;
+ // The function can return if any basic blocks terminating with a ReturnInst
----------------
I think you can actually avoid this variable. You can declare "FoundNoReturnCall" outside the loops and define it in each iteration of the outer loop. If (!FoundNoReturnCall) in outer loop then break and if (FoundNoReturnCall) outside the loop then F->setDoesNotReturn(). CanReturn is acting as an accumulator here but if you declare FoundNoReturnCall outside the loop then it can act for the same purpose.
================
Comment at: llvm/lib/Transforms/IPO/FunctionAttrs.cpp:1409-1411
+ if (auto *CB = dyn_cast<CallBase>(&I)) {
+ if (Function *Callee = CB->getCalledFunction()) {
+ if (Callee->doesNotReturn()) {
----------------
Can combine them to one condition in some helper function and call it here. This will be more readable and maintenable
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93946/new/
https://reviews.llvm.org/D93946
More information about the llvm-commits
mailing list