Skip to content

Commit

Permalink
Fix issue when inode file ID cannot be created.
Browse files Browse the repository at this point in the history
This PR fixes a problem when the the file ID cannot be determined during code-gen to create a unique symbol name.  This can happen when a preprocessor leaves a file name in the line tag that does not exist.
  • Loading branch information
mjklemm committed Dec 9, 2024
1 parent 88d9996 commit 7f75c76
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4241,7 +4241,7 @@ LogicalResult convertFlagsAttr(Operation *op, mlir::omp::FlagsAttr attribute,
return success();
}

static bool getTargetEntryUniqueInfo(llvm::TargetRegionEntryInfo &targetInfo,
static void getTargetEntryUniqueInfo(llvm::TargetRegionEntryInfo &targetInfo,
omp::TargetOp targetOp,
llvm::StringRef parentName = "") {
auto fileLoc = targetOp.getLoc()->findInstanceOf<FileLineColLoc>();
Expand All @@ -4250,15 +4250,16 @@ static bool getTargetEntryUniqueInfo(llvm::TargetRegionEntryInfo &targetInfo,
StringRef fileName = fileLoc.getFilename().getValue();

llvm::sys::fs::UniqueID id;
uint64_t line = fileLoc.getLine();
if (auto ec = llvm::sys::fs::getUniqueID(fileName, id)) {
targetOp.emitError("Unable to get unique ID for file");
return false;
size_t fileHash = llvm::hash_value(fileName.str());
size_t deviceId = 0xdeadf17e;
targetInfo = llvm::TargetRegionEntryInfo(parentName, deviceId,
fileHash, line);
} else {
targetInfo = llvm::TargetRegionEntryInfo(parentName, id.getDevice(),
id.getFile(), line);
}

uint64_t line = fileLoc.getLine();
targetInfo = llvm::TargetRegionEntryInfo(parentName, id.getDevice(),
id.getFile(), line);
return true;
}

static void
Expand Down Expand Up @@ -4811,8 +4812,7 @@ convertOmpTarget(Operation &opInst, llvm::IRBuilderBase &builder,

llvm::TargetRegionEntryInfo entryInfo;

if (!getTargetEntryUniqueInfo(entryInfo, targetOp, parentName))
return failure();
getTargetEntryUniqueInfo(entryInfo, targetOp, parentName);

llvm::OpenMPIRBuilder::InsertPointTy allocaIP =
findAllocaInsertPoint(builder, moduleTranslation);
Expand Down

0 comments on commit 7f75c76

Please sign in to comment.