@@ -4414,41 +4414,40 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) {
44144414 }
44154415 }
44164416
4417-
44184417 // When using SYCLDeviceOnlyAttr, there can be two functions with the same
44194418 // mangling, the host function and the device overload. So when compiling for
44204419 // device we need to make sure we're selecting the SYCLDeviceOnlyAttr
44214420 // overload and dropping the host overload.
44224421 if (LangOpts.SYCLIsDevice ) {
4423- StringRef MangledName = getMangledName (GD);
4424- auto DDI = DeferredDecls.find (MangledName);
4425- // If we have an existing declaration with the same mangling for this
4426- // symbol it may be a SYCLDeviceOnlyAttr case.
4427- if (DDI != DeferredDecls.end ()) {
4428- auto *G = cast<ValueDecl>(DeferredDecls[MangledName].getDecl ());
4429-
4430- if (!G->hasAttr <SYCLDeviceOnlyAttr>() &&
4431- Global->hasAttr <SYCLDeviceOnlyAttr>() &&
4432- Global->hasAttr <SYCLDeviceAttr>()) {
4433- // If the host declaration was already processed and the device only
4434- // declaration is also a sycl external declaration, remove the host
4435- // variant and skip. The device only variant will be generated later
4436- // as it's marked sycl external.
4437- DeferredDecls.erase (DDI);
4438- return ;
4439- } else if (!G->hasAttr <SYCLDeviceOnlyAttr>() &&
4440- Global->hasAttr <SYCLDeviceOnlyAttr>()) {
4441- // If the host declaration was already processed, replace it with the
4442- // device only declaration.
4443- DeferredDecls[MangledName] = GD;
4444- return ;
4445- } else if (!Global->hasAttr <SYCLDeviceOnlyAttr>() &&
4446- G->hasAttr <SYCLDeviceOnlyAttr>()) {
4447- // If the device only declaration was already processed, skip the
4448- // host declaration.
4449- return ;
4450- }
4422+ StringRef MangledName = getMangledName (GD);
4423+ auto DDI = DeferredDecls.find (MangledName);
4424+ // If we have an existing declaration with the same mangling for this
4425+ // symbol it may be a SYCLDeviceOnlyAttr case.
4426+ if (DDI != DeferredDecls.end ()) {
4427+ auto *G = cast<ValueDecl>(DeferredDecls[MangledName].getDecl ());
4428+
4429+ if (!G->hasAttr <SYCLDeviceOnlyAttr>() &&
4430+ Global->hasAttr <SYCLDeviceOnlyAttr>() &&
4431+ Global->hasAttr <SYCLDeviceAttr>()) {
4432+ // If the host declaration was already processed and the device only
4433+ // declaration is also a sycl external declaration, remove the host
4434+ // variant and skip. The device only variant will be generated later
4435+ // as it's marked sycl external.
4436+ DeferredDecls.erase (DDI);
4437+ return ;
4438+ } else if (!G->hasAttr <SYCLDeviceOnlyAttr>() &&
4439+ Global->hasAttr <SYCLDeviceOnlyAttr>()) {
4440+ // If the host declaration was already processed, replace it with the
4441+ // device only declaration.
4442+ DeferredDecls[MangledName] = GD;
4443+ return ;
4444+ } else if (!Global->hasAttr <SYCLDeviceOnlyAttr>() &&
4445+ G->hasAttr <SYCLDeviceOnlyAttr>()) {
4446+ // If the device only declaration was already processed, skip the
4447+ // host declaration.
4448+ return ;
44514449 }
4450+ }
44524451 }
44534452
44544453 // clang::ParseAST ensures that we emit the SYCL devices at the end, so
0 commit comments