Skip to content

Commit

Permalink
Revert "[EfficiencySanitizer] Adds shadow memory parameters for 40-bi…
Browse files Browse the repository at this point in the history
…t virtual memory address."

This reverts commit r280796, as it broke the AArch64 bots for no reason.

The tests were passing and we should try to keep them passing, so a proper
review should make that happen.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@280802 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
rengolin committed Sep 7, 2016
1 parent c7d7511 commit 17c896a
Showing 1 changed file with 9 additions and 34 deletions.
43 changes: 9 additions & 34 deletions lib/Transforms/Instrumentation/EfficiencySanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,23 +99,12 @@ static const char *const EsanWhichToolName = "__esan_which_tool";
// FIXME: Try to place these shadow constants, the names of the __esan_*
// interface functions, and the ToolType enum into a header shared between
// llvm and compiler-rt.
struct ShadowMemoryParams {
uint64_t ShadowMask;
uint64_t ShadowOffs[3];
} ShadowParams;

static const ShadowMemoryParams ShadowParams48 = {
0x00000fffffffffffull,
{
0x0000130000000000ull, 0x0000220000000000ull, 0x0000440000000000ull,
}};

static const ShadowMemoryParams ShadowParams40 = {
0x0fffffffffull,
{
0x1300000000ull, 0x2200000000ull, 0x4400000000ull,
}};

static const uint64_t ShadowMask = 0x00000fffffffffffull;
static const uint64_t ShadowOffs[3] = { // Indexed by scale
0x0000130000000000ull,
0x0000220000000000ull,
0x0000440000000000ull,
};
// This array is indexed by the ToolType enum.
static const int ShadowScale[] = {
0, // ESAN_None.
Expand Down Expand Up @@ -539,20 +528,6 @@ void EfficiencySanitizer::createDestructor(Module &M, Constant *ToolInfoArg) {
}

bool EfficiencySanitizer::initOnModule(Module &M) {

Triple TargetTriple(M.getTargetTriple());
switch (TargetTriple.getArch()) {
case Triple::x86_64:
ShadowParams = ShadowParams48;
break;
case Triple::mips64:
case Triple::mips64el:
ShadowParams = ShadowParams40;
break;
default:
report_fatal_error("unsupported architecture");
}

Ctx = &M.getContext();
const DataLayout &DL = M.getDataLayout();
IRBuilder<> IRB(M.getContext());
Expand Down Expand Up @@ -584,13 +559,13 @@ bool EfficiencySanitizer::initOnModule(Module &M) {

Value *EfficiencySanitizer::appToShadow(Value *Shadow, IRBuilder<> &IRB) {
// Shadow = ((App & Mask) + Offs) >> Scale
Shadow = IRB.CreateAnd(Shadow, ConstantInt::get(IntptrTy, ShadowParams.ShadowMask));
Shadow = IRB.CreateAnd(Shadow, ConstantInt::get(IntptrTy, ShadowMask));
uint64_t Offs;
int Scale = ShadowScale[Options.ToolType];
if (Scale <= 2)
Offs = ShadowParams.ShadowOffs[Scale];
Offs = ShadowOffs[Scale];
else
Offs = ShadowParams.ShadowOffs[0] << Scale;
Offs = ShadowOffs[0] << Scale;
Shadow = IRB.CreateAdd(Shadow, ConstantInt::get(IntptrTy, Offs));
if (Scale > 0)
Shadow = IRB.CreateLShr(Shadow, Scale);
Expand Down

0 comments on commit 17c896a

Please sign in to comment.