[PATCH] D19141: [SSP, 2/2] Create llvm.stackguard() intrinsic and lower it to LOAD_STACK_GUARD

Tim Shen via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 14 16:41:38 PDT 2016


timshen created this revision.
timshen added reviewers: echristo, iteratee, gottesmm.
timshen added a subscriber: llvm-commits.
Herald added subscribers: joker.eph, srhines, danalbert, qcolombet, tberghammer.

With this change, ideally IR pass can always generate llvm.stackguard
call to get the stack guard; but for now there are still IR form stack
guard customizations around (see getIRStackGuard()). Future SSP 
customization should go through LOAD_STACK_GUARD.

There is a behavior change: stack guard values are not CSEed anymore,
since we should never reuse the value in case that it has been spilled (and
corrupted). See ssp-guard-spill.ll.

The solution above isn't ideal. Ideally we'd like to know if the guard created in llvm.stackprotector() gets
spilled or not. If the value is spilled, discard the value and reload
stack guard; otherwise reuse the value. This can be done by teaching
register allocator to know how to rematerialize LOAD_STACK_GUARD and 
force a rematerialization (which seems hard), or check for spilling in
expandPostRAPseudo. It only makes sense when the stack guard is a global
variable, which requires more instructions to load. Anyway, this seems to go out 
of the scope of the current patch.

http://reviews.llvm.org/D19141

Files:
  docs/LangRef.rst
  include/llvm/IR/Intrinsics.td
  include/llvm/Target/TargetLowering.h
  lib/CodeGen/MachineCSE.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
  lib/CodeGen/StackProtector.cpp
  lib/Target/AArch64/AArch64ISelLowering.cpp
  lib/Target/X86/X86ISelLowering.cpp
  test/CodeGen/AArch64/stack-guard-remat-bitcast.ll
  test/CodeGen/ARM/warn-stack.ll
  test/CodeGen/X86/2009-02-12-DebugInfoVLA.ll
  test/CodeGen/X86/StackColoring.ll
  test/CodeGen/X86/dynamic-allocas-VLAs.ll
  test/CodeGen/X86/fast-isel-stackcheck.ll
  test/CodeGen/X86/ssp-guard-spill.ll
  test/CodeGen/X86/warn-stack.ll
  test/DebugInfo/X86/vla.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19141.53810.patch
Type: text/x-patch
Size: 22008 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160414/eb160d06/attachment.bin>


More information about the llvm-commits mailing list