[Mlir-commits] [mlir] b85cfe2 - [OpenMP][IRBuilder] Change the default constructor for OpenMPIRBuilder::LocationDescription
Shraiysh Vaishay
llvmlistbot at llvm.org
Mon Feb 14 11:10:44 PST 2022
Author: Shraiysh Vaishay
Date: 2022-02-15T00:40:34+05:30
New Revision: b85cfe208f1d2768274375eb807b4d9362db77af
URL: https://github.com/llvm/llvm-project/commit/b85cfe208f1d2768274375eb807b4d9362db77af
DIFF: https://github.com/llvm/llvm-project/commit/b85cfe208f1d2768274375eb807b4d9362db77af.diff
LOG: [OpenMP][IRBuilder] Change the default constructor for OpenMPIRBuilder::LocationDescription
This patch changes the argument from template-IRBuilder to IRBuilderBase
thus allowing us to write less code while getting the location from a
builder.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D119717
Added:
Modified:
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index 7643da21be601..17aec5d5145fb 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -145,8 +145,7 @@ class OpenMPIRBuilder {
/// Description of a LLVM-IR insertion point (IP) and a debug/source location
/// (filename, line, column, ...).
struct LocationDescription {
- template <typename T, typename U>
- LocationDescription(const IRBuilder<T, U> &IRB)
+ LocationDescription(const IRBuilderBase &IRB)
: IP(IRB.saveIP()), DL(IRB.getCurrentDebugLocation()) {}
LocationDescription(const InsertPointTy &IP) : IP(IP) {}
LocationDescription(const InsertPointTy &IP, const DebugLoc &DL)
diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
index d69e428f8cea2..4b44197c4366f 100644
--- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
@@ -264,8 +264,7 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder,
builder.CreateBr(entryBB);
builder.SetInsertPoint(entryBB);
}
- llvm::OpenMPIRBuilder::LocationDescription ompLoc(
- builder.saveIP(), builder.getCurrentDebugLocation());
+ llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
builder.restoreIP(moduleTranslation.getOpenMPBuilder()->createParallel(
ompLoc, findAllocaInsertPoint(builder, moduleTranslation), bodyGenCB,
privCB, finiCB, ifCond, numThreads, pbKind, isCancellable));
@@ -295,8 +294,7 @@ convertOmpMaster(Operation &opInst, llvm::IRBuilderBase &builder,
// called for variables which have destructors/finalizers.
auto finiCB = [&](InsertPointTy codeGenIP) {};
- llvm::OpenMPIRBuilder::LocationDescription ompLoc(
- builder.saveIP(), builder.getCurrentDebugLocation());
+ llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
builder.restoreIP(moduleTranslation.getOpenMPBuilder()->createMaster(
ompLoc, bodyGenCB, finiCB));
return success();
@@ -325,8 +323,7 @@ convertOmpCritical(Operation &opInst, llvm::IRBuilderBase &builder,
// called for variables which have destructors/finalizers.
auto finiCB = [&](InsertPointTy codeGenIP) {};
- llvm::OpenMPIRBuilder::LocationDescription ompLoc(
- builder.saveIP(), builder.getCurrentDebugLocation());
+ llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
llvm::LLVMContext &llvmContext = moduleTranslation.getLLVMContext();
llvm::Constant *hint = nullptr;
@@ -520,8 +517,7 @@ convertOmpOrdered(Operation &opInst, llvm::IRBuilderBase &builder,
SmallVector<llvm::Value *> vecValues =
moduleTranslation.lookupValues(orderedOp.depend_vec_vars());
- llvm::OpenMPIRBuilder::LocationDescription ompLoc(
- builder.saveIP(), builder.getCurrentDebugLocation());
+ llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
size_t indexVecValues = 0;
while (indexVecValues < vecValues.size()) {
SmallVector<llvm::Value *> storeValues;
@@ -566,8 +562,7 @@ convertOmpOrderedRegion(Operation &opInst, llvm::IRBuilderBase &builder,
// called for variables which have destructors/finalizers.
auto finiCB = [&](InsertPointTy codeGenIP) {};
- llvm::OpenMPIRBuilder::LocationDescription ompLoc(
- builder.saveIP(), builder.getCurrentDebugLocation());
+ llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
builder.restoreIP(
moduleTranslation.getOpenMPBuilder()->createOrderedThreadsSimd(
ompLoc, bodyGenCB, finiCB, !orderedRegionOp.simd()));
@@ -637,8 +632,7 @@ convertOmpSections(Operation &opInst, llvm::IRBuilderBase &builder,
// called for variables which have destructors/finalizers.
auto finiCB = [&](InsertPointTy codeGenIP) {};
- llvm::OpenMPIRBuilder::LocationDescription ompLoc(
- builder.saveIP(), builder.getCurrentDebugLocation());
+ llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
builder.restoreIP(moduleTranslation.getOpenMPBuilder()->createSections(
ompLoc, findAllocaInsertPoint(builder, moduleTranslation), sectionCBs,
privCB, finiCB, false, sectionsOp.nowait()));
@@ -720,12 +714,7 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
}
// Set up the source location value for OpenMP runtime.
- llvm::DISubprogram *subprogram =
- builder.GetInsertBlock()->getParent()->getSubprogram();
- const llvm::DILocation *diLoc =
- moduleTranslation.translateLoc(opInst.getLoc(), subprogram);
- llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder.saveIP(),
- llvm::DebugLoc(diLoc));
+ llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
// Generator of the canonical loop body.
// TODO: support error propagation in OpenMPIRBuilder and use it instead of
@@ -772,8 +761,7 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
llvm::OpenMPIRBuilder::LocationDescription loc = ompLoc;
llvm::OpenMPIRBuilder::InsertPointTy computeIP = ompLoc.IP;
if (i != 0) {
- loc = llvm::OpenMPIRBuilder::LocationDescription(bodyInsertPoints.back(),
- llvm::DebugLoc(diLoc));
+ loc = llvm::OpenMPIRBuilder::LocationDescription(bodyInsertPoints.back());
computeIP = loopInfos.front()->getPreheaderIP();
}
loopInfos.push_back(ompBuilder->createCanonicalLoop(
@@ -788,7 +776,7 @@ convertOmpWsLoop(Operation &opInst, llvm::IRBuilderBase &builder,
// invalidated.
llvm::IRBuilderBase::InsertPoint afterIP = loopInfos.front()->getAfterIP();
llvm::CanonicalLoopInfo *loopInfo =
- ompBuilder->collapseLoops(diLoc, loopInfos, {});
+ ompBuilder->collapseLoops(ompLoc.DL, loopInfos, {});
allocaIP = findAllocaInsertPoint(builder, moduleTranslation);
@@ -922,13 +910,8 @@ convertOmpAtomicRead(Operation &opInst, llvm::IRBuilderBase &builder,
auto readOp = cast<omp::AtomicReadOp>(opInst);
llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
- // Set up the source location value for OpenMP runtime.
- llvm::DISubprogram *subprogram =
- builder.GetInsertBlock()->getParent()->getSubprogram();
- const llvm::DILocation *diLoc =
- moduleTranslation.translateLoc(opInst.getLoc(), subprogram);
- llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder.saveIP(),
- llvm::DebugLoc(diLoc));
+ llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
+
llvm::AtomicOrdering AO = convertAtomicOrdering(readOp.memory_order());
llvm::Value *x = moduleTranslation.lookupValue(readOp.x());
Type xTy = readOp.x().getType().cast<omp::PointerLikeType>().getElementType();
@@ -949,13 +932,7 @@ convertOmpAtomicWrite(Operation &opInst, llvm::IRBuilderBase &builder,
auto writeOp = cast<omp::AtomicWriteOp>(opInst);
llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
- // Set up the source location value for OpenMP runtime.
- llvm::DISubprogram *subprogram =
- builder.GetInsertBlock()->getParent()->getSubprogram();
- const llvm::DILocation *diLoc =
- moduleTranslation.translateLoc(opInst.getLoc(), subprogram);
- llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder.saveIP(),
- llvm::DebugLoc(diLoc));
+ llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
llvm::AtomicOrdering ao = convertAtomicOrdering(writeOp.memory_order());
llvm::Value *expr = moduleTranslation.lookupValue(writeOp.value());
llvm::Value *dest = moduleTranslation.lookupValue(writeOp.address());
More information about the Mlir-commits
mailing list