Based on my understanding of her design, following is one obtuse motivating example: -------------------------- class A; class B; int foo(A* p, B* q) { p->a_int_field = 2; q->another_int_field = 3; return p->a_int_field; // !!!!! } ---------------------------------- the *-statement can be optimized into "return 2" if optimizer can prove type-A does not include type-B, and type-B does not include type-A either. On 03/12/2013 07:48 PM, Krzysztof Parzyszek wrote:> On 3/12/2013 9:43 PM, Shuxin Yang wrote: >> >> Note that, to make base/offset/size more effective, analyzer need to >> track the base along the UD chains >> as far as possible. In this case, the "bases" for the memory are "p", >> instead of &vd and &vc, respectively. > > If the base pointers are the same, then offset+length for each access > is sufficient to determine aliasing. No type information is needed > for this. I'm still not sure exactly what this proposal is supposed > to address, but yes---given two base pointers (possibly not equal), > the structural paths to the accessed objects are not sufficient. > > -Krzysztof > >
Krzysztof Parzyszek
2013-Mar-13 02:59 UTC
[LLVMdev] PROPOSAL: struct-access-path aware TBAA
On 3/12/2013 9:56 PM, Shuxin Yang wrote:> Based on my understanding of her design, following is one obtuse > motivating example: > > -------------------------- > class A; > class B; > > int foo(A* p, B* q) { > > p->a_int_field = 2; > q->another_int_field = 3; > return p->a_int_field; // !!!!! > } > ---------------------------------- > > the *-statement can be optimized into "return 2" if optimizer can prove > type-A does not include type-B, > and type-B does not include type-A either. >And my example shows that they can alias regardless of that. Granted, it's somewhat contrived and I'm not 100% sure if it's legal. Once there are pointers, there is little that can be done without knowing at least something about what they point to. -Krzysztof -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
On Tue, Mar 12, 2013 at 7:59 PM, Krzysztof Parzyszek <kparzysz at codeaurora.org> wrote:> On 3/12/2013 9:56 PM, Shuxin Yang wrote: >> >> Based on my understanding of her design, following is one obtuse >> motivating example: >> >> -------------------------- >> class A; >> class B; >> >> int foo(A* p, B* q) { >> >> p->a_int_field = 2; >> q->another_int_field = 3; >> return p->a_int_field; // !!!!! >> } >> ---------------------------------- >> >> the *-statement can be optimized into "return 2" if optimizer can prove >> type-A does not include type-B, >> and type-B does not include type-A either. >> > > And my example shows that they can alias regardless of that. Granted, it's > somewhat contrived and I'm not 100% sure if it's legal. Once there are > pointers, there is little that can be done without knowing at least > something about what they point to.yes, this is essentially one of my claims :)
On Mar 12, 2013, at 7:59 PM, Krzysztof Parzyszek wrote:> On 3/12/2013 9:56 PM, Shuxin Yang wrote: >> Based on my understanding of her design, following is one obtuse >> motivating example: >> >> -------------------------- >> class A; >> class B; >> >> int foo(A* p, B* q) { >> >> p->a_int_field = 2; >> q->another_int_field = 3; >> return p->a_int_field; // !!!!! >> } >> ---------------------------------- >> >> the *-statement can be optimized into "return 2" if optimizer can prove >> type-A does not include type-B, >> and type-B does not include type-A either. >> > > And my example shows that they can alias regardless of that. Granted, it's somewhat contrived and I'm not 100% sure if it's legal. Once there are pointers, there is little that can be done without knowing at least something about what they point to.Your example should return alias with llvm's alias analysis framework. llvm's alias analysis are chained together, basic alias analysis should return alias for your example. We call TBAA when basicAA says mayalias. We let basicAA try its best to do point chasing (there is no inter procedural analysis). For Shuxin's example, if the input parameters can alias, TBAA may still return noalias. This issue exists with the current TBAA where we only annotate scalar accesses with the scalar types. -Manman> > -Krzysztof > > -- > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation