llvm / llvm/llvm-project

[CIR] Implement handling for conditional lifetime cleanups

Open
#178,551 3 comments 0 reactions 1 assignee Claimed by @andykaylor View on GitHub
ClangIR
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

There are some situations where cleanups must be conditionally deactivated while they are still on the EHStack. See `ConditionalLifetimeExtended` with the `clang/test/CodeGenCXX/control-flow-in-stmt-expr.cpp` test for an example of code that triggers this condition.

This is handled in classic codegen by introducing a compiler-generated flag value which is set when the cleanup should be active and clear when the cleanup should not be active. This flag is then tested before the cleanup code is executed. We will likely want to use a similar solution in CIR, but we will need a way to represent this condition within the structured (`cir.cleanup.scope`) representation in CIR.

When this feature is implemented, the Clang IR EH design document (`clang/docs/ClangIRCleanupAndEHDesign.rst`) should be updated to describe the solution used.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.