Re: Question about Sparse parsing - return statement

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 21, 2017 at 2:53 PM, Dibyendu Majumdar
<mobile@xxxxxxxxxxxxxxx> wrote:
>
> I notice that the return statement has a symbol associated with - the
> ret_target. What is the meaning of this symbol?

Sparse uses symbols for branch targets too.

There's several special target symbols - the return target, the
break/continue targets for loops and switch statements etc.

For example, a regular label (ie a target of a "goto") is a symbol
with the identifier being the label.  Amd the return point is
basically just another label that has the identifier "return".

So a "return statement" is basically the same as "goto return-label"
(plus the expression handling if there is one, of course).

Note that there can be *many* such return points as a function is
generated, since each inlined function will have its return point
pointing to the place in the calling function where it will return.
The same way each 'switch' statement will have its "break" label, and
each "for/.while/do" loop will have it's own "continue" and "break"
labels.

Note how each label is always described by a symbol, and how you can
look up what "break" means (regardless of whether you're in a switch
or a loop context) by just looking up the "break" label in the
NS_ITERATOR namespace.

In fact, it should be noted that the code to handle "break" and
"continue" is *EXACTLY*THE*SAME*. That should blow your mind. They
both use exactly the same logic, and they just do exactly the same
thing: look up the symbol associated with that ident, and "goto" it.

(I may be off in some of the details, it's way too long since I looked
at this code).

The return symbol is also the exit point of a compound statement, so
there's a lot of just commonalities here: any branch target always is
a symbol that is associated with the basic block that is the target.

         Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux