ramshankar r via llvm-dev
2020-Jul-06 16:18 UTC
[llvm-dev] Question about basic-aa's assumptions
Hi, I have a test-case for which I seem to be getting incorrect information from basic-aa alias-analysis. Here it is: #include <stdio.h> #define ARR_SIZE 4 char c[ARR_SIZE]; char *pc[ARR_SIZE]; char **ppc = pc; int main() { pc[0] = &c[0]; pc[1] = &c[1]; pc[2] = &c[2]; pc[3] = &c[3]; printf(" ppc: %p\n" " pc : %p\n" " c : %p\n" " *pc: %p\n", ppc, pc, c, *pc); return 0; } The way I compiled it is as follows: clang -m32 -g pointer.c -emit-llvm -S -c opt pointer.ll -aa-pipeline=basic-aa -passes=aa-eval -print-all-alias-modref-info -disable-output The result from the AA-Evaluator prints this: NoAlias: i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @pc, i32 0, i32 0), i8*** @ppc If we run the program, the result is this: ppc: 0x565ee028 pc : 0x565ee028 c : 0x565ee024 *pc: 0x565ee024 Basically, I would have liked if basic-aa said ppc and pc are may-aliased to start with for this kind of usage. This is how the globals look like. The second one: "ppc" has "pc" on the right hand side. @pc = common dso_local global [4 x i8*] zeroinitializer, align 4, !dbg !0 @ppc = dso_local global i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @pc, i32 0, i32 0), align 4, !dbg !6 Best regards, Ram -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200706/768d0c58/attachment.html>
ramshankar r via llvm-dev
2020-Jul-07 16:15 UTC
[llvm-dev] Question about basic-aa's assumptions
Any takers on this? Best, Ram On Mon, Jul 6, 2020 at 12:18 PM ramshankar r <ramshankar543 at gmail.com> wrote:> Hi, > > I have a test-case for which I seem to be getting incorrect information > from basic-aa alias-analysis. Here it is: > #include <stdio.h> > #define ARR_SIZE 4 > char c[ARR_SIZE]; > char *pc[ARR_SIZE]; > char **ppc = pc; > > int main() { > > pc[0] = &c[0]; > pc[1] = &c[1]; > pc[2] = &c[2]; > pc[3] = &c[3]; > > printf(" ppc: %p\n" > " pc : %p\n" > " c : %p\n" > " *pc: %p\n", > ppc, pc, c, *pc); > > return 0; > } > > The way I compiled it is as follows: > clang -m32 -g pointer.c -emit-llvm -S -c > opt pointer.ll -aa-pipeline=basic-aa -passes=aa-eval > -print-all-alias-modref-info -disable-output > > The result from the AA-Evaluator prints this: > NoAlias: i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @pc, i32 0, > i32 0), i8*** @ppc > > If we run the program, the result is this: > ppc: 0x565ee028 > pc : 0x565ee028 > c : 0x565ee024 > *pc: 0x565ee024 > > Basically, I would have liked if basic-aa said ppc and pc are may-aliased > to start with for this kind of usage. This is how the globals look like. > The second one: "ppc" has "pc" on the right hand side. > > @pc = common dso_local global [4 x i8*] zeroinitializer, align 4, !dbg !0 > @ppc = dso_local global i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* > @pc, i32 0, i32 0), align 4, !dbg !6 > > Best regards, > Ram >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200707/570ea0b8/attachment.html>
Johannes Doerfert via llvm-dev
2020-Jul-07 16:49 UTC
[llvm-dev] Question about basic-aa's assumptions
On 7/6/20 11:18 AM, ramshankar r via llvm-dev wrote:> Hi, > > I have a test-case for which I seem to be getting incorrect information > from basic-aa alias-analysis. Here it is: > #include <stdio.h> > #define ARR_SIZE 4 > char c[ARR_SIZE]; > char *pc[ARR_SIZE]; > char **ppc = pc; > > int main() { > > pc[0] = &c[0]; > pc[1] = &c[1]; > pc[2] = &c[2]; > pc[3] = &c[3]; > > printf(" ppc: %p\n" > " pc : %p\n" > " c : %p\n" > " *pc: %p\n", > ppc, pc, c, *pc); > > return 0; > } > > The way I compiled it is as follows: > clang -m32 -g pointer.c -emit-llvm -S -c > opt pointer.ll -aa-pipeline=basic-aa -passes=aa-eval > -print-all-alias-modref-info -disable-output > > The result from the AA-Evaluator prints this: > NoAlias: i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @pc, i32 0, > i32 0), i8*** @ppcIsn't this talking about `&pc[0]` and `&ppc`? If so, NoAlias seems reasonable to me. I mean, you print the value of `ppc` and `pc` while the above talks about the addresses of these. (I'm a bit tired so take this as a potential answer only.) ~ Johannes> If we run the program, the result is this: > ppc: 0x565ee028 > pc : 0x565ee028 > c : 0x565ee024 > *pc: 0x565ee024 > > Basically, I would have liked if basic-aa said ppc and pc are may-aliased > to start with for this kind of usage. This is how the globals look like. > The second one: "ppc" has "pc" on the right hand side. > > @pc = common dso_local global [4 x i8*] zeroinitializer, align 4, !dbg !0 > @ppc = dso_local global i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* > @pc, i32 0, i32 0), align 4, !dbg !6 > > Best regards, > Ram > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200707/7e400d67/attachment.html>
Jeroen Dobbelaere via llvm-dev
2020-Jul-08 07:14 UTC
[llvm-dev] Question about basic-aa's assumptions
Hi Ramshankar, giving it a try:> The result from the AA-Evaluator prints this: > NoAlias: i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @pc, i32 0, i32 0), i8*** @ppc- the first is an 'i8**' (the address of pc), - the second 'i8***' (aka the address of ppc.) Those represent two different objects. Greetings, Jeroen Dobbelaere From: llvm-dev <llvm-dev-bounces at lists.llvm.org> On Behalf Of ramshankar r via llvm-dev Sent: Tuesday, July 7, 2020 18:16 To: llvm-dev at lists.llvm.org Subject: Re: [llvm-dev] Question about basic-aa's assumptions Any takers on this? Best, Ram On Mon, Jul 6, 2020 at 12:18 PM ramshankar r <ramshankar543 at gmail.com<mailto:ramshankar543 at gmail.com>> wrote: Hi, I have a test-case for which I seem to be getting incorrect information from basic-aa alias-analysis. Here it is: #include <stdio.h> #define ARR_SIZE 4 char c[ARR_SIZE]; char *pc[ARR_SIZE]; char **ppc = pc; int main() { pc[0] = &c[0]; pc[1] = &c[1]; pc[2] = &c[2]; pc[3] = &c[3]; printf(" ppc: %p\n" " pc : %p\n" " c : %p\n" " *pc: %p\n", ppc, pc, c, *pc); return 0; } The way I compiled it is as follows: clang -m32 -g pointer.c -emit-llvm -S -c opt pointer.ll -aa-pipeline=basic-aa -passes=aa-eval -print-all-alias-modref-info -disable-output The result from the AA-Evaluator prints this: NoAlias: i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @pc, i32 0, i32 0), i8*** @ppc If we run the program, the result is this: ppc: 0x565ee028 pc : 0x565ee028 c : 0x565ee024 *pc: 0x565ee024 Basically, I would have liked if basic-aa said ppc and pc are may-aliased to start with for this kind of usage. This is how the globals look like. The second one: "ppc" has "pc" on the right hand side. @pc = common dso_local global [4 x i8*] zeroinitializer, align 4, !dbg !0 @ppc = dso_local global i8** getelementptr inbounds ([4 x i8*], [4 x i8*]* @pc, i32 0, i32 0), align 4, !dbg !6 Best regards, Ram -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200708/3f98c00f/attachment.html>
Apparently Analagous Threads
- (BasicAA) PartialAlias between different fields of a structure, intentional?
- [LLVMdev] info on coming out of SSA form
- [LLVMdev] info on coming out of SSA form
- (BasicAA) PartialAlias between different fields of a structure, intentional?
- [LLVMdev] proof of concept for a loop fusion pass