[clang] [llvm] [clang-cl] Use MSVC's "GS buffer" heuristic for the default /GS (PR #225626)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 13 18:10:32 PDT 2026


https://github.com/efriedma-quic commented:

> (a) pursue the GS buffer heuristic the way it's done here in this PR (adding a new heuristic mode into LLVM), and then follow-up with the refactor of removing the notion of the GS mode from LLVM in favor of marking all allocas in Clang (I'm happy to take on that task).

Assume we extend `stack-protector` metadata to allow specifying whether an alloca counts as a large array, small array, or neither, similar to what like this patch does.  To simplify things, add an additional mode to explicitly mark an alloca as "protectable, but not a large alloca or a small alloca".  Then simplest mode we can could implement that allows matching the current semantics is the following:

- Determine whether an alloca is a 'large array', a 'small array', or neither based on `stack-protector` metadata.  Emit a stack protector if there's any any arrays, or any possibly-out-of-bounds use of any alloca not opted out.  Layout the stack based on the `stack-protector` metadata.

For functions where all allocas have `stack-protector` metadata, this is equivalent to sspstrong: all the decisions that distinguish sspstrong from any other mode are controlled by the metadata.  So I'm not sure we need a new mode, just new metadata.

https://github.com/llvm/llvm-project/pull/225626


More information about the cfe-commits mailing list