ScopDetection: Improve printing of alias sets

We now show the all members of the alias set that may couse possible aliasing.
In case a alias set member is not a named instruction (unnamed instructions or
constant expressions), we show the expression itself.

This improves our error message

from:

  Possible aliasing for value: .reg2mem

to:

  Possible aliasing: ".reg2mem",
                     "[0 x double]* inttoptr (i64 47255179264 to [0 x double]*)

llvm-svn: 174329
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index d7f75b0..be7feeef 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -277,10 +277,38 @@
   // references which seem to 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() && !IgnoreAliasing)
-    INVALID_NOVERIFY(Alias,
-                     "Possible aliasing for value: " << BaseValue->getName()
-                     << "\n");
+  if (!AS.isMustAlias() && !IgnoreAliasing) {
+    std::string Message;
+    raw_string_ostream OS(Message);
+
+    OS << "Possible aliasing: ";
+
+    std::vector<Value*> Pointers;
+
+    for (AliasSet::iterator AI = AS.begin(), AE = AS.end(); AI != AE; ++AI)
+      Pointers.push_back(AI.getPointer());
+
+    std::sort(Pointers.begin(), Pointers.end());
+
+    for (std::vector<Value*>::iterator PI = Pointers.begin(),
+         PE = Pointers.end();;) {
+      Value *V = *PI;
+
+      if (V->getName().size() == 0)
+        OS << "\"" << *V << "\"";
+      else
+        OS << "\"" << V->getName() << "\"";
+
+      ++PI;
+
+      if (PI != PE)
+        OS << ", ";
+      else
+        break;
+    }
+
+    INVALID_NOVERIFY(Alias, OS.str())
+  }
 
   return true;
 }