Timm =?utf-8?q?Bäder?= <tbae...@redhat.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/71...@github.com>


================
@@ -1005,12 +1008,23 @@ bool SetThisField(InterpState &S, CodePtr OpPC, 
uint32_t I) {
 template <PrimType Name, class T = typename PrimConv<Name>::T>
 bool GetGlobal(InterpState &S, CodePtr OpPC, uint32_t I) {
   const Block *B = S.P.getGlobal(I);
+
+  if (!CheckConstant(S, OpPC, B->getDescriptor()))
+    return false;
   if (B->isExtern())
     return false;
   S.Stk.push<T>(B->deref<T>());
   return true;
 }
 
+/// Same as GetGlobal, but without the checks.
+template <PrimType Name, class T = typename PrimConv<Name>::T>
+bool GetGlobalUnchecked(InterpState &S, CodePtr OpPC, uint32_t I) {
+  auto *B = S.P.getGlobal(I);
+  S.Stk.push<T>(B->deref<T>());
+  return true;
+}
+
----------------
AaronBallman wrote:

Would it be reasonable to implement `GetGlobal` in terms of 
`GetGlobalUnchecked` so we can share code, or is that not feasible because 
`GetGlobalUnchecked` will push something to the stack that the checks may then 
reject?

https://github.com/llvm/llvm-project/pull/71919
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to