[PATCH] D147535: [clang][Interp] Don't create global variables more than once
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 4 07:40:26 PDT 2023
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, tahonermann, shafik, erichkeane.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
just because we're being told to evaluate it twice. This sometimes
happens when a variable is evaluated again during codegen.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D147535
Files:
clang/lib/AST/Interp/ByteCodeExprGen.cpp
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===================================================================
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1564,7 +1564,11 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147535.510803.patch
Type: text/x-patch
Size: 630 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230404/c35c07a2/attachment.bin>
More information about the cfe-commits
mailing list