llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

We only ever use this value to verify that  a frame has cleaned up after 
itself, i.e. in assertions.

---
Full diff: https://github.com/llvm/llvm-project/pull/202294.diff


4 Files Affected:

- (modified) clang/lib/AST/ByteCode/Disasm.cpp (+2) 
- (modified) clang/lib/AST/ByteCode/Interp.h (+6) 
- (modified) clang/lib/AST/ByteCode/InterpFrame.cpp (+5-3) 
- (modified) clang/lib/AST/ByteCode/InterpFrame.h (+5-1) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/Disasm.cpp 
b/clang/lib/AST/ByteCode/Disasm.cpp
index cf7afcd6d4b1e..4caf830a0a1b4 100644
--- a/clang/lib/AST/ByteCode/Disasm.cpp
+++ b/clang/lib/AST/ByteCode/Disasm.cpp
@@ -570,7 +570,9 @@ LLVM_DUMP_METHOD void InterpFrame::dump(llvm::raw_ostream 
&OS,
   OS.indent(Spaces) << "Depth: " << Depth << "\n";
   OS.indent(Spaces) << "ArgSize: " << ArgSize << "\n";
   OS.indent(Spaces) << "Args: " << (void *)Args << "\n";
+#ifndef NDEBUG
   OS.indent(Spaces) << "FrameOffset: " << FrameOffset << "\n";
+#endif
   OS.indent(Spaces) << "FrameSize: " << (Func ? Func->getFrameSize() : 0)
                     << "\n";
 
diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index d2ca122d0e805..b9cdd6aba4027 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -260,7 +260,10 @@ PRESERVE_NONE bool Ret(InterpState &S, CodePtr &PC) {
   const T &Ret = S.Stk.pop<T>();
 
   assert(S.Current);
+
+#ifndef NDEBUG
   assert(S.Current->getFrameOffset() == S.Stk.size() && "Invalid frame");
+#endif
   if (!S.checkingPotentialConstantExpression() || S.Current->Caller)
     cleanupAfterFunctionCall(S, PC, S.Current->getFunction());
 
@@ -280,7 +283,10 @@ PRESERVE_NONE bool Ret(InterpState &S, CodePtr &PC) {
 }
 
 PRESERVE_NONE inline bool RetVoid(InterpState &S, CodePtr &PC) {
+
+#ifndef NDEBUG
   assert(S.Current->getFrameOffset() == S.Stk.size() && "Invalid frame");
+#endif
 
   if (!S.checkingPotentialConstantExpression() || S.Current->Caller)
     cleanupAfterFunctionCall(S, PC, S.Current->getFunction());
diff --git a/clang/lib/AST/ByteCode/InterpFrame.cpp 
b/clang/lib/AST/ByteCode/InterpFrame.cpp
index 9c9318fe0e55a..bde3e11451602 100644
--- a/clang/lib/AST/ByteCode/InterpFrame.cpp
+++ b/clang/lib/AST/ByteCode/InterpFrame.cpp
@@ -25,13 +25,15 @@ using namespace clang::interp;
 
 InterpFrame::InterpFrame(InterpState &S)
     : Caller(nullptr), S(S), Depth(0), Func(nullptr), RetPC(CodePtr()),
-      ArgSize(0), Args(nullptr), FrameOffset(0) {}
+      ArgSize(0), Args(nullptr) {}
 
 InterpFrame::InterpFrame(InterpState &S, const Function *Func,
                          InterpFrame *Caller, CodePtr RetPC, unsigned ArgSize)
     : Caller(Caller), S(S), Depth(Caller ? Caller->Depth + 1 : 0), Func(Func),
-      RetPC(RetPC), ArgSize(ArgSize), Args(static_cast<char *>(S.Stk.top())),
-      FrameOffset(S.Stk.size()) {
+      RetPC(RetPC), ArgSize(ArgSize), Args(static_cast<char *>(S.Stk.top())) {
+#ifndef NDEBUG
+  FrameOffset = S.Stk.size();
+#endif
 
   if (!Func)
     return;
diff --git a/clang/lib/AST/ByteCode/InterpFrame.h 
b/clang/lib/AST/ByteCode/InterpFrame.h
index 7dbf58c23fd5c..4d772e1b55f46 100644
--- a/clang/lib/AST/ByteCode/InterpFrame.h
+++ b/clang/lib/AST/ByteCode/InterpFrame.h
@@ -92,8 +92,10 @@ class InterpFrame final : public Frame {
   /// Returns the current function.
   const Function *getFunction() const { return Func; }
 
+#ifndef NDEBUG
   /// Returns the offset on the stack at which the frame starts.
   size_t getFrameOffset() const { return FrameOffset; }
+#endif
 
   /// Returns the value of a local variable.
   template <typename T> const T &getLocal(unsigned Offset) const {
@@ -223,8 +225,10 @@ class InterpFrame final : public Frame {
   const unsigned ArgSize;
   /// Pointer to the arguments in the callee's frame.
   char *Args = nullptr;
+#ifndef NDEBUG
   /// Offset on the stack at entry.
-  const size_t FrameOffset;
+  size_t FrameOffset = 0;
+#endif
 
 public:
   unsigned MSVCConstexprAllowed = 0;

``````````

</details>


https://github.com/llvm/llvm-project/pull/202294
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to