llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
When a local scope has been destroyed via `destroyLocals()`, don't do it again
automatically (further calls to `destroyLocals()` keep working, as before).
For
```c++
constexpr void inc4(int &a) {
char c[1];
++a;
}
```
we used to generate:
```
inc4 0x7c6e999e5480
frame size: 64
arg size: 48
rvo: 0
this arg: 0
0 InitScope 0
16 GetParamPtr 0
32 IncPopSint32 1
48 Destroy 0
64 Destroy 0
80 RetVoid
```
and now we generate:
```
inc4 0x7d3b1b1e5480
frame size: 64
arg size: 48
rvo: 0
this arg: 0
0 InitScope 0
16 GetParamPtr 0
32 IncPopSint32 1
48 Destroy 0
64 RetVoid
```
---
Full diff: https://github.com/llvm/llvm-project/pull/220253.diff
1 Files Affected:
- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+3-1)
``````````diff
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp
b/clang/lib/AST/ByteCode/Compiler.cpp
index 55abd51659b46..5a15dc330c7e5 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -116,7 +116,7 @@ template <class Emitter> class LocalScope : public
VariableScope<Emitter> {
/// Emit a Destroy op for this scope.
~LocalScope() override {
- if (!Idx)
+ if (!Idx || ExplicitlyDestroyed)
return;
this->Ctx->emitDestroy(*Idx, SourceInfo{});
removeStoredOpaqueValues();
@@ -130,6 +130,7 @@ template <class Emitter> class LocalScope : public
VariableScope<Emitter> {
// calls to destroyLocals().
bool Success = this->emitDestructors(E);
this->Ctx->emitDestroy(*Idx, E);
+ ExplicitlyDestroyed = true;
return Success;
}
@@ -212,6 +213,7 @@ template <class Emitter> class LocalScope : public
VariableScope<Emitter> {
/// Index of the scope in the chain.
UnsignedOrNone Idx = std::nullopt;
+ bool ExplicitlyDestroyed = false;
};
template <class Emitter> class ArrayIndexScope final {
``````````
</details>
https://github.com/llvm/llvm-project/pull/220253
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits