On Sun, Jun 16, 2013 at 10:06 AM, Barry Holm <barry.hol...@gmail.com> wrote:
>
> I am trying to analyze source code to object code traceability while
> using C source code and GCC 3.3.2 with optimization levels O0, O1, O2.
> I create test cases that each test case (separate routine) contains
> one C source code construct (if - else, do-while, for loop, switch and
> etc.) and analyse the traceability to the object code. I would like to
> ensure that all cases of constructs in the source code are covered by
> this analysis.  I wonder if I need to extend the list of constructs
> with additional cases as “if….else do….while”  in case the object code
> created from separate  “if….else" and "do….while” statements is
> different from the object code created  from two consecutive “if…else
> do ... while” statements.  Is there a way to identify the full list of
> these constructs to ensure that each object code is traceable back to
> the source code using optimization level -O2? How different is this
> list from optimization level -O1 or -O0?

You didn't really say what the goal was.

At -O2 some source code constructs can disappear from the object code
entirely, because the results they compute are unused.  Is that OK for
your purposes?

When optimizing, the compiler doesn't really see the input in source
code terms.  Conditions and loops are broken down into simple branches
and conditional branches, then basic blocks and loops are built out of
that.  So the divergence between the source code and the compiled code
can be fairly large.

Ian

Reply via email to