Alias set with only one element having may-alias property

Looks like missing some basics here.

Consider following test:

1 int escape(int **ptr);
2 int foo(int * ptr)
3 {
4 return escape(&ptr);
5 }

At line number 4 address of pointer passed to another routine.

When I print alias set:

Alias Set Tracker: 1 alias sets for 1 pointer values.
AliasSet[0x43be490, 2] may alias, Mod/Ref Pointers: (i32** %ptr.addr, 8)
1 Unknown instructions: i32 %call

Here ptr.addr is only in the set, and set property is may-alias.

I’m not sure it may-alias with what, if its aliasing with self then why not must-alias ?

Is may-alias indicating ptr.addr is unsafe to optimize, and it can possibly alias with something.

Regards,
Ashutosh

From: "Ashutosh via llvm-dev Nema" <llvm-dev@lists.llvm.org>
To: "llvm-dev" <llvm-dev@lists.llvm.org>
Sent: Tuesday, September 22, 2015 5:37:48 AM
Subject: [llvm-dev] Alias set with only one element having may-alias property

Looks like missing some basics here.

Consider following test:

1 int escape(int **ptr);
2 int foo(int * ptr)
3 {
4 return escape(&ptr);
5 }

At line number 4 address of pointer passed to another routine.

When I print alias set:

Alias Set Tracker: 1 alias sets for 1 pointer values.
AliasSet[0x43be490, 2] may alias, Mod/Ref Pointers: (i32** %ptr.addr,
8)
1 Unknown instructions: i32 %call

Here ptr.addr is only in the set, and set property is may-alias.

I’m not sure it may-alias with what, if its aliasing with self then
why not must-alias ?

Is may-alias indicating ptr.addr is unsafe to optimize, and it can
possibly alias with something.

Regarding optimization, this depends on how the AST is used. But, if other pointer accesses are found that might alias with %ptr.addr, then Mod/Ref seems like a default state for the alias set given the unknown behavior of 'int escape(int **ptr)'.

-Hal