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

Richard Osborne richard at xmos.com
Fri Jul 20 10:05:22 PDT 2012


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?

-- 
Richard Osborne | XMOS
http://www.xmos.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: dce_no_return.diff
Type: text/x-patch
Size: 2384 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120720/96fac200/attachment.bin>


More information about the llvm-commits mailing list