[LLVMdev] PROPOSAL: struct-access-path aware TBAA
Daniel Berlin
dberlin at dberlin.org
Wed Mar 13 10:28:34 PDT 2013
On Tue, Mar 12, 2013 at 11:59 PM, Shuxin Yang <shuxin.llvm at gmail.com> wrote:
> I personally believe that in the context of type-based AA, correctness is a
> subjective term:-).
>
> If the user smell something fishy, it is up to user to disable such opt,
> there is no other
> way around. TBAA is just to find the a sweet spot between precision &
> safeness.
Sorry, but we have to agree to disagree.
Users should expect that normal, reasonable, standards compliant code
doesn't break because the compiler decided to be aggressive.
Where the standard is ambiguous, that's one thing, but if certain
cases require us disabling TBAA for functions automatically, that is
the way it should be.
I actually used to be much more aggressive about this, probably at
your level, before the users came crashing down on me :)
You can almost always find other ways to disambiguate.
In a lot of cases, we talked with standards folks, asked what they
intended, and did that. We filed DR's for the rest.
> Unfortunately, in the context of TBAA, precision & safeness usually come at
> each other's expense...
But in most cases, IMHO, you have to choose safeness.
>
> It would be nice if we can union the dynamic types of each elements in
> point-to set. However,
> we certainly can live without if the program being compiled is well typed.
The program I gave was well typed :)
> I don't think it is a dispensable tool for this kind of opt.
>
> For some nasty license issue, I'm not allowed to peruse and discuss gcc
> internals.
FWIW: I have the right to give you the versions I wrote, under
whatever license you like.
Being a lawyer, I can guarantee I know what i'm giving you is safe :)
> I'm just using the gcc 4.6.3 binary shipped with Ubuntu to compile following
> snippet. I'm wondering
> why the p->x is promoted. In the light of "dynamic type",
> shouldn't p and q's point-to sets are "everything whose addr is taken".
In the below example, GCC assumes p and q point to anything because
they are incoming arguments.
>
>
> ------------------------------
> typedef struct {
> int x;
> }T1;
>
> typedef struct {
> int y;
> }T2;
>
> int foo(T1 *p, T2 *q) {
> p->x = 1;
> q->y = 4;
> return p->x;
> }
> --------------------------
More information about the llvm-dev
mailing list