}
}
+static llvm::TargetRegionEntryInfo getEntryInfoFromPresumedLoc(
+ CodeGenModule &CGM, llvm::OpenMPIRBuilder &OMPBuilder,
+ SourceLocation BeginLoc, llvm::StringRef ParentName = "") {
+
+ auto FileInfoCallBack = [&]() {
+ SourceManager &SM = CGM.getContext().getSourceManager();
+ PresumedLoc PLoc = SM.getPresumedLoc(BeginLoc);
+
+ llvm::sys::fs::UniqueID ID;
+ if (auto EC = llvm::sys::fs::getUniqueID(PLoc.getFilename(), ID)) {
+ PLoc = SM.getPresumedLoc(BeginLoc, /*UseLineDirectives=*/false);
+ }
+
+ return std::pair<std::string, uint64_t>(PLoc.getFilename(), PLoc.getLine());
+ };
+
+ return OMPBuilder.getTargetEntryUniqueInfo(FileInfoCallBack, ParentName);
+}
+
Address CGOpenMPRuntime::getAddrOfDeclareTargetVar(const VarDecl *VD) {
auto AddrOfGlobal = [&VD, this]() { return CGM.GetAddrOfGlobal(VD); };
};
std::vector<llvm::GlobalVariable *> GeneratedRefs;
- auto PLoc = CGM.getContext().getSourceManager().getPresumedLoc(
- VD->getCanonicalDecl()->getBeginLoc());
- if (PLoc.isInvalid())
- PLoc = CGM.getContext().getSourceManager().getPresumedLoc(
- VD->getCanonicalDecl()->getBeginLoc(), /*UseLineDirectives=*/false);
llvm::Type *LlvmPtrTy = CGM.getTypes().ConvertTypeForMem(
CGM.getContext().getPointerType(VD->getType()));
convertCaptureClause(VD), convertDeviceClause(VD),
VD->hasDefinition(CGM.getContext()) == VarDecl::DeclarationOnly,
VD->isExternallyVisible(),
- OMPBuilder.getTargetEntryUniqueInfo(PLoc.getFilename(), PLoc.getLine()),
+ getEntryInfoFromPresumedLoc(CGM, OMPBuilder,
+ VD->getCanonicalDecl()->getBeginLoc()),
CGM.getMangledName(VD), GeneratedRefs, CGM.getLangOpts().OpenMPSimd,
CGM.getLangOpts().OMPTargetTriples, LlvmPtrTy, AddrOfGlobal,
LinkageForVariable);
return nullptr;
}
-static llvm::TargetRegionEntryInfo getEntryInfoFromPresumedLoc(
- CodeGenModule &CGM, llvm::OpenMPIRBuilder &OMPBuilder,
- SourceLocation BeginLoc, llvm::StringRef ParentName) {
-
- auto PLoc = CGM.getContext().getSourceManager().getPresumedLoc(BeginLoc);
- if (PLoc.isInvalid())
- PLoc = CGM.getContext().getSourceManager().getPresumedLoc(
- BeginLoc, /*UseLineDirectives=*/false);
-
- return OMPBuilder.getTargetEntryUniqueInfo(PLoc.getFilename(), PLoc.getLine(),
- ParentName);
-}
-
bool CGOpenMPRuntime::emitDeclareTargetVarDefinition(const VarDecl *VD,
llvm::GlobalVariable *Addr,
bool PerformInit) {
};
std::vector<llvm::GlobalVariable *> GeneratedRefs;
- auto PLoc = CGM.getContext().getSourceManager().getPresumedLoc(
- VD->getCanonicalDecl()->getBeginLoc());
- if (PLoc.isInvalid())
- PLoc = CGM.getContext().getSourceManager().getPresumedLoc(
- VD->getCanonicalDecl()->getBeginLoc(), /*UseLineDirectives=*/false);
OMPBuilder.registerTargetGlobalVariable(
convertCaptureClause(VD), convertDeviceClause(VD),
VD->hasDefinition(CGM.getContext()) == VarDecl::DeclarationOnly,
VD->isExternallyVisible(),
- OMPBuilder.getTargetEntryUniqueInfo(PLoc.getFilename(), PLoc.getLine()),
+ getEntryInfoFromPresumedLoc(CGM, OMPBuilder,
+ VD->getCanonicalDecl()->getBeginLoc()),
CGM.getMangledName(VD), GeneratedRefs, CGM.getLangOpts().OpenMPSimd,
CGM.getLangOpts().OMPTargetTriples, AddrOfGlobal, LinkageForVariable,
CGM.getTypes().ConvertTypeForMem(
InsertPointTy AllocaIP,
BodyGenCallbackTy BodyGenCB);
+
+ using FileIdentifierInfoCallbackTy = std::function<std::tuple<std::string, uint64_t>()>;
+
/// Creates a unique info for a target entry when provided a filename and
/// line number from.
///
- /// \param FileName The name of the file the target entry resides in
- /// \param Line The line number where the target entry resides
+ /// \param CallBack A callback function which should return filename the entry
+ /// resides in as well as the line number for the target entry
/// \param ParentName The name of the parent the target entry resides in, if
/// any.
static TargetRegionEntryInfo
- getTargetEntryUniqueInfo(StringRef FileName, uint64_t Line,
+ getTargetEntryUniqueInfo(FileIdentifierInfoCallbackTy CallBack,
StringRef ParentName = "");
/// Functions used to generate reductions. Such functions take two Values
}
TargetRegionEntryInfo
-OpenMPIRBuilder::getTargetEntryUniqueInfo(StringRef FileName, uint64_t Line,
+OpenMPIRBuilder::getTargetEntryUniqueInfo(FileIdentifierInfoCallbackTy CallBack,
StringRef ParentName) {
sys::fs::UniqueID ID;
- if (auto EC = sys::fs::getUniqueID(FileName, ID)) {
- assert(EC &&
- "Unable to get unique ID for file, during getTargetEntryUniqueInfo");
+ auto FileIDInfo = CallBack();
+ if (auto EC = sys::fs::getUniqueID(std::get<0>(FileIDInfo), ID)) {
+ llvm_unreachable(
+ "Unable to get unique ID for file, during getTargetEntryUniqueInfo");
}
- return TargetRegionEntryInfo(ParentName, ID.getDevice(), ID.getFile(), Line);
+
+ return TargetRegionEntryInfo(ParentName, ID.getDevice(), ID.getFile(),
+ std::get<1>(FileIDInfo));
}
Constant *OpenMPIRBuilder::getAddrOfDeclareTargetVar(