summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/StackColoring.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/StackColoring.cpp')
-rw-r--r--llvm/lib/CodeGen/StackColoring.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/StackColoring.cpp b/llvm/lib/CodeGen/StackColoring.cpp
index f9d1eaf0307..0bd941e64aa 100644
--- a/llvm/lib/CodeGen/StackColoring.cpp
+++ b/llvm/lib/CodeGen/StackColoring.cpp
@@ -39,6 +39,7 @@
#include "llvm/CodeGen/Passes.h"
#include "llvm/CodeGen/SelectionDAGNodes.h"
#include "llvm/CodeGen/SlotIndexes.h"
+#include "llvm/CodeGen/StackProtector.h"
#include "llvm/CodeGen/TargetOpcodes.h"
#include "llvm/CodeGen/WinEHFuncInfo.h"
#include "llvm/Config/llvm-config.h"
@@ -422,6 +423,9 @@ class StackColoring : public MachineFunctionPass {
/// SlotIndex analysis object.
SlotIndexes *Indexes;
+ /// The stack protector object.
+ StackProtector *SP;
+
/// The list of lifetime markers found. These markers are to be removed
/// once the coloring is done.
SmallVector<MachineInstr*, 8> Markers;
@@ -520,11 +524,13 @@ char &llvm::StackColoringID = StackColoring::ID;
INITIALIZE_PASS_BEGIN(StackColoring, DEBUG_TYPE,
"Merge disjoint stack slots", false, false)
INITIALIZE_PASS_DEPENDENCY(SlotIndexes)
+INITIALIZE_PASS_DEPENDENCY(StackProtector)
INITIALIZE_PASS_END(StackColoring, DEBUG_TYPE,
"Merge disjoint stack slots", false, false)
void StackColoring::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<SlotIndexes>();
+ AU.addRequired<StackProtector>();
MachineFunctionPass::getAnalysisUsage(AU);
}
@@ -930,17 +936,9 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
MergedAllocas.insert(From);
MergedAllocas.insert(To);
- // Transfer the stack protector layout tag, but make sure that SSPLK_AddrOf
- // does not overwrite SSPLK_SmallArray or SSPLK_LargeArray, and make sure
- // that SSPLK_SmallArray does not overwrite SSPLK_LargeArray.
- MachineFrameInfo::SSPLayoutKind FromKind
- = MFI->getObjectSSPLayout(SI.first);
- MachineFrameInfo::SSPLayoutKind ToKind = MFI->getObjectSSPLayout(SI.second);
- if (FromKind != MachineFrameInfo::SSPLK_None &&
- (ToKind == MachineFrameInfo::SSPLK_None ||
- (ToKind != MachineFrameInfo::SSPLK_LargeArray &&
- FromKind != MachineFrameInfo::SSPLK_AddrOf)))
- MFI->setObjectSSPLayout(SI.second, FromKind);
+ // Allow the stack protector to adjust its value map to account for the
+ // upcoming replacement.
+ SP->adjustForColoring(From, To);
// The new alloca might not be valid in a llvm.dbg.declare for this
// variable, so undef out the use to make the verifier happy.
@@ -1141,6 +1139,7 @@ bool StackColoring::runOnMachineFunction(MachineFunction &Func) {
MF = &Func;
MFI = &MF->getFrameInfo();
Indexes = &getAnalysis<SlotIndexes>();
+ SP = &getAnalysis<StackProtector>();
BlockLiveness.clear();
BasicBlocks.clear();
BasicBlockNumbering.clear();
OpenPOWER on IntegriCloud