Hi all,
Are you sure that the problem here is with the nocapture flag and not with the noalias?
Removing noalias from the function definition of @f results in the expected output.
My guess is that something goes wrong in determining that *%q can be based on %p through @g which results in a 'no alias' relation for the two where there should be a 'may alias' result.
For example, the original version produces the following:
$ opt test.ll -basicaa -print-alias-sets -disable-output
Alias Set Tracker: 2 alias sets for 3 pointer values.
AliasSet[0x9e22028, 2] may alias, Mod/Ref Pointers: (i32** %q, 18446744073709551615), (i32* %0, 18446744073709551615)
1 Unknown instructions: void <badref>
AliasSet[0x9e22868, 1] must alias, Mod/Ref Pointers: (i32* %p, 18446744073709551615)
Whereas the version without 'noalias' attribute produces the following:
$ opt test.ll -basicaa -print-alias-sets -disable-output
Alias Set Tracker: 1 alias sets for 3 pointer values.
AliasSet[0x97db018, 3] may alias, Mod/Ref Pointers: (i32* %p, 18446744073709551615), (i32** %q, 18446744073709551615), (i32* %0, 18446744073709551615)
1 Unknown instructions: void <badref>
Cheers,
Roel