-
-
Save nikic/d900c8b2e901fc9c3ab1eb30650af9c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp | |
index c69ca70db91d..8e7f9ba4f717 100644 | |
--- a/llvm/lib/Transforms/Utils/InlineFunction.cpp | |
+++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp | |
@@ -1079,7 +1079,8 @@ static void AddAliasScopeMetadata(CallBase &CB, ValueToValueMapTy &VMap, | |
// Figure out if we're derived from anything that is not a noalias | |
// argument. | |
- bool RequiresNoCaptureBefore = false, UsesAliasingPtr = false; | |
+ bool RequiresNoCaptureBefore = false, UsesAliasingPtr = false, | |
+ UsesUnknownObject = false; | |
for (const Value *V : ObjSet) { | |
// Is this value a constant that cannot be derived from any pointer | |
// value (we need to exclude constant expressions, for example, that | |
@@ -1100,14 +1101,24 @@ static void AddAliasScopeMetadata(CallBase &CB, ValueToValueMapTy &VMap, | |
UsesAliasingPtr = true; | |
} | |
- // If this is not some identified function-local object (which cannot | |
- // directly alias a noalias argument), or some other argument (which, | |
- // by definition, also cannot alias a noalias argument), then we could | |
- // alias a noalias argument that has been captured). | |
- if (!isa<Argument>(V) && !isIdentifiedFunctionLocal(V)) | |
+ if (isEscapeSource(V)) { | |
+ // An escape source can only alias with a noalias argument if it has | |
+ // been captured beforehand. | |
RequiresNoCaptureBefore = true; | |
+ } else if (!isa<Argument>(V) && !isIdentifiedObject(V)) { | |
+ // If this is neither an escape source, nor some identified object | |
+ // (which cannot directly alias a noalias argument), nor some other | |
+ // argument (which, by definition, also cannot alias a noalias | |
+ // argument), conservatively do not make any assumptions. | |
+ UsesUnknownObject = true; | |
+ } | |
} | |
+ // Nothing we can do if the used underlying object cannot be reliably | |
+ // determined. | |
+ if (UsesUnknownObject) | |
+ continue; | |
+ | |
// A function call can always get captured noalias pointers (via other | |
// parameters, globals, etc.). | |
if (IsFuncCall && !IsArgMemOnlyCall) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment