[llvm-commits] [PATCH] treat calls to noreturn functions as side effecting

Duncan Sands baldrick at free.fr
Fri Jul 20 23:06:21 PDT 2012


Hi Richard,

> Currently at -O2 a call to a readonly noreturn function (e.g. a function
> consisting of while(1)) is replaced by unreachable, which seems somewhat nasty.
> The following sequence of transforms are responsible:
>
> 1) prune-eh adds unreachable after the call (since it has the noreturn attribute)
> 2) early-cse removes the call to the function (since it has the readonly
> attribute).
>
> This patch makes Instruction::hasSideEffect() return true for functions marked
> with the no return attribute avoid this.
> To be completely correct early-cse (and others) should be updated so that they
> only delete calls to functions that provably always return (or are marked as
> such) - see PR965. While this would be nice to fix it is also a much bigger
> slice of work.
>
> Does this patch seem reasonable?

it does seem pretty reasonable to me.

Ciao, Duncan.




More information about the llvm-commits mailing list