forked from OSchip/llvm-project
[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. llvm-svn: 298192
This commit is contained in:
parent
d55e153b87
commit
7693b116a1
|
@ -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;
|
||||
|
||||
|
|
|
@ -167,11 +167,6 @@ Value *ParallelLoopGenerator::createParallelLoop(
|
|||
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::storeValuesIntoStruct(SetVector<Value *> &Values) {
|
|||
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());
|
||||
|
|
|
@ -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*
|
||||
|
|
|
@ -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]]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue