Fix AddAliasScopeMetadata to not add scopes when deriving from unknown pointers
authorHal Finkel <hfinkel@anl.gov>
Sat, 30 Aug 2014 12:48:33 +0000 (12:48 +0000)
committerHal Finkel <hfinkel@anl.gov>
Sat, 30 Aug 2014 12:48:33 +0000 (12:48 +0000)
commitbd896c1b25395ab2d304229b311bda148d38b629
tree69fcac8a00ad54d890d49edb2e6cde937ac86b07
parentb265e6f1b61d5999bd4426de145373ff630f51cd
Fix AddAliasScopeMetadata to not add scopes when deriving from unknown pointers

The previous implementation of AddAliasScopeMetadata, which adds noalias
metadata to preserve noalias parameter attribute information when inlining had
a flaw: it would add alias.scope metadata to accesses which might have been
derived from pointers other than noalias function parameters. This was
incorrect because even some access known not to alias with all noalias function
parameters could easily alias with an access derived from some other pointer.
Instead, when deriving from some unknown pointer, we cannot add alias.scope
metadata at all. This fixes a miscompile of the test-suite's tramp3d-v4.
Furthermore, we cannot add alias.scope to functions unless we know they
access only argument-derived pointers (currently, we know this only for
memory intrinsics).

Also, we fix a theoretical problem with using the NoCapture attribute to skip
the capture check. This is incorrect (as explained in the comment added), but
would not matter in any code generated by Clang because we get only inferred
nocapture attributes in Clang-generated IR.

This functionality is not yet enabled by default.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216818 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/InlineFunction.cpp
test/Transforms/Inline/noalias-calls.ll