[cfe-dev] clang++ on unreachable code

Eli Friedman eli.friedman at gmail.com
Mon Jun 20 12:17:08 PDT 2011


On Mon, Jun 20, 2011 at 12:02 PM, Kodakara, Sreekumar V
<sreekumar.v.kodakara at intel.com> wrote:
> Note that the code corresponding to a++; and return a; statements are not
> generated by frontend. Looks like the frontend detected that a++ and return
> a; to be dead code. My question is under what circumstances does the
> frontend do this optimization and is it possible to tell the frontend to NOT
> do the optimization?.

The pruning optimizations clang uses are extremely simple; the exact
details aren't guaranteed, but we basically only prune code after a
return statement or noreturn call and code guarded by a if/switch with
an operand that is obviously constant.

There isn't any flag to change this because it doesn't really make
sense; dead code doesn't do anything useful.  What are you trying to
do?

-Eli



More information about the cfe-dev mailing list