[PATCH] D78717: [SystemZ] Implement -fstack-clash-protection

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 7 09:05:44 PDT 2020


jonpa updated this revision to Diff 262670.
jonpa added a comment.

Backend part updated.

- Added probing of the tail of dyn-alloca, with an extra check for zero tail, roughly like GCC. It seems it can be assumed that the alloca size will always be a multiple of 8 bytes, or? I think that is necessary, or there might be final probe partially below SP (if tail is e.g. 4 bytes). Also, if the stack-probe size is 0, an infinite loop would result (assert?), but I suppose that would always be noticeable.

- (re)compute live-ins for the new blocks created in inlineStackProbe() (it seems this is not needed for the probed alloca case). The generated code from inlineStackProbe() does roughly the same as GCC. We could use a brct for the loop instead, or we could try to keep it at 12 or more instructions using multiple exits (like "forced" unrolling), but I suppose maybe the unrolling is the common case, so the loop isn't that important?

- Tests: Not sure if we need all the X86 test cases - for instance stack-clash-medium-natural-probes.ll seems to generate nearly the same code as stack-clash-medium.ll. stack-clash-unknown-call.ll: Changed the called function from memset to something not known, since the point of the test case seemed to be to have a call in the function, which however did not work at first since an XC loop resulted.

- Moved the utility functions to SystemZInstrInfo.cpp as agreed before.

> Huh. I'd probably just use uint64_t everywhere.

I think what confused me a bit was that MCCFIInstruction::createDefCfaOffset() takes an 'int' as argument, but I suppose it's not the end of the world if the CFA offset is possibly broken if the stack frame size ever became greater than -INT32_MIN...?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78717/new/

https://reviews.llvm.org/D78717

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Targets/SystemZ.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/stack-clash-protection.c
  clang/test/Driver/stack-clash-protection-02.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
  llvm/lib/Target/SystemZ/SystemZFrameLowering.h
  llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
  llvm/lib/Target/SystemZ/SystemZISelLowering.h
  llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp
  llvm/lib/Target/SystemZ/SystemZInstrInfo.h
  llvm/lib/Target/SystemZ/SystemZInstrInfo.td
  llvm/lib/Target/SystemZ/SystemZOperators.td
  llvm/test/CodeGen/SystemZ/stack-clash-dynamic-alloca.ll
  llvm/test/CodeGen/SystemZ/stack-clash-large.ll
  llvm/test/CodeGen/SystemZ/stack-clash-medium-natural-probes-mutliple-objects.ll
  llvm/test/CodeGen/SystemZ/stack-clash-medium-natural-probes.ll
  llvm/test/CodeGen/SystemZ/stack-clash-medium.ll
  llvm/test/CodeGen/SystemZ/stack-clash-no-free-probe.ll
  llvm/test/CodeGen/SystemZ/stack-clash-protection.ll
  llvm/test/CodeGen/SystemZ/stack-clash-small.ll
  llvm/test/CodeGen/SystemZ/stack-clash-unknown-call.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78717.262670.patch
Type: text/x-patch
Size: 44576 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200507/a6c6db46/attachment.bin>


More information about the llvm-commits mailing list