@@ -3617,7 +3617,7 @@ VarCreationState Compiler<Emitter>::visitDecl(const VarDecl *VD) {
36173617
36183618 auto R = this ->visitVarDecl (VD, /* Toplevel=*/ true );
36193619
3620- if (R.notCreated ())
3620+ if (R.notCreated () || R. dummyCreated () )
36213621 return R;
36223622
36233623 if (R)
@@ -3709,7 +3709,7 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD, bool Topleve
37093709 // This case is EvalEmitter-only. If we won't create any instructions for the
37103710 // initializer anyway, don't bother creating the variable in the first place.
37113711 if (!this ->isActive ())
3712- return VarCreationState::NotCreated () ;
3712+ return VarCreationState::NotCreated;
37133713
37143714 const Expr *Init = VD->getInit ();
37153715 std::optional<PrimType> VarT = classify (VD->getType ());
@@ -3759,12 +3759,16 @@ VarCreationState Compiler<Emitter>::visitVarDecl(const VarDecl *VD, bool Topleve
37593759 return Init && checkDecl () && initGlobal (*GlobalIndex);
37603760 }
37613761
3762- std::optional<unsigned > GlobalIndex = P.createGlobal (VD, Init);
3762+ if (std::optional<unsigned > GlobalIndex = P.createGlobal (VD, Init))
3763+ return !Init || (checkDecl () && initGlobal (*GlobalIndex));
37633764
3764- if (!GlobalIndex)
3765- return false ;
3765+ if (std::optional<unsigned > I = P.getOrCreateDummy (VD)) {
3766+ if (!this ->emitGetPtrGlobal (*I, VD))
3767+ return false ;
3768+ return VarCreationState::DummyCreated;
3769+ }
37663770
3767- return !Init || ( checkDecl () && initGlobal (*GlobalIndex)) ;
3771+ return false ;
37683772 } else {
37693773 InitLinkScope<Emitter> ILS (this , InitLink::Decl (VD));
37703774
@@ -5240,7 +5244,7 @@ bool Compiler<Emitter>::visitDeclRef(const ValueDecl *D, const Expr *E) {
52405244 auto revisit = [&](const VarDecl *VD) -> bool {
52415245 auto VarState = this ->visitDecl (VD);
52425246
5243- if (VarState.notCreated ())
5247+ if (VarState.notCreated () || VarState. dummyCreated () )
52445248 return true ;
52455249 if (!VarState)
52465250 return false ;
0 commit comments