@@ -1595,9 +1595,9 @@ CGOpenMPRuntime::createDispatchNextFunction(unsigned IVSize, bool IVSigned) {
15951595/// Obtain information that uniquely identifies a target entry. This
15961596/// consists of the file and device IDs as well as line number associated with
15971597/// the relevant entry source location.
1598- static llvm::TargetRegionEntryInfo
1599- getTargetEntryUniqueInfo(ASTContext &C, SourceLocation Loc ,
1600- StringRef ParentName = "" ) {
1598+ static void getTargetEntryUniqueInfo(ASTContext &C, SourceLocation Loc,
1599+ unsigned &DeviceID, unsigned &FileID ,
1600+ unsigned &LineNum ) {
16011601 SourceManager &SM = C.getSourceManager();
16021602
16031603 // The loc should be always valid and have a file ID (the user cannot use
@@ -1617,8 +1617,9 @@ getTargetEntryUniqueInfo(ASTContext &C, SourceLocation Loc,
16171617 << PLoc.getFilename() << EC.message();
16181618 }
16191619
1620- return llvm::TargetRegionEntryInfo(ParentName, ID.getDevice(), ID.getFile(),
1621- PLoc.getLine());
1620+ DeviceID = ID.getDevice();
1621+ FileID = ID.getFile();
1622+ LineNum = PLoc.getLine();
16221623}
16231624
16241625Address CGOpenMPRuntime::getAddrOfDeclareTargetVar(const VarDecl *VD) {
@@ -1634,9 +1635,11 @@ Address CGOpenMPRuntime::getAddrOfDeclareTargetVar(const VarDecl *VD) {
16341635 llvm::raw_svector_ostream OS(PtrName);
16351636 OS << CGM.getMangledName(GlobalDecl(VD));
16361637 if (!VD->isExternallyVisible()) {
1637- auto EntryInfo = getTargetEntryUniqueInfo(
1638- CGM.getContext(), VD->getCanonicalDecl()->getBeginLoc());
1639- OS << llvm::format("_%x", EntryInfo.FileID);
1638+ unsigned DeviceID, FileID, Line;
1639+ getTargetEntryUniqueInfo(CGM.getContext(),
1640+ VD->getCanonicalDecl()->getBeginLoc(),
1641+ DeviceID, FileID, Line);
1642+ OS << llvm::format("_%x", FileID);
16401643 }
16411644 OS << "_decl_tgt_ref_ptr";
16421645 }
@@ -1855,10 +1858,16 @@ bool CGOpenMPRuntime::emitDeclareTargetVarDefinition(const VarDecl *VD,
18551858 // Produce the unique prefix to identify the new target regions. We use
18561859 // the source location of the variable declaration which we know to not
18571860 // conflict with any target region.
1858- auto EntryInfo =
1859- getTargetEntryUniqueInfo(CGM.getContext(), Loc, VD->getName());
1861+ unsigned DeviceID;
1862+ unsigned FileID;
1863+ unsigned Line;
1864+ getTargetEntryUniqueInfo(CGM.getContext(), Loc, DeviceID, FileID, Line);
18601865 SmallString<128> Buffer, Out;
1861- EntryInfo.getTargetRegionEntryFnName(Buffer);
1866+ {
1867+ llvm::raw_svector_ostream OS(Buffer);
1868+ OS << "__omp_offloading_" << llvm::format("_%x", DeviceID)
1869+ << llvm::format("_%x_", FileID) << VD->getName() << "_l" << Line;
1870+ }
18621871
18631872 const Expr *Init = VD->getAnyInitializer();
18641873 if (CGM.getLangOpts().CPlusPlus && PerformInit) {
@@ -1904,12 +1913,9 @@ bool CGOpenMPRuntime::emitDeclareTargetVarDefinition(const VarDecl *VD,
19041913
19051914 // Register the information for the entry associated with the constructor.
19061915 Out.clear();
1907- auto CtorEntryInfo = EntryInfo;
1908- CtorEntryInfo.ParentName = Twine(Buffer, "_ctor").toStringRef(Out);
1909- llvm::errs() << "Registering var ctor: " << Twine(Buffer, "_ctor") << "\n";
19101916 OffloadEntriesInfoManager.registerTargetRegionEntryInfo(
1911- CtorEntryInfo, Ctor, ID ,
1912- llvm::OffloadEntriesInfoManager::OMPTargetRegionEntryCtor,
1917+ DeviceID, FileID, Twine(Buffer, "_ctor").toStringRef(Out), Line, Ctor ,
1918+ ID, llvm::OffloadEntriesInfoManager::OMPTargetRegionEntryCtor,
19131919 CGM.getLangOpts().OpenMPIsDevice);
19141920 }
19151921 if (VD->getType().isDestructedType() != QualType::DK_none) {
@@ -1955,11 +1961,9 @@ bool CGOpenMPRuntime::emitDeclareTargetVarDefinition(const VarDecl *VD,
19551961 }
19561962 // Register the information for the entry associated with the destructor.
19571963 Out.clear();
1958- auto DtorEntryInfo = EntryInfo;
1959- DtorEntryInfo.ParentName = Twine(Buffer, "_dtor").toStringRef(Out);
19601964 OffloadEntriesInfoManager.registerTargetRegionEntryInfo(
1961- DtorEntryInfo, Dtor, ID ,
1962- llvm::OffloadEntriesInfoManager::OMPTargetRegionEntryDtor,
1965+ DeviceID, FileID, Twine(Buffer, "_dtor").toStringRef(Out), Line, Dtor ,
1966+ ID, llvm::OffloadEntriesInfoManager::OMPTargetRegionEntryDtor,
19631967 CGM.getLangOpts().OpenMPIsDevice);
19641968 }
19651969 return CGM.getLangOpts().OpenMPIsDevice;
@@ -2997,7 +3001,8 @@ void CGOpenMPRuntime::createOffloadEntriesAndInfoMetadata() {
29973001 auto &&TargetRegionMetadataEmitter =
29983002 [this, &C, MD, &OrderedEntries, &ParentFunctions, &GetMDInt,
29993003 &GetMDString](
3000- llvm::TargetRegionEntryInfo EntryInfo,
3004+ unsigned DeviceID, unsigned FileID, StringRef ParentName,
3005+ unsigned Line,
30013006 const llvm::OffloadEntriesInfoManager::OffloadEntryInfoTargetRegion
30023007 &E) {
30033008 // Generate metadata for target regions. Each entry of this metadata
@@ -3010,26 +3015,24 @@ void CGOpenMPRuntime::createOffloadEntriesAndInfoMetadata() {
30103015 // - Entry 4 -> Line in the file where the entry was identified.
30113016 // - Entry 5 -> Order the entry was created.
30123017 // The first element of the metadata node is the kind.
3013- llvm::Metadata *Ops[] = {
3014- GetMDInt(E.getKind()), GetMDInt(EntryInfo.DeviceID),
3015- GetMDInt(EntryInfo.FileID), GetMDString(EntryInfo.ParentName),
3016- GetMDInt(EntryInfo.Line), GetMDInt(E.getOrder())};
3018+ llvm::Metadata *Ops[] = {GetMDInt(E.getKind()), GetMDInt(DeviceID),
3019+ GetMDInt(FileID), GetMDString(ParentName),
3020+ GetMDInt(Line), GetMDInt(E.getOrder())};
30173021
30183022 SourceLocation Loc;
30193023 for (auto I = CGM.getContext().getSourceManager().fileinfo_begin(),
30203024 E = CGM.getContext().getSourceManager().fileinfo_end();
30213025 I != E; ++I) {
3022- if (I->getFirst()->getUniqueID().getDevice() == EntryInfo. DeviceID &&
3023- I->getFirst()->getUniqueID().getFile() == EntryInfo. FileID) {
3026+ if (I->getFirst()->getUniqueID().getDevice() == DeviceID &&
3027+ I->getFirst()->getUniqueID().getFile() == FileID) {
30243028 Loc = CGM.getContext().getSourceManager().translateFileLineCol(
3025- I->getFirst(), EntryInfo. Line, 1);
3029+ I->getFirst(), Line, 1);
30263030 break;
30273031 }
30283032 }
30293033 // Save this entry in the right position of the ordered entries array.
3030- OrderedEntries[E.getOrder()] =
3031- std::make_tuple(&E, Loc, StringRef(EntryInfo.ParentName));
3032- ParentFunctions[E.getOrder()] = StringRef(EntryInfo.ParentName);
3034+ OrderedEntries[E.getOrder()] = std::make_tuple(&E, Loc, ParentName);
3035+ ParentFunctions[E.getOrder()] = ParentName;
30333036
30343037 // Add metadata to the named metadata node.
30353038 MD->addOperand(llvm::MDNode::get(C, Ops));
@@ -3192,18 +3195,15 @@ void CGOpenMPRuntime::loadOffloadInfoMetadata() {
31923195 llvm_unreachable("Unexpected metadata!");
31933196 break;
31943197 case llvm::OffloadEntriesInfoManager::OffloadEntryInfo::
3195- OffloadingEntryInfoTargetRegion: {
3198+ OffloadingEntryInfoTargetRegion:
31963199 assert(CGM.getLangOpts().OpenMPIsDevice && "Initialization of entries is "
31973200 "only required for the "
31983201 "device code generation.");
3199- llvm::TargetRegionEntryInfo EntryInfo(/*ParentName=*/GetMDString(3),
3200- /*DeviceID=*/GetMDInt(1),
3201- /*FileID=*/GetMDInt(2),
3202- /*Line=*/GetMDInt(4));
32033202 OffloadEntriesInfoManager.initializeTargetRegionEntryInfo(
3204- EntryInfo, /*Order=*/GetMDInt(5));
3203+ /*DeviceID=*/GetMDInt(1), /*FileID=*/GetMDInt(2),
3204+ /*ParentName=*/GetMDString(3), /*Line=*/GetMDInt(4),
3205+ /*Order=*/GetMDInt(5));
32053206 break;
3206- }
32073207 case llvm::OffloadEntriesInfoManager::OffloadEntryInfo::
32083208 OffloadingEntryInfoDeviceGlobalVar:
32093209 assert(CGM.getLangOpts().OpenMPIsDevice && "Initialization of entries is "
@@ -6209,7 +6209,7 @@ void CGOpenMPRuntime::emitTargetOutlinedFunction(
62096209 const OMPExecutableDirective &D, StringRef ParentName,
62106210 llvm::Function *&OutlinedFn, llvm::Constant *&OutlinedFnID,
62116211 bool IsOffloadEntry, const RegionCodeGenTy &CodeGen) {
6212- assert(!ParentName.empty() && "Invalid target entry parent name!");
6212+ assert(!ParentName.empty() && "Invalid target region parent name!");
62136213 HasEmittedTargetRegion = true;
62146214 SmallVector<std::pair<const Expr *, const Expr *>, 4> Allocators;
62156215 for (const auto *C : D.getClausesOfKind<OMPUsesAllocatorsClause>()) {
@@ -6292,10 +6292,17 @@ void CGOpenMPRuntime::emitTargetOutlinedFunctionHelper(
62926292
62936293 const bool BuildOutlinedFn = CGM.getLangOpts().OpenMPIsDevice ||
62946294 !CGM.getLangOpts().OpenMPOffloadMandatory;
6295- auto EntryInfo =
6296- getTargetEntryUniqueInfo(CGM.getContext(), D.getBeginLoc(), ParentName);
6295+ unsigned DeviceID;
6296+ unsigned FileID;
6297+ unsigned Line;
6298+ getTargetEntryUniqueInfo(CGM.getContext(), D.getBeginLoc(), DeviceID, FileID,
6299+ Line);
62976300 SmallString<64> EntryFnName;
6298- EntryInfo.getTargetRegionEntryFnName(EntryFnName);
6301+ {
6302+ llvm::raw_svector_ostream OS(EntryFnName);
6303+ OS << "__omp_offloading" << llvm::format("_%x", DeviceID)
6304+ << llvm::format("_%x_", FileID) << ParentName << "_l" << Line;
6305+ }
62996306
63006307 const CapturedStmt &CS = *D.getCapturedStmt(OMPD_target);
63016308
@@ -6350,7 +6357,7 @@ void CGOpenMPRuntime::emitTargetOutlinedFunctionHelper(
63506357
63516358 // Register the information for the entry associated with this target region.
63526359 OffloadEntriesInfoManager.registerTargetRegionEntryInfo(
6353- EntryInfo , TargetRegionEntryAddr, OutlinedFnID,
6360+ DeviceID, FileID, ParentName, Line , TargetRegionEntryAddr, OutlinedFnID,
63546361 llvm::OffloadEntriesInfoManager::OMPTargetRegionEntryTargetRegion,
63556362 CGM.getLangOpts().OpenMPIsDevice);
63566363
@@ -10345,12 +10352,16 @@ void CGOpenMPRuntime::scanForTargetRegionsFunctions(const Stmt *S,
1034510352
1034610353 if (RequiresDeviceCodegen) {
1034710354 const auto &E = *cast<OMPExecutableDirective>(S);
10348- auto EntryInfo =
10349- getTargetEntryUniqueInfo(CGM.getContext(), E.getBeginLoc(), ParentName);
10355+ unsigned DeviceID;
10356+ unsigned FileID;
10357+ unsigned Line;
10358+ getTargetEntryUniqueInfo(CGM.getContext(), E.getBeginLoc(), DeviceID,
10359+ FileID, Line);
1035010360
1035110361 // Is this a target region that should not be emitted as an entry point? If
1035210362 // so just signal we are done with this target region.
10353- if (!OffloadEntriesInfoManager.hasTargetRegionEntryInfo(EntryInfo))
10363+ if (!OffloadEntriesInfoManager.hasTargetRegionEntryInfo(DeviceID, FileID,
10364+ ParentName, Line))
1035410365 return;
1035510366
1035610367 switch (E.getDirectiveKind()) {
0 commit comments