@@ -1830,36 +1830,31 @@ void CGOpenMPRuntime::registerVTableOffloadEntry(llvm::GlobalVariable *VTable,
18301830}
18311831
18321832void CGOpenMPRuntime::emitAndRegisterVTable(CodeGenModule &CGM,
1833- CXXRecordDecl *CXXRecord,
1834- const VarDecl *VD) {
1835- // Register C++ VTable to OpenMP Offload Entry if it's a new
1836- // CXXRecordDecl.
1837- if (CXXRecord && CXXRecord->isDynamicClass() &&
1838- CGM.getOpenMPRuntime().VTableDeclMap.find(CXXRecord) ==
1839- CGM.getOpenMPRuntime().VTableDeclMap.end()) {
1840- CGM.getOpenMPRuntime().VTableDeclMap.try_emplace(CXXRecord, VD);
1841- CGM.EmitVTable(CXXRecord);
1842- CodeGenVTables VTables = CGM.getVTables();
1843- llvm::GlobalVariable *VTablesAddr = VTables.GetAddrOfVTable(CXXRecord);
1844- if (VTablesAddr)
1845- CGM.getOpenMPRuntime().registerVTableOffloadEntry(VTablesAddr, VD);
1846- // Emit VTable for all the fields containing dynamic CXXRecord
1847- for (const FieldDecl *Field : CXXRecord->fields()) {
1848- if (CXXRecordDecl *RecordDecl =
1849- Field->getType()->getAsCXXRecordDecl())
1850- emitAndRegisterVTable(CGM, RecordDecl, VD);
1851-
1852- }
1853- // Emit VTable for all dynamic parent class
1854- for (CXXBaseSpecifier &Base : CXXRecord->bases()) {
1855- if (CXXRecordDecl *BaseDecl =
1856- Base.getType()->getAsCXXRecordDecl())
1857- emitAndRegisterVTable(CGM, BaseDecl, VD);
1858-
1859- }
1860- }
1861- };
1862-
1833+ CXXRecordDecl *CXXRecord,
1834+ const VarDecl *VD) {
1835+ // Register C++ VTable to OpenMP Offload Entry if it's a new
1836+ // CXXRecordDecl.
1837+ if (CXXRecord && CXXRecord->isDynamicClass() &&
1838+ CGM.getOpenMPRuntime().VTableDeclMap.find(CXXRecord) ==
1839+ CGM.getOpenMPRuntime().VTableDeclMap.end()) {
1840+ CGM.getOpenMPRuntime().VTableDeclMap.try_emplace(CXXRecord, VD);
1841+ CGM.EmitVTable(CXXRecord);
1842+ CodeGenVTables VTables = CGM.getVTables();
1843+ llvm::GlobalVariable *VTablesAddr = VTables.GetAddrOfVTable(CXXRecord);
1844+ if (VTablesAddr)
1845+ CGM.getOpenMPRuntime().registerVTableOffloadEntry(VTablesAddr, VD);
1846+ // Emit VTable for all the fields containing dynamic CXXRecord
1847+ for (const FieldDecl *Field : CXXRecord->fields()) {
1848+ if (CXXRecordDecl *RecordDecl = Field->getType()->getAsCXXRecordDecl())
1849+ emitAndRegisterVTable(CGM, RecordDecl, VD);
1850+ }
1851+ // Emit VTable for all dynamic parent class
1852+ for (CXXBaseSpecifier &Base : CXXRecord->bases()) {
1853+ if (CXXRecordDecl *BaseDecl = Base.getType()->getAsCXXRecordDecl())
1854+ emitAndRegisterVTable(CGM, BaseDecl, VD);
1855+ }
1856+ }
1857+ };
18631858
18641859void CGOpenMPRuntime::registerVTable(const OMPExecutableDirective &D) {
18651860 // Register VTable by scanning through the map clause of OpenMP target region.
@@ -10070,15 +10065,15 @@ void CGOpenMPRuntime::scanForTargetRegionsFunctions(const Stmt *S,
1007010065 // Register vtable from device for target data and target directives.
1007110066 // Add this block here since scanForTargetRegionsFunctions ignores
1007210067 // target data by checking if S is a executable directive (target).
10073- if (isa<OMPExecutableDirective>(S) &&
10074- isOpenMPTargetDataManagementDirective(
10075- dyn_cast<OMPExecutableDirective>(S)->getDirectiveKind())) {
10076- auto &E = *dyn_cast<OMPExecutableDirective>(S);
10077- // Don't need to check if it's device compile
10078- // since scanForTargetRegionsFunctions currently only called
10079- // in device compilation.
10080- registerVTable(E);
10081- }
10068+ if (isa<OMPExecutableDirective>(S) &&
10069+ isOpenMPTargetDataManagementDirective(
10070+ dyn_cast<OMPExecutableDirective>(S)->getDirectiveKind())) {
10071+ auto &E = *dyn_cast<OMPExecutableDirective>(S);
10072+ // Don't need to check if it's device compile
10073+ // since scanForTargetRegionsFunctions currently only called
10074+ // in device compilation.
10075+ registerVTable(E);
10076+ }
1008210077
1008310078 // Codegen OMP target directives that offload compute to the device.
1008410079 bool RequiresDeviceCodegen =
0 commit comments