[cfe-commits] patch: add -fno-optimize-sibling-calls

Kostya Serebryany kcc at google.com
Fri Jan 20 17:47:57 PST 2012


This flag fill improve the quality of asan warning messages.
Compare the asan output for a test program at O0 and O1:

---------------------------------------------------------
int global[10];
void call4(int i) { global[i+10]++; }
void call3(int i) { call4(i); }
void call2(int i) { call3(i); }
void call1(int i) { call2(i); }
int main(int argc, char **argv) {
  call1(argc);
  return global[0];
}
---------------------------------------------------------
O0:
READ of size 4 at 0x00000061416c thread T0
    #0 0x404183 in call4(int) deep_tail_call.cc:2
    #1 0x404262 in call3(int) deep_tail_call.cc:3
    #2 0x4043c2 in call2(int) deep_tail_call.cc:4
    #3 0x404522 in call1(int) deep_tail_call.cc:5
    #4 0x404724 in main deep_tail_call.cc:7
O1:
READ of size 4 at 0x00000061316c thread T0
    #0 0x403fee in call4(int) deep_tail_call.cc:2

I am not sure if this flag should be set by default when asan is on.
There are at least two other flags that are required to get perfect call
stacks (-fno-inline or -O1; -fno-omit-frame-pointer).
We should either enable all of them under asan, or none.
I prefer to not change these flag under the hood, but instead document that
they are required for more informative warning messages (at the cost of
some performance loss).

--kcc


On Wed, Jan 18, 2012 at 7:54 PM, Nick Lewycky <nlewycky at google.com> wrote:

> This patch adds support for the -fno-optimize-sibling-calls flag. The
> driver lowers -fno-optimize-sibling-calls to -mdisable-tail-calls and cc1
> will ask llvm to not do any tail/sibling call optimization in the codegen
> layer. Thus far this is only implemented in LLVM's x86 backend.
>
> The goal is to produce better ASAN reports by preserving correct call
> stacks, though I don't enable it by default with -faddress-sanitizer. Maybe
> the ASAN folks will want to add that after this lands, I leave it to them.
>
> Please review!
>
> Nick
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120120/31f437c2/attachment.html>


More information about the cfe-commits mailing list