[polly] r298192 - [OpenMP] Do not emit lifetime markers for context

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 18 13:10:08 PDT 2017


Author: grosser
Date: Sat Mar 18 15:10:07 2017
New Revision: 298192

URL: http://llvm.org/viewvc/llvm-project?rev=298192&view=rev
Log:
[OpenMP] Do not emit lifetime markers for context

In commit r219005 lifetime markers have been introduced to mark the lifetime of
the OpenMP context data structure. However, their use seems incorrect and
recently caused a miscompile in ASC_Sequoia/CrystalMk after r298053 which was
not at all related to r298053. r298053 only caused a change in the loop order,
as this change resulted in a different isl internal representation which caused
the scheduler to derive a different schedule. This change then caused the IR to
change, which apparently created a pattern in which LLVM exploites the lifetime
markers. It seems we are using the OpenMP context outside of the lifetime
markers. Even though CrystalMk could probably be fixed by expanding the scope of
the lifetime markers, it is not clear what happens in case the OpenMP function
call is in a loop which will cause a sequence of starting and ending lifetimes.
As it is unlikely that the lifetime markers give any performance benefit, we
just drop them to remove complexity.

Modified:
    polly/trunk/include/polly/CodeGen/LoopGenerators.h
    polly/trunk/lib/CodeGen/LoopGenerators.cpp
    polly/trunk/test/Isl/CodeGen/OpenMP/loop-body-references-outer-values.ll
    polly/trunk/test/Isl/CodeGen/OpenMP/loop-bounds-reference-outer-ids.ll
    polly/trunk/test/Isl/CodeGen/OpenMP/single_loop.ll

Modified: polly/trunk/include/polly/CodeGen/LoopGenerators.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/LoopGenerators.h?rev=298192&r1=298191&r2=298192&view=diff
==============================================================================
--- polly/trunk/include/polly/CodeGen/LoopGenerators.h (original)
+++ polly/trunk/include/polly/CodeGen/LoopGenerators.h Sat Mar 18 15:10:07 2017
@@ -101,7 +101,7 @@ public:
   /// Create a parallel loop generator for the current function.
   ParallelLoopGenerator(PollyIRBuilder &Builder, Pass *P, LoopInfo &LI,
                         DominatorTree &DT, const DataLayout &DL)
-      : Builder(Builder), P(P), LI(LI), DT(DT), DL(DL),
+      : Builder(Builder), P(P), LI(LI), DT(DT),
         LongType(
             Type::getIntNTy(Builder.getContext(), DL.getPointerSizeInBits())),
         M(Builder.GetInsertBlock()->getParent()->getParent()) {}
@@ -140,9 +140,6 @@ private:
   /// The dominance tree of the current function we need to update.
   DominatorTree &DT;
 
-  /// The target layout to get the right size for types.
-  const DataLayout &DL;
-
   /// The type of a "long" on this hardware used for backend calls.
   Type *LongType;
 

Modified: polly/trunk/lib/CodeGen/LoopGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/LoopGenerators.cpp?rev=298192&r1=298191&r2=298192&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/LoopGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/LoopGenerators.cpp Sat Mar 18 15:10:07 2017
@@ -167,11 +167,6 @@ Value *ParallelLoopGenerator::createPara
   Builder.CreateCall(SubFn, SubFnParam);
   createCallJoinThreads();
 
-  // Mark the end of the lifetime for the parameter struct.
-  Type *Ty = Struct->getType();
-  ConstantInt *SizeOf = Builder.getInt64(DL.getTypeAllocSize(Ty));
-  Builder.CreateLifetimeEnd(Struct, SizeOf);
-
   return IV;
 }
 
@@ -294,10 +289,6 @@ ParallelLoopGenerator::storeValuesIntoSt
   StructType *Ty = StructType::get(Builder.getContext(), Members);
   AllocaInst *Struct = new AllocaInst(Ty, nullptr, "polly.par.userContext", IP);
 
-  // Mark the start of the lifetime for the parameter struct.
-  ConstantInt *SizeOf = Builder.getInt64(DL.getTypeAllocSize(Ty));
-  Builder.CreateLifetimeStart(Struct, SizeOf);
-
   for (unsigned i = 0; i < Values.size(); i++) {
     Value *Address = Builder.CreateStructGEP(Ty, Struct, i);
     Address->setName("polly.subfn.storeaddr." + Values[i]->getName());

Modified: polly/trunk/test/Isl/CodeGen/OpenMP/loop-body-references-outer-values.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/OpenMP/loop-body-references-outer-values.ll?rev=298192&r1=298191&r2=298192&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/OpenMP/loop-body-references-outer-values.ll (original)
+++ polly/trunk/test/Isl/CodeGen/OpenMP/loop-body-references-outer-values.ll Sat Mar 18 15:10:07 2017
@@ -15,8 +15,6 @@
 ; AST:   Stmt_for_body(c0);
 
 ; IR-LABEL: polly.parallel.for:
-; IR-NEXT:  %0 = bitcast { float* }* %polly.par.userContext to i8*
-; IR-NEXT:  call void @llvm.lifetime.start(i64 8, i8* %0)
 ; IR-NEXT:  %polly.subfn.storeaddr.A = getelementptr inbounds { float* }, { float* }* %polly.par.userContext, i32 0, i32 0
 ; IR-NEXT:  store float* %A, float** %polly.subfn.storeaddr.A
 ; IR-NEXT:  %polly.par.userContext1 = bitcast { float* }* %polly.par.userContext to i8*

Modified: polly/trunk/test/Isl/CodeGen/OpenMP/loop-bounds-reference-outer-ids.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/OpenMP/loop-bounds-reference-outer-ids.ll?rev=298192&r1=298191&r2=298192&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/OpenMP/loop-bounds-reference-outer-ids.ll (original)
+++ polly/trunk/test/Isl/CodeGen/OpenMP/loop-bounds-reference-outer-ids.ll Sat Mar 18 15:10:07 2017
@@ -23,9 +23,7 @@
 ; AST:       Stmt_for_body6(c0, c1, c2);
 
 ; IR:      %polly.par.userContext = alloca { i64, i64 }
-; IR:      %[[R0:[0-9a-z.]+]] = bitcast { i64, i64 }* %polly.par.userContext to i8*
-; IR-NEXT: call void @llvm.lifetime.start(i64 16, i8* %[[R0]])
-; IR-NEXT: %[[R1:[0-9a-z.]+]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* %polly.par.userContext, i32 0, i32 0
+; IR: %[[R1:[0-9a-z.]+]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* %polly.par.userContext, i32 0, i32 0
 ; IR-NEXT: store i64 %n, i64* %[[R1]]
 ; IR-NEXT: %[[R2:[0-9a-z.]+]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* %polly.par.userContext, i32 0, i32 1
 ; IR-NEXT: store i64 %polly.indvar, i64* %[[R2]]

Modified: polly/trunk/test/Isl/CodeGen/OpenMP/single_loop.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/OpenMP/single_loop.ll?rev=298192&r1=298191&r2=298192&view=diff
==============================================================================
--- polly/trunk/test/Isl/CodeGen/OpenMP/single_loop.ll (original)
+++ polly/trunk/test/Isl/CodeGen/OpenMP/single_loop.ll Sat Mar 18 15:10:07 2017
@@ -31,17 +31,13 @@
 ; IR-NEXT:   %polly.par.userContext = alloca
 
 ; IR-LABEL: polly.parallel.for:
-; IR-NEXT:   %0 = bitcast {}* %polly.par.userContext to i8*
-; IR-NEXT:   call void @llvm.lifetime.start(i64 0, i8* %0)
 ; IR-NEXT:   %polly.par.userContext1 = bitcast {}* %polly.par.userContext to i8*
 ; IR-NEXT:   call void @GOMP_parallel_loop_runtime_start(void (i8*)* @single_parallel_loop_polly_subfn, i8* %polly.par.userContext1, i32 0, i64 0, i64 1024, i64 1)
 ; IR-NEXT:   call void @single_parallel_loop_polly_subfn(i8* %polly.par.userContext1)
 ; IR-NEXT:   call void @GOMP_parallel_end()
-; IR-NEXT:   %1 = bitcast {}* %polly.par.userContext to i8*
-; IR-NEXT:   call void @llvm.lifetime.end(i64 8, i8* %1)
 ; IR-NEXT:   br label %polly.exiting
 
-; IR: define internal void @single_parallel_loop_polly_subfn(i8* %polly.par.userContext) #2
+; IR: define internal void @single_parallel_loop_polly_subfn(i8* %polly.par.userContext) #1
 ; IR-LABEL: polly.par.setup:
 ; IR-NEXT:   %polly.par.LBPtr = alloca i64
 ; IR-NEXT:   %polly.par.UBPtr = alloca i64
@@ -81,7 +77,7 @@
 ; IR-LABEL: polly.loop_preheader:
 ; IR-NEXT:   br label %polly.loop_header
 
-; IR: attributes #2 = { "polly.skip.fn" }
+; IR: attributes #1 = { "polly.skip.fn" }
 
 ; IR-STRIDE4:   call void @GOMP_parallel_loop_runtime_start(void (i8*)* @single_parallel_loop_polly_subfn, i8* %polly.par.userContext1, i32 0, i64 0, i64 1024, i64 4)
 ; IR-STRIDE4:  add nsw i64 %polly.indvar, 3




More information about the llvm-commits mailing list