Skip to content

Commit f72152a

Browse files
Add some comments and clean up some codoe
1 parent 938091d commit f72152a

File tree

4 files changed

+14
-20
lines changed

4 files changed

+14
-20
lines changed

flang/lib/Optimizer/CodeGen/CodeGen.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
5353
#include "mlir/Dialect/LLVMIR/NVVMDialect.h"
5454
#include "mlir/Dialect/LLVMIR/Transforms/AddComdats.h"
55-
#include "mlir/Dialect/LLVMIR/Transforms/OpenMPOffloadPrivatizationPrepare.h"
5655
#include "mlir/Dialect/OpenACC/OpenACC.h"
5756
#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
5857
#include "mlir/IR/BuiltinTypes.h"

mlir/lib/Dialect/LLVMIR/IR/FunctionCallUtils.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ mlir::LLVM::lookupOrCreateFn(OpBuilder &b, Operation *moduleOp, StringRef name,
6868
SymbolTableCollection *symbolTables) {
6969
assert(moduleOp->hasTrait<OpTrait::SymbolTable>() &&
7070
"expected SymbolTable operation");
71-
llvm::errs() << "Looking up " << name << "\n";
7271
auto func = lookupFuncOp(name, moduleOp, symbolTables);
7372
auto funcT = LLVMFunctionType::get(resultType, paramTypes, isVarArg);
7473
// Assert the signature of the found function is same as expected
@@ -86,7 +85,7 @@ mlir::LLVM::lookupOrCreateFn(OpBuilder &b, Operation *moduleOp, StringRef name,
8685
}
8786
return func;
8887
}
89-
llvm::errs() << "Did not find " << name << ".. creating it \n";
88+
9089
OpBuilder::InsertionGuard g(b);
9190
assert(!moduleOp->getRegion(0).empty() && "expected non-empty region");
9291
b.setInsertionPointToStart(&moduleOp->getRegion(0).front());

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

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,25 +95,21 @@ class OMPTargetPrepareDelayedPrivatizationPattern
9595
newPrivVars.push_back(privVar);
9696
continue;
9797
}
98-
// Treat the privVar as varPtr. TODO: For boxchars this likely wont be a
99-
// pointer. Allocate heap memory that corresponds to the type of memory
98+
99+
// Allocate heap memory that corresponds to the type of memory
100100
// pointed to by varPtr
101+
// TODO: For boxchars this likely wont be a pointer.
101102
mlir::Value varPtr = privVar;
102103
mlir::Value heapMem = allocateHeapMem(targetOp, privVar, mod, rewriter);
103-
if (!heapMem) {
104-
newPrivVars.push_back(privVar);
104+
if (!heapMem)
105105
return failure();
106-
}
107-
newPrivVars.push_back(heapMem);
108-
109-
// Find the earliest insertion point for the copy.
110-
111-
// Now, fix up the omp::MapInfoOp instances that use varPtr to refer
112-
// to heapMem instead.
113-
using ReplacementEntry = std::pair<Operation *, Operation *>;
114-
llvm::SmallVector<ReplacementEntry> replRecord;
115106

107+
newPrivVars.push_back(heapMem);
116108

109+
// Find the earliest insertion point for the copy. This will be before
110+
// the first in the list of omp::MapInfoOp instances that use varPtr.
111+
// After the copy these omp::MapInfoOp instances will refer to heapMem
112+
// instead.
117113
Operation *varPtrDefiningOp = varPtr.getDefiningOp();
118114
std::set<Operation *> users;
119115
users.insert(varPtrDefiningOp->user_begin(),
@@ -122,11 +118,9 @@ class OMPTargetPrepareDelayedPrivatizationPattern
122118
auto usesVarPtr = [&users](Operation *op) -> bool {
123119
return users.count(op);
124120
};
125-
126121
SmallVector<Operation *> chainOfOps;
127122
chainOfOps.push_back(mapInfoOperation);
128123
if (!mapInfoOp.getMembers().empty()) {
129-
130124
for (auto member : mapInfoOp.getMembers()) {
131125
if (usesVarPtr(member.getDefiningOp()))
132126
chainOfOps.push_back(member.getDefiningOp());
@@ -144,13 +138,15 @@ class OMPTargetPrepareDelayedPrivatizationPattern
144138
});
145139

146140
rewriter.setInsertionPoint(chainOfOps.front());
141+
// Copy the value of the local variable into the heap-allocated location.
147142
mlir::Location loc = chainOfOps.front()->getLoc();
148143
mlir::Type varType = getElemType(varPtr);
149-
// Copy the value of the local variable into the heap-allocated location.
150144
auto loadVal = rewriter.create<LLVM::LoadOp>(loc, varType, varPtr);
151145
LLVM_ATTRIBUTE_UNUSED auto storeInst =
152146
rewriter.create<LLVM::StoreOp>(loc, loadVal.getResult(), heapMem);
153147

148+
using ReplacementEntry = std::pair<Operation *, Operation *>;
149+
llvm::SmallVector<ReplacementEntry> replRecord;
154150
auto cloneAndMarkForDeletion = [&](Operation *origOp) -> Operation * {
155151
Operation *clonedOp = rewriter.clone(*origOp);
156152
rewriter.replaceAllOpUsesWith(origOp, clonedOp);

mlir/lib/Tools/mlir-opt/MlirOptMain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ LogicalResult mlir::MlirOptMain(llvm::raw_ostream &outputStream,
624624
// We use the thread-pool this context is creating, and avoid
625625
// creating any thread when disabled.
626626
MLIRContext threadPoolCtx;
627-
llvm::errs() << "threadPoolCtx.isMultithreadingEnabled() = " << threadPoolCtx.isMultithreadingEnabled() << "\n";
627+
628628
if (threadPoolCtx.isMultithreadingEnabled())
629629
threadPool = &threadPoolCtx.getThreadPool();
630630

0 commit comments

Comments
 (0)