Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang/lib/CodeGen/CGOpenMPRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,8 @@ static llvm::TargetRegionEntryInfo getEntryInfoFromPresumedLoc(
return std::pair<std::string, uint64_t>(PLoc.getFilename(), PLoc.getLine());
};

return OMPBuilder.getTargetEntryUniqueInfo(FileInfoCallBack, ParentName);
return OMPBuilder.getTargetEntryUniqueInfo(FileInfoCallBack,
*CGM.getFileSystem(), ParentName);
}

ConstantAddress CGOpenMPRuntime::getAddrOfDeclareTargetVar(const VarDecl *VD) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ class OpenMPIRBuilder {
/// any.
LLVM_ABI static TargetRegionEntryInfo
getTargetEntryUniqueInfo(FileIdentifierInfoCallbackTy CallBack,
StringRef ParentName = "");
vfs::FileSystem &VFS, StringRef ParentName = "");

/// Enum class for the RedctionGen CallBack type to be used.
enum class ReductionGenCBKind { Clang, MLIR };
Expand Down
14 changes: 8 additions & 6 deletions llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10312,17 +10312,19 @@ void OffloadEntriesInfoManager::getTargetRegionEntryFnName(

TargetRegionEntryInfo
OpenMPIRBuilder::getTargetEntryUniqueInfo(FileIdentifierInfoCallbackTy CallBack,
vfs::FileSystem &VFS,
StringRef ParentName) {
sys::fs::UniqueID ID(0xdeadf17e, 0);
auto FileIDInfo = CallBack();
uint64_t FileID = 0;
std::error_code EC = sys::fs::getUniqueID(std::get<0>(FileIDInfo), ID);
// If the inode ID could not be determined, create a hash value
// the current file name and use that as an ID.
if (EC)
if (ErrorOr<vfs::Status> Status = VFS.status(std::get<0>(FileIDInfo))) {
ID = Status->getUniqueID();
FileID = Status->getUniqueID().getFile();
} else {
// If the inode ID could not be determined, create a hash value
// the current file name and use that as an ID.
FileID = hash_value(std::get<0>(FileIDInfo));
else
FileID = ID.getFile();
}

return TargetRegionEntryInfo(ParentName, ID.getDevice(), FileID,
std::get<1>(FileIDInfo));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3595,8 +3595,10 @@ getDeclareTargetRefPtrSuffix(LLVM::GlobalOp globalOp,
llvm::StringRef(loc.getFilename()), loc.getLine());
};

auto vfs = llvm::vfs::getRealFileSystem();
os << llvm::format(
"_%x", ompBuilder.getTargetEntryUniqueInfo(fileInfoCallBack).FileID);
"_%x",
ompBuilder.getTargetEntryUniqueInfo(fileInfoCallBack, *vfs).FileID);
}
os << "_decl_tgt_ref_ptr";

Expand Down Expand Up @@ -5888,10 +5890,12 @@ convertDeclareTargetAttr(Operation *op, mlir::omp::DeclareTargetAttr attribute,
lineNo);
};

auto vfs = llvm::vfs::getRealFileSystem();

ompBuilder->registerTargetGlobalVariable(
captureClause, deviceClause, isDeclaration, isExternallyVisible,
ompBuilder->getTargetEntryUniqueInfo(fileInfoCallBack), mangledName,
generatedRefs, /*OpenMPSimd*/ false, targetTriple,
ompBuilder->getTargetEntryUniqueInfo(fileInfoCallBack, *vfs),
mangledName, generatedRefs, /*OpenMPSimd*/ false, targetTriple,
/*GlobalInitializer*/ nullptr, /*VariableLinkage*/ nullptr,
gVal->getType(), gVal);

Expand All @@ -5901,9 +5905,9 @@ convertDeclareTargetAttr(Operation *op, mlir::omp::DeclareTargetAttr attribute,
ompBuilder->Config.hasRequiresUnifiedSharedMemory())) {
ompBuilder->getAddrOfDeclareTargetVar(
captureClause, deviceClause, isDeclaration, isExternallyVisible,
ompBuilder->getTargetEntryUniqueInfo(fileInfoCallBack), mangledName,
generatedRefs, /*OpenMPSimd*/ false, targetTriple, gVal->getType(),
/*GlobalInitializer*/ nullptr,
ompBuilder->getTargetEntryUniqueInfo(fileInfoCallBack, *vfs),
mangledName, generatedRefs, /*OpenMPSimd*/ false, targetTriple,
gVal->getType(), /*GlobalInitializer*/ nullptr,
/*VariableLinkage*/ nullptr);
}
}
Expand Down