[PollyIRBuilder] Bound size of alias metadata
authorTobias Grosser <tobias@grosser.es>
Mon, 3 Apr 2017 07:42:50 +0000 (07:42 +0000)
committerTobias Grosser <tobias@grosser.es>
Mon, 3 Apr 2017 07:42:50 +0000 (07:42 +0000)
No-alias metadata grows quadratic in the size of arrays involved, which can
become very costly for large programs. This commit bounds the number of arrays
for which we construct no-alias information to ten. This is conservatively
correct, as we just provide less information to LLVM and speeds up the compile
time of one of my internal test cases from 'does-not-terminate' to
'finishes-in-less-than-a-minute'. In the future we might try to be more clever
here, but this change should provide a good baseline.

llvm-svn: 299352

polly/lib/CodeGen/IRBuilder.cpp

index 1077515..a8fb1fd 100644 (file)
@@ -21,6 +21,8 @@
 using namespace llvm;
 using namespace polly;
 
+static const int MaxArraysInAliasScops = 10;
+
 /// Get a self referencing id metadata node.
 ///
 /// The MDNode looks like this (if arg0/arg1 are not null):
@@ -58,6 +60,12 @@ void ScopAnnotator::buildAliasScopes(Scop &S) {
   AliasScopeMap.clear();
   OtherAliasScopeListMap.clear();
 
+  // The construction of alias scopes is quadratic in the number of arrays
+  // involved. In case of too many arrays, skip the construction of alias
+  // information to avoid quadratic increases in compile time and code size.
+  if (std::distance(S.array_begin(), S.array_end()) > MaxArraysInAliasScops)
+    return;
+
   std::string AliasScopeStr = "polly.alias.scope.";
   for (const ScopArrayInfo *Array : S.arrays())
     AliasScopeMap[Array->getBasePtr()] =