summaryrefslogtreecommitdiff
path: root/include/llvm/CodeGen/StackProtector.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/CodeGen/StackProtector.h')
-rw-r--r--include/llvm/CodeGen/StackProtector.h30
1 files changed, 8 insertions, 22 deletions
diff --git a/include/llvm/CodeGen/StackProtector.h b/include/llvm/CodeGen/StackProtector.h
index 72de212d0df9..a506ac636a17 100644
--- a/include/llvm/CodeGen/StackProtector.h
+++ b/include/llvm/CodeGen/StackProtector.h
@@ -19,6 +19,7 @@
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/Triple.h"
+#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/ValueMap.h"
#include "llvm/Pass.h"
@@ -35,24 +36,11 @@ class TargetMachine;
class Type;
class StackProtector : public FunctionPass {
-public:
- /// SSPLayoutKind. Stack Smashing Protection (SSP) rules require that
- /// vulnerable stack allocations are located close the stack protector.
- enum SSPLayoutKind {
- SSPLK_None, ///< Did not trigger a stack protector. No effect on data
- ///< layout.
- SSPLK_LargeArray, ///< Array or nested array >= SSP-buffer-size. Closest
- ///< to the stack protector.
- SSPLK_SmallArray, ///< Array or nested array < SSP-buffer-size. 2nd closest
- ///< to the stack protector.
- SSPLK_AddrOf ///< The address of this allocation is exposed and
- ///< triggered protection. 3rd closest to the protector.
- };
-
+private:
/// A mapping of AllocaInsts to their required SSP layout.
- using SSPLayoutMap = ValueMap<const AllocaInst *, SSPLayoutKind>;
+ using SSPLayoutMap = DenseMap<const AllocaInst *,
+ MachineFrameInfo::SSPLayoutKind>;
-private:
const TargetMachine *TM = nullptr;
/// TLI - Keep a pointer of a TargetLowering to consult for determining
@@ -70,7 +58,7 @@ private:
/// AllocaInst triggers a stack protector.
SSPLayoutMap Layout;
- /// \brief The minimum size of buffers that will receive stack smashing
+ /// The minimum size of buffers that will receive stack smashing
/// protection when -fstack-protection is used.
unsigned SSPBufferSize = 0;
@@ -107,7 +95,7 @@ private:
bool ContainsProtectableArray(Type *Ty, bool &IsLarge, bool Strong = false,
bool InStruct = false) const;
- /// \brief Check whether a stack allocation has its address taken.
+ /// Check whether a stack allocation has its address taken.
bool HasAddressTaken(const Instruction *AI);
/// RequiresStackProtector - Check whether or not this function needs a
@@ -123,14 +111,12 @@ public:
void getAnalysisUsage(AnalysisUsage &AU) const override;
- SSPLayoutKind getSSPLayout(const AllocaInst *AI) const;
-
// Return true if StackProtector is supposed to be handled by SelectionDAG.
bool shouldEmitSDCheck(const BasicBlock &BB) const;
- void adjustForColoring(const AllocaInst *From, const AllocaInst *To);
-
bool runOnFunction(Function &Fn) override;
+
+ void copyToMachineFrameInfo(MachineFrameInfo &MFI) const;
};
} // end namespace llvm