[PATCH] D17094: [safestack] Add -safe-stack-subr-acc-as-unsafe option
Michael LeMay via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 15 11:26:22 PDT 2016
mlemay-intel updated this revision to Diff 53926.
mlemay-intel added a comment.
Check for the separate-stack-seg feature instead of defining a new command line option.
http://reviews.llvm.org/D17094
Files:
include/llvm/Target/TargetLowering.h
lib/CodeGen/SafeStack.cpp
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86ISelLowering.h
Index: lib/Target/X86/X86ISelLowering.h
===================================================================
--- lib/Target/X86/X86ISelLowering.h
+++ lib/Target/X86/X86ISelLowering.h
@@ -655,6 +655,7 @@
unsigned getJumpTableEncoding() const override;
bool useSoftFloat() const override;
+ bool useOnlyLocalStackPointers() const override;
MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override {
return MVT::i8;
Index: lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- lib/Target/X86/X86ISelLowering.cpp
+++ lib/Target/X86/X86ISelLowering.cpp
@@ -1985,6 +1985,10 @@
return Subtarget.useSoftFloat();
}
+bool X86TargetLowering::useOnlyLocalStackPointers() const {
+ return Subtarget.useSeparateStackSeg();
+}
+
const MCExpr *
X86TargetLowering::LowerCustomJumpTableEntry(const MachineJumpTableInfo *MJTI,
const MachineBasicBlock *MBB,
Index: lib/CodeGen/SafeStack.cpp
===================================================================
--- lib/CodeGen/SafeStack.cpp
+++ lib/CodeGen/SafeStack.cpp
@@ -308,6 +308,11 @@
case Instruction::Invoke: {
ImmutableCallSite CS(I);
+ // FIXME: A more precise solution may consider whether particular types
+ // of intrinsics necessitate moving allocations to the unsafe stack.
+ if (TL->useOnlyLocalStackPointers())
+ return false;
+
if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
if (II->getIntrinsicID() == Intrinsic::lifetime_start ||
II->getIntrinsicID() == Intrinsic::lifetime_end)
Index: include/llvm/Target/TargetLowering.h
===================================================================
--- include/llvm/Target/TargetLowering.h
+++ include/llvm/Target/TargetLowering.h
@@ -169,6 +169,13 @@
virtual bool useSoftFloat() const { return false; }
+ /// A target may require that no pointer passed from one function to another
+ /// points to the main stack. Such a target must override this function to
+ /// return true. SafeStack must always be used for such a target, to move
+ /// any stack allocation to the unsafe stack that is the target of a pointer
+ /// passed to a subroutine.
+ virtual bool useOnlyLocalStackPointers() const { return false; }
+
/// Return the pointer type for the given address space, defaults to
/// the pointer type from the data layout.
/// FIXME: The default needs to be removed once all the code is updated.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17094.53926.patch
Type: text/x-patch
Size: 2556 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160415/f492cbd7/attachment.bin>
More information about the llvm-commits
mailing list