diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h --- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h +++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h @@ -145,8 +145,7 @@ /// Description of a LLVM-IR insertion point (IP) and a debug/source location /// (filename, line, column, ...). struct LocationDescription { - template - LocationDescription(const IRBuilder &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 --- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp @@ -264,8 +264,7 @@ 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 @@ // 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 @@ // 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 @@ SmallVector 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 storeValues; @@ -566,8 +562,7 @@ // 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 @@ // 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 @@ } // 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 @@ 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 @@ // 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 @@ auto readOp = cast(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().getElementType(); @@ -949,13 +932,7 @@ auto writeOp = cast(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());