[polly] r305675 - [CodeGen] Emit aliasing metadata for new arrays.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 19 03:19:29 PDT 2017


Author: meinersbur
Date: Mon Jun 19 05:19:29 2017
New Revision: 305675

URL: http://llvm.org/viewvc/llvm-project?rev=305675&view=rev
Log:
[CodeGen] Emit aliasing metadata for new arrays.

Ensure that all array base pointers are assigned before generating
aliasing metadata by allocating new arrays beforehand.

Before this patch, getBasePtr() returned nullptr for new arrays because
the arrays were created at a later point. Nullptr did not match to any
array after the created array base pointers have been assigned and when
the loads/stores are generated.

Modified:
    polly/trunk/lib/CodeGen/CodeGeneration.cpp
    polly/trunk/lib/CodeGen/IRBuilder.cpp
    polly/trunk/test/Isl/CodeGen/MemAccess/create_arrays.ll
    polly/trunk/test/ScheduleOptimizer/pattern-matching-based-opts_10.ll

Modified: polly/trunk/lib/CodeGen/CodeGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/CodeGeneration.cpp?rev=305675&r1=305674&r2=305675&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/CodeGeneration.cpp (original)
+++ polly/trunk/lib/CodeGen/CodeGeneration.cpp Mon Jun 19 05:19:29 2017
@@ -162,7 +162,6 @@ static bool CodeGen(Scop &S, IslAstInfo
   assert(!R->isTopLevelRegion() && "Top level regions are not supported");
 
   ScopAnnotator Annotator;
-  Annotator.buildAliasScopes(S);
 
   simplifyRegion(R, &DT, &LI, &RI);
   assert(R->isSimple());
@@ -183,6 +182,11 @@ static bool CodeGen(Scop &S, IslAstInfo
 
   IslNodeBuilder NodeBuilder(Builder, Annotator, DL, LI, SE, DT, S, StartBlock);
 
+  // All arrays must have their base pointers known before
+  // ScopAnnotator::buildAliasScopes.
+  NodeBuilder.allocateNewArrays();
+  Annotator.buildAliasScopes(S);
+
   if (PerfMonitoring) {
     PerfMonitor P(S, EnteringBB->getParent()->getParent());
     P.initialize();
@@ -224,7 +228,6 @@ static bool CodeGen(Scop &S, IslAstInfo
 
     isl_ast_node_free(AstRoot);
   } else {
-    NodeBuilder.allocateNewArrays();
     NodeBuilder.addParameters(S.getContext());
     Value *RTC = NodeBuilder.createRTC(AI.getRunCondition());
 

Modified: polly/trunk/lib/CodeGen/IRBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/IRBuilder.cpp?rev=305675&r1=305674&r2=305675&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/IRBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/IRBuilder.cpp Mon Jun 19 05:19:29 2017
@@ -67,10 +67,12 @@ void ScopAnnotator::buildAliasScopes(Sco
     return;
 
   std::string AliasScopeStr = "polly.alias.scope.";
-  for (const ScopArrayInfo *Array : S.arrays())
+  for (const ScopArrayInfo *Array : S.arrays()) {
+    assert(Array->getBasePtr() && "Base pointer must be present");
     AliasScopeMap[Array->getBasePtr()] =
         getID(Ctx, AliasScopeDomain,
               MDString::get(Ctx, (AliasScopeStr + Array->getName()).c_str()));
+  }
 
   for (const ScopArrayInfo *Array : S.arrays()) {
     MDNode *AliasScopeList = MDNode::get(Ctx, {});

Modified: polly/trunk/test/Isl/CodeGen/MemAccess/create_arrays.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/MemAccess/create_arrays.ll?rev=305675&r1=305674&r2=305675&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/MemAccess/create_arrays.ll (original)
+++ polly/trunk/test/Isl/CodeGen/MemAccess/create_arrays.ll Mon Jun 19 05:19:29 2017
@@ -29,6 +29,18 @@
 ; CODEGEN:  %polly.access.cast.E = bitcast [270336 x [200000 x double]]* %E to double*
 ; CODEGEN:  %polly.access.mul.E = mul nsw i64 %polly.indvar33, 200000
 ; CODEGEN:  %polly.access.add.E = add nsw i64 %polly.access.mul.E, %polly.indvar
+; CODEGEN:  {{%.*}} = load double, double* %polly.access.E, align 8, !alias.scope [[TAG0:![0-9]+]], !noalias [[TAG2:![0-9]+]]
+; CODEGEN:  store double {{%.*}}, double* %scevgep36, align 8, !alias.scope [[TAG5:![0-9]+]], !noalias [[TAG8:![0-9]+]]
+;
+; CODEGEN-DAG: [[TAG0]] = distinct !{[[TAG0]], [[TAG1:![0-9]+]], !"polly.alias.scope.E"}
+; CODEGEN-DAG: [[TAG1]] = distinct !{[[TAG1]], !"polly.alias.scope.domain"}
+; CODEGEN-DAG: [[TAG2]] = !{[[TAG3:![0-9]+]], [[TAG4:![0-9]+]], [[TAG5:![0-9]+]], [[TAG6:![0-9]+]], [[TAG7:![0-9]+]]}
+; CODEGEN-DAG: [[TAG3]] = distinct !{[[TAG3]], [[TAG1]], !"polly.alias.scope.MemRef_B"}
+; CODEGEN-DAG: [[TAG4]] = distinct !{[[TAG4]], [[TAG1]], !"polly.alias.scope.MemRef_beta"}
+; CODEGEN-DAG: [[TAG5]] = distinct !{[[TAG5]], [[TAG1]], !"polly.alias.scope.MemRef_A"}
+; CODEGEN-DAG: [[TAG6]] = distinct !{[[TAG6]], [[TAG1]], !"polly.alias.scope.D"}
+; CODEGEN-DAG: [[TAG7]] = distinct !{[[TAG7]], [[TAG1]], !"polly.alias.scope.F"}
+; CODEGEN-DAG: [[TAG8]] = !{[[TAG3]], [[TAG4]], [[TAG6]], [[TAG0]], [[TAG7]]}
 ;
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-unknown"

Modified: polly/trunk/test/ScheduleOptimizer/pattern-matching-based-opts_10.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScheduleOptimizer/pattern-matching-based-opts_10.ll?rev=305675&r1=305674&r2=305675&view=diff
==============================================================================
--- polly/trunk/test/ScheduleOptimizer/pattern-matching-based-opts_10.ll (original)
+++ polly/trunk/test/ScheduleOptimizer/pattern-matching-based-opts_10.ll Mon Jun 19 05:19:29 2017
@@ -12,14 +12,14 @@
 ; This test case checks whether Polly generates second level alias metadata
 ; to distinguish the specific accesses in case of the ublas gemm kernel.
 ;
-; CHECK: %tmp22_p_scalar_{{[0-9]*}} = load double, double* %scevgep[[N0:[a-z_0-9]*]], align 8, !alias.scope !10, !noalias !2
-; CHECK: store double %p_tmp23{{[0-9]*}}, double* %scevgep[[N0]], align 8, !alias.scope !10, !noalias !2
-; CHECK: %tmp22_p_scalar_{{[0-9]*}} = load double, double* %scevgep[[N1:[a-z_0-9]*]], align 8, !alias.scope !11, !noalias !12
-; CHECK: store double %p_tmp23{{[0-9]*}}, double* %scevgep[[N1]], align 8, !alias.scope !11, !noalias !12
-; CHECK: %tmp22_p_scalar_{{[0-9]*}} = load double, double* %scevgep[[N2:[a-z_0-9]*]], align 8, !alias.scope !13, !noalias !14
-; CHECK: store double %p_tmp23{{[0-9]*}}, double* %scevgep[[N2]], align 8, !alias.scope !13, !noalias !14
-; CHECK: %tmp22_p_scalar_{{[0-9]*}} = load double, double* %scevgep[[N3:[a-z_0-9]*]], align 8, !alias.scope !15, !noalias !16
-; CHECK: store double %p_tmp23{{[0-9]*}}, double* %scevgep[[N3]], align 8, !alias.scope !15, !noalias !16
+; CHECK: %tmp22_p_scalar_{{[0-9]*}} = load double, double* %scevgep[[N0:[a-z_0-9]*]], align 8
+; CHECK: store double %p_tmp23{{[0-9]*}}, double* %scevgep[[N0]], align 8
+; CHECK: %tmp22_p_scalar_{{[0-9]*}} = load double, double* %scevgep[[N1:[a-z_0-9]*]], align 8
+; CHECK: store double %p_tmp23{{[0-9]*}}, double* %scevgep[[N1]], align 8
+; CHECK: %tmp22_p_scalar_{{[0-9]*}} = load double, double* %scevgep[[N2:[a-z_0-9]*]], align 8
+; CHECK: store double %p_tmp23{{[0-9]*}}, double* %scevgep[[N2]], align 8
+; CHECK: %tmp22_p_scalar_{{[0-9]*}} = load double, double* %scevgep[[N3:[a-z_0-9]*]], align 8
+; CHECK: store double %p_tmp23{{[0-9]*}}, double* %scevgep[[N3]], align 8
 ;
 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-unknown"




More information about the llvm-commits mailing list