@@ -4972,8 +4972,8 @@ static void PrintNSClosingBraces(raw_ostream &OS, const DeclContext *DC) {
4972
4972
}
4973
4973
4974
4974
static std::string EmitShim (raw_ostream &OS, unsigned &ShimCounter,
4975
- const std::string &LastShim,
4976
- const NamespaceDecl *AnonNS) {
4975
+ const std::string &LastShim,
4976
+ const NamespaceDecl *AnonNS) {
4977
4977
std::string NewShimName =
4978
4978
" __sycl_detail::__shim_" + std::to_string (ShimCounter) + " ()" ;
4979
4979
// Print opening-namespace
@@ -4992,8 +4992,7 @@ static std::string EmitShim(raw_ostream &OS, unsigned &ShimCounter,
4992
4992
4993
4993
// Emit the list of shims required for a DeclContext, calls itself recursively.
4994
4994
static void EmitShims (raw_ostream &OS, unsigned &ShimCounter,
4995
- const DeclContext *DC,
4996
- std::string &NameForLastShim) {
4995
+ const DeclContext *DC, std::string &NameForLastShim) {
4997
4996
if (DC->isTranslationUnit ()) {
4998
4997
NameForLastShim = " ::" + NameForLastShim;
4999
4998
return ;
@@ -5028,7 +5027,7 @@ static void EmitShims(raw_ostream &OS, unsigned &ShimCounter,
5028
5027
// Returns a string containing the FQN of the 'top most' shim, including its
5029
5028
// function call parameters.
5030
5029
static std::string EmitShims (raw_ostream &OS, unsigned &ShimCounter,
5031
- PrintingPolicy &Policy, const VarDecl *VD) {
5030
+ PrintingPolicy &Policy, const VarDecl *VD) {
5032
5031
if (!VD->isInAnonymousNamespace ())
5033
5032
return " " ;
5034
5033
std::string RelativeName;
@@ -5068,7 +5067,7 @@ bool SYCLIntegrationFooter::emit(raw_ostream &OS) {
5068
5067
if (llvm::find (Visited, VD) != Visited.end ())
5069
5068
continue ;
5070
5069
5071
- // We only want to emit the #includes if we have a spec-constant that needs
5070
+ // We only want to emit the #includes if we have a variable that needs
5072
5071
// them, so emit this one on the first time through the loop.
5073
5072
if (!EmittedFirstSpecConstant && !DeviceGlobalsEmitted)
5074
5073
OS << " #include <CL/sycl/detail/defines_elementary.hpp>\n " ;
@@ -5078,37 +5077,32 @@ bool SYCLIntegrationFooter::emit(raw_ostream &OS) {
5078
5077
if (Util::isSyclDeviceGlobalType (VD->getType ())) {
5079
5078
DeviceGlobalsEmitted = true ;
5080
5079
DeviceGlobOS << " device_global_map::add(" ;
5080
+ DeviceGlobOS << " (void *)&" ;
5081
+ if (VD->isInAnonymousNamespace ()) {
5082
+ DeviceGlobOS << TopShim;
5083
+ } else {
5084
+ DeviceGlobOS << " ::" ;
5085
+ VD->getNameForDiagnostic (DeviceGlobOS, Policy, true );
5086
+ }
5087
+ DeviceGlobOS << " , \" " ;
5088
+ DeviceGlobOS << SYCLUniqueStableIdExpr::ComputeName (S.getASTContext (),
5089
+ VD);
5090
+ DeviceGlobOS << " \" );\n " ;
5081
5091
} else {
5082
5092
EmittedFirstSpecConstant = true ;
5083
5093
OS << " __SYCL_INLINE_NAMESPACE(cl) {\n " ;
5084
5094
OS << " namespace sycl {\n " ;
5085
5095
OS << " namespace detail {\n " ;
5086
5096
OS << " template<>\n " ;
5087
5097
OS << " inline const char *get_spec_constant_symbolic_ID_impl<" ;
5088
- }
5089
5098
5090
- std::string VarRefName;
5091
- llvm::raw_string_ostream VarRefNameOS (VarRefName);
5092
- if (VD->isInAnonymousNamespace ()) {
5093
- VarRefNameOS << TopShim;
5094
- } else {
5095
- VarRefNameOS << " ::" ;
5096
- VD->getNameForDiagnostic (VarRefNameOS, Policy, true );
5097
- }
5098
- VarRefNameOS.flush ();
5099
- if (Util::isSyclDeviceGlobalType (VD->getType ())) {
5100
- DeviceGlobOS << " (void *)&" ;
5101
- DeviceGlobOS << VarRefName;
5102
- } else {
5103
- OS << VarRefName;
5104
- }
5099
+ if (VD->isInAnonymousNamespace ()) {
5100
+ OS << TopShim;
5101
+ } else {
5102
+ OS << " ::" ;
5103
+ VD->getNameForDiagnostic (OS, Policy, true );
5104
+ }
5105
5105
5106
- if (Util::isSyclDeviceGlobalType (VD->getType ())) {
5107
- DeviceGlobOS << " , \" " ;
5108
- DeviceGlobOS << SYCLUniqueStableIdExpr::ComputeName (S.getASTContext (),
5109
- VD);
5110
- DeviceGlobOS << " \" );\n " ;
5111
- } else {
5112
5106
OS << " >() {\n " ;
5113
5107
OS << " return \" " ;
5114
5108
OS << SYCLUniqueStableIdExpr::ComputeName (S.getASTContext (), VD);
0 commit comments