1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[SafeStack,NFC] Move ClColoring into SafeStack.cpp

This allows to reuse the code in other components.
This commit is contained in:
Vitaly Buka 2020-06-14 15:32:07 -07:00
parent caee47ac16
commit 6289daf91f
2 changed files with 10 additions and 15 deletions

View File

@ -18,6 +18,7 @@
#include "SafeStackLayout.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/Statistic.h"
@ -95,6 +96,10 @@ static cl::opt<bool>
SafeStackUsePointerAddress("safestack-use-pointer-address",
cl::init(false), cl::Hidden);
// Disabled by default due to PR32143.
static cl::opt<bool> ClColoring("safe-stack-coloring",
cl::desc("enable safe stack coloring"),
cl::Hidden, cl::init(false));
namespace {
@ -493,7 +498,9 @@ Value *SafeStack::moveStaticAllocasToUnsafeStack(
DIBuilder DIB(*F.getParent());
StackColoring SSC(F, StaticAllocas);
SSC.run();
static const StackColoring::LiveRange NoColoringRange = {BitVector{1, true}};
if (ClColoring)
SSC.run();
SSC.removeAllMarkers();
// Unsafe stack always grows down.
@ -528,7 +535,8 @@ Value *SafeStack::moveStaticAllocasToUnsafeStack(
unsigned Align =
std::max((unsigned)DL.getPrefTypeAlignment(Ty), AI->getAlignment());
SSL.addObject(AI, Size, Align, SSC.getLiveRange(AI));
SSL.addObject(AI, Size, Align,
ClColoring ? SSC.getLiveRange(AI) : NoColoringRange);
}
SSL.computeLayout();

View File

@ -26,11 +26,6 @@ using namespace llvm::safestack;
#define DEBUG_TYPE "safestackcoloring"
// Disabled by default due to PR32143.
static cl::opt<bool> ClColoring("safe-stack-coloring",
cl::desc("enable safe stack coloring"),
cl::Hidden, cl::init(false));
const StackColoring::LiveRange &StackColoring::getLiveRange(AllocaInst *AI) {
const auto IT = AllocaNumbering.find(AI);
assert(IT != AllocaNumbering.end());
@ -285,14 +280,6 @@ StackColoring::StackColoring(Function &F, ArrayRef<AllocaInst *> Allocas)
}
void StackColoring::run() {
if (!ClColoring) {
for (auto &R : LiveRanges) {
R.SetMaximum(1);
R.AddRange(0, 1);
}
return;
}
for (auto &R : LiveRanges)
R.SetMaximum(NumInst);
for (unsigned I = 0; I < NumAllocas; ++I)