================ @@ -9187,18 +9210,30 @@ call ptr @malloc(i64 64), !alloc_token !0 #### '`stack-protector`' Metadata -The `stack-protector` metadata may be attached to alloca instructions. An -alloca instruction with this metadata and value `i32 0` will be skipped when -deciding whether a given function requires a stack protector. The function -may still use a stack protector, if other criteria determine it needs one. +The `stack-protector` metadata may be attached to alloca instructions. It +overrides, for that one allocation, the heuristic that the `ssp`, `sspstrong` +and `"stack-protector-gs-buffer"` function attributes would otherwise apply. +The function may still use a stack protector, if other criteria determine it +needs one. + +The metadata contains a single integer: + +- `0` opts the given alloca out of requiring a stack protector. +- `1` marks the given alloca as a buffer that requires a stack protector, and + that is laid out like a small (`< ssp-buffer-size`) array. +- `2` marks the given alloca as a buffer that requires a stack protector, and + that is laid out like a large (`>= ssp-buffer-size`) array. ---------------- nikic wrote:
I think the semantics here should be that 1/2 say that *if* the alloca is protected, then it will be treated as small/large. It should not imply that the alloca must be protected. Otherwise it's not possible to compose the frontend small/large classification with backend heuristics. This also makes me think that it might be better to make the small/large classification separate metadata, though I'm not sure on that (after all, the combination of !stack-protector=0 + small/large is not meaningful. Though the combination of something like !stack-protector=1 + small/large could be meaningful, if we want to have a way to express the "force stack protection for this alloca" semantics this is currently describing). https://github.com/llvm/llvm-project/pull/225626 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
