[Openmp-commits] [PATCH] D127399: [OpenMP] Ensure createXXX functions will always call updateToLocation
Johannes Doerfert via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Thu Jun 9 04:55:34 PDT 2022
jdoerfert created this revision.
jdoerfert added reviewers: kiranchandramohan, Leporacanthicus, Meinersbur.
Herald added subscribers: guansong, bollu, hiraditya, yaxunl.
Herald added a project: All.
jdoerfert requested review of this revision.
Herald added subscribers: llvm-commits, sstefan1.
Herald added a project: LLVM.
It is easy to not set the debug location which will result in problems
in debug builds. Hence, we should always use the helper
`updateToLocation` for all user facing entry points of the OMPIRBuilder.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D127399
Files:
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===================================================================
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -1843,6 +1843,9 @@
OpenMPIRBuilder::createCanonicalLoop(const LocationDescription &Loc,
LoopBodyGenCallbackTy BodyGenCB,
Value *TripCount, const Twine &Name) {
+ if (!updateToLocation(Loc))
+ return nullptr;
+
BasicBlock *BB = Loc.IP.getBlock();
BasicBlock *NextBB = BB->getNextNode();
@@ -1887,7 +1890,8 @@
LocationDescription ComputeLoc =
ComputeIP.isSet() ? LocationDescription(ComputeIP, Loc.DL) : Loc;
- updateToLocation(ComputeLoc);
+ if (!updateToLocation(ComputeLoc))
+ return nullptr;
ConstantInt *Zero = ConstantInt::get(IndVarTy, 0);
ConstantInt *One = ConstantInt::get(IndVarTy, 1);
@@ -3326,7 +3330,7 @@
"Unexpected Insertion point location!");
auto merged = MergeBlockIntoPredecessor(ExitBB);
BasicBlock *ExitPredBB = SplitPos->getParent();
- auto InsertBB = merged ? ExitPredBB : ExitBB;
+ auto *InsertBB = merged ? ExitPredBB : ExitBB;
if (!isa_and_nonnull<BranchInst>(SplitPos))
SplitPos->eraseFromParent();
Builder.SetInsertPoint(InsertBB);
@@ -3451,8 +3455,8 @@
CallInst *OpenMPIRBuilder::createOMPAlloc(const LocationDescription &Loc,
Value *Size, Value *Allocator,
std::string Name) {
- IRBuilder<>::InsertPointGuard IPG(Builder);
- Builder.restoreIP(Loc.IP);
+ if (!updateToLocation(Loc))
+ return nullptr;
uint32_t SrcLocStrSize;
Constant *SrcLocStr = getOrCreateSrcLocStr(Loc, SrcLocStrSize);
@@ -3468,8 +3472,8 @@
CallInst *OpenMPIRBuilder::createOMPFree(const LocationDescription &Loc,
Value *Addr, Value *Allocator,
std::string Name) {
- IRBuilder<>::InsertPointGuard IPG(Builder);
- Builder.restoreIP(Loc.IP);
+ if (!updateToLocation(Loc))
+ return nullptr;
uint32_t SrcLocStrSize;
Constant *SrcLocStr = getOrCreateSrcLocStr(Loc, SrcLocStrSize);
@@ -3484,8 +3488,8 @@
const LocationDescription &Loc, Value *InteropVar,
omp::OMPInteropType InteropType, Value *Device, Value *NumDependences,
Value *DependenceAddress, bool HaveNowaitClause) {
- IRBuilder<>::InsertPointGuard IPG(Builder);
- Builder.restoreIP(Loc.IP);
+ if (!updateToLocation(Loc))
+ return nullptr;
uint32_t SrcLocStrSize;
Constant *SrcLocStr = getOrCreateSrcLocStr(Loc, SrcLocStrSize);
@@ -3512,8 +3516,8 @@
CallInst *OpenMPIRBuilder::createOMPInteropDestroy(
const LocationDescription &Loc, Value *InteropVar, Value *Device,
Value *NumDependences, Value *DependenceAddress, bool HaveNowaitClause) {
- IRBuilder<>::InsertPointGuard IPG(Builder);
- Builder.restoreIP(Loc.IP);
+ if (!updateToLocation(Loc))
+ return nullptr;
uint32_t SrcLocStrSize;
Constant *SrcLocStr = getOrCreateSrcLocStr(Loc, SrcLocStrSize);
@@ -3541,8 +3545,9 @@
Value *NumDependences,
Value *DependenceAddress,
bool HaveNowaitClause) {
- IRBuilder<>::InsertPointGuard IPG(Builder);
- Builder.restoreIP(Loc.IP);
+ if (!updateToLocation(Loc))
+ return nullptr;
+
uint32_t SrcLocStrSize;
Constant *SrcLocStr = getOrCreateSrcLocStr(Loc, SrcLocStrSize);
Value *Ident = getOrCreateIdent(SrcLocStr, SrcLocStrSize);
@@ -3567,8 +3572,8 @@
CallInst *OpenMPIRBuilder::createCachedThreadPrivate(
const LocationDescription &Loc, llvm::Value *Pointer,
llvm::ConstantInt *Size, const llvm::Twine &Name) {
- IRBuilder<>::InsertPointGuard IPG(Builder);
- Builder.restoreIP(Loc.IP);
+ if (!updateToLocation(Loc))
+ return nullptr;
uint32_t SrcLocStrSize;
Constant *SrcLocStr = getOrCreateSrcLocStr(Loc, SrcLocStrSize);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127399.435506.patch
Type: text/x-patch
Size: 4059 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220609/495d31b1/attachment.bin>
More information about the Openmp-commits
mailing list