[cfe-dev] clang++ on unreachable code
Kodakara, Sreekumar V
sreekumar.v.kodakara at intel.com
Mon Jun 20 13:52:19 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?
Thanks Eli for answering the question. I am porting an analysis framework from CIL to LLVM. The analysis framework can report such dead code and I was trying to replicate that same using LLVM frontend. I was not able to replicate for this example as Clang already removes such code before it gets to my tool. But as you mentioned, since the pruning is simple, it is not a big problem for my application in general.
Thanks again.
Sreekumar
More information about the cfe-dev
mailing list