just because we're being told to evaluate it twice. This sometimes
happens when a variable is evaluated again during codegen.
Differential Revision: https://reviews.llvm.org/D147535
std::optional<PrimType> VarT = classify(VD->getType());
if (shouldBeGloballyIndexed(VD)) {
- std::optional<unsigned> GlobalIndex = P.getOrCreateGlobal(VD, Init);
+ // We've already seen and initialized this global.
+ if (P.getGlobal(VD))
+ return true;
+
+ std::optional<unsigned> GlobalIndex = P.createGlobal(VD, Init);
if (!GlobalIndex)
return this->bail(VD);