[clang] [CodeGen] Store Value* instead of polymorphic Cleanup in EmitCall (PR #238332)
Romaric Jodin via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 4 00:48:49 PST 2026
rjodinchr wrote:
> If SmallVector doesn't allow storing types with vtables in -fsanitize=cfi-unrelated-cast mode, shouldn't we be adding a suppression to SmallVector, instead of changing users of SmallVector?
Adding a suppression (`LLVM_NO_SANITIZE("cfi-unrelated-cast")`) to `SmallVector` would only mask the sanitizer check rather than fixing the underlying issue (`SmallVector` casting raw `void *` storage in `begin()` / `mallocForGrow()` to `T *` before any `T` object has been constructed at that address). Properly reworking `SmallVector` to avoid premature `void *` -> `T *` casts on uninitialized storage without suppressions would be a much larger change across `SmallVector`.
In my CFI testing so far, `SmallVector<CallLifetimeEnd, 2>` was the only `SmallVector` instantiation that triggered this issue. Moreover, `CallLifetimeEnd` only derives from the polymorphic `EHScopeStack::Cleanup` so it can be pushed onto `EHStack`; `CallLifetimeEndAfterCall` never uses `EHStack` or virtual dispatch and only needs the `llvm::Value *` to call `EmitLifetimeEnd`. So even as a first cleanup step, storing `llvm::Value *` directly avoids wrapping each pointer in a polymorphic `Cleanup` object (and lets `SmallVector` use its trivially-copyable specialization).
https://github.com/llvm/llvm-project/pull/238332
More information about the cfe-commits
mailing list