[PATCH] D45331: [StackProtector] Ignore certain intrinsics when calculating sspstrong heuristic.

Matt Davis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 5 11:34:00 PDT 2018


mattd created this revision.
mattd added reviewers: void, timshen.

The 'strong' StackProtector heuristic takes into consideration call instructions.
Certain intrinsics, such as lifetime.start, can cause the
StackProtector to protect functions that do not need to be protected.

Specifically, a volatile variable, (not optimized away), but belonging to a stack
allocation will encourage a llvm.lifetime.start to be inserted during
compilation. Because that intrinsic is a 'call' the strong StackProtector
will see that the alloca'd variable is being passed to a call instruction, and
insert a stack protector. In this case the intrinsic isn't really lowered to a
call. This can cause unnecessary stack checking, at the cost of additional
(wasted) CPU cycles.

In the future we should rely on TargetTransformInfo::isLoweredToCall, but as of
now that routine considers all intrinsics as not being lowerable. That needs
to be corrected, and such a change is on my list of things to get moving on.

As a side note, the updated stack-protector-dbginfo.ll test always seems to
pass.  I never see the dbg.declare/dbg.value reaching the
StackProtector::HasAddressTaken, but I don't see any code excluding dbg
intrinsic calls either, so I think it's the safest thing to do.


https://reviews.llvm.org/D45331

Files:
  lib/CodeGen/StackProtector.cpp
  test/CodeGen/X86/stack-protector-dbginfo.ll
  test/CodeGen/X86/stack-protector.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45331.141185.patch
Type: text/x-patch
Size: 4754 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180405/e4679a54/attachment.bin>


More information about the llvm-commits mailing list