This adds a stack probing instruction sequence for dynamic stack
allocations, to protect against stack clash attacks. The instruction
sequence used is the same one used for unknown-size allocations in
function prologues.
Details
Diff Detail
Event Timeline
Seems fine from a GlobalISel perspective, and I'm guessing the stack clashing details will be reviewed in the SelectionDAG patch which adds the test.
llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp | ||
---|---|---|
681 | Why is this custom only for {p0, s64} ? It seems all the existing tests for G_DYN_STACKALLOC are for {p0, s64}, so I'm not sure when the other case is even possible and why we can't use the probing then too. | |
765 | Would it be a good idea to share some of the code between this handler and lowerDynStackAlloc? Maybe add a method to LegalizeHelper that does the allocation and returns the SPTmp. , then the code here would be just | |
llvm/test/CodeGen/AArch64/stack-probing-dynamic.ll | ||
3 | I love that this test has the same checks for GlobalISel and SelectionDAG :) Nitpick: I think it would be nice to also test this in llvm/test/CodeGen/AArch64/GlobalISel/legalize-dyn-alloca.mir, which covers just the legalizer. |
llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp | ||
---|---|---|
681 | This is the only combination of types emitted by the IR translator, but I guess this will emit a non-probed alloca if that ever changes, so I'll change it to assert that the types are what we expect. |
- Assert if types aren't what we expect, instead of emitting an un-probed SP move.
- Share code with LegalizerHelper
- Add MIR tests for the legalizer
Why is this custom only for {p0, s64} ? It seems all the existing tests for G_DYN_STACKALLOC are for {p0, s64}, so I'm not sure when the other case is even possible and why we can't use the probing then too.