Skip to content

Commit 6288da9

Browse files
Make changes requested by reviewers - Formatting changes requested by meinersbur - Use the first heap-allocated private as fakeDependVar as suggested by tblah.
1 parent 4c5d8d8 commit 6288da9

File tree

4 files changed

+111
-116
lines changed

4 files changed

+111
-116
lines changed

mlir/include/mlir/Dialect/OpenMP/Transforms/OpenMPOffloadPrivatizationPrepare.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- OpenMPOffloadPrivatizationPrepare.h -*- C++ -*-===//
1+
//===- OpenMPOffloadPrivatizationPrepare.h ----------------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

mlir/include/mlir/Dialect/OpenMP/Transforms/Passes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===- Passes.h - LLVM Pass Construction and Registration -----------------===//
1+
//===- Passes.h - LLVM Pass Construction and Registration -------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

mlir/lib/Dialect/OpenMP/Transforms/OpenMPOffloadPrivatizationPrepare.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,17 +121,10 @@ class PrepareForOMPOffloadPrivatizationPass
121121
// /*cleanup_code*/
122122
// omp.terminator
123123
// }
124+
// fakeDependVar is the address of the first heap-allocated copy of the
125+
// host variable being privatized.
126+
124127
bool needsCleanupTask = !privatizer.getDeallocRegion().empty();
125-
if (needsCleanupTask && !fakeDependVar) {
126-
Region *targetParentRegion = targetOp->getParentRegion();
127-
rewriter.setInsertionPointToStart(&*targetParentRegion->begin());
128-
Location loc = targetParentRegion->getLoc();
129-
Type i32Ty = rewriter.getI32Type();
130-
Type llvmPtrTy = LLVM::LLVMPointerType::get(targetOp->getContext());
131-
Value constOne = rewriter.create<LLVM::ConstantOp>(loc, i32Ty, 1);
132-
fakeDependVar =
133-
LLVM::AllocaOp::create(rewriter, loc, llvmPtrTy, i32Ty, constOne);
134-
}
135128

136129
// Allocate heap memory that corresponds to the type of memory
137130
// pointed to by varPtr
@@ -153,6 +146,9 @@ class PrepareForOMPOffloadPrivatizationPass
153146
"a private variable out of the stack and into the "
154147
"heap for use by a deferred target task");
155148

149+
if (needsCleanupTask && !fakeDependVar)
150+
fakeDependVar = heapMem;
151+
156152
// The types of private vars should match before and after the
157153
// transformation. In particular, if the type is a pointer,
158154
// simply record the newly allocated malloc location as the

0 commit comments

Comments
 (0)