[PATCH 03/11] Record a pointer to the AliasSet

Andreas Simbuerger simbuerg at googlemail.com
Sun Jun 8 17:42:25 PDT 2014


Instead of taking the pointer of the AliasSet reference we directly
retreive a pointer from the AliasSetTracker. This gives us a pointer
that should be valid at least until the ScopDetection is destroyed.
---
 lib/Analysis/ScopDetection.cpp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/lib/Analysis/ScopDetection.cpp b/lib/Analysis/ScopDetection.cpp
index cab7af7..fbaf07c 100644
--- a/lib/Analysis/ScopDetection.cpp
+++ b/lib/Analysis/ScopDetection.cpp
@@ -471,8 +471,15 @@ bool ScopDetection::isValidMemoryAccess(Instruction &Inst,
   // alias, if -basicaa is not available. They actually do not, but as we can
   // not proof this without -basicaa we would fail. We disable this check to
   // not cause irrelevant verification failures.
-  if (!AS.isMustAlias())
-    return invalid<ReportAlias>(Context, /*Assert=*/true, &Inst, &AS);
+  if (!AS.isMustAlias()) {
+    // If we want to be able to use this for diagnostics outside of
+    // ScopDetection, we need to fetch the AliasSet as a pointer as soon as it
+    // is created above.
+    AliasSet *ASPtr = Context.AST.getAliasSetForPointerIfExists(
+        BaseValue, AliasAnalysis::UnknownSize,
+        Inst.getMetadata(LLVMContext::MD_tbaa));
+    return invalid<ReportAlias>(Context, /*Assert=*/false, &Inst, ASPtr);
+  }
 
   return true;
 }
-- 
2.0.0




More information about the llvm-commits mailing list