diff options
| author | Sagar Thakur <sagar.thakur@imgtec.com> | 2016-10-06 09:52:06 +0000 |
|---|---|---|
| committer | Sagar Thakur <sagar.thakur@imgtec.com> | 2016-10-06 09:52:06 +0000 |
| commit | f9292220dc8f156c0ec042b104e65f45d357b7de (patch) | |
| tree | dc5f784da29baed79ac617951f88b1a048cbe24f /llvm | |
| parent | 6f4bc4f68db54bab350c87e0374e370dfc15442b (diff) | |
| download | bcm5719-llvm-f9292220dc8f156c0ec042b104e65f45d357b7de.tar.gz bcm5719-llvm-f9292220dc8f156c0ec042b104e65f45d357b7de.zip | |
[EfficiencySanitizer] Adds shadow memory parameters for 40-bit virtual memory address.
Adding 40-bit shadow memory parameters because MIPS64 uses 40-bit virtual memory addresses.
Reviewed by rengolin.
Differential: https://reviews.llvm.org/D23801
llvm-svn: 283433
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp index 735728a7d41..3bd666be7b9 100644 --- a/llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/EfficiencySanitizer.cpp @@ -99,12 +99,23 @@ 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. -static const uint64_t ShadowMask = 0x00000fffffffffffull; -static const uint64_t ShadowOffs[3] = { // Indexed by scale - 0x0000130000000000ull, - 0x0000220000000000ull, - 0x0000440000000000ull, -}; +struct ShadowMemoryParams { + uint64_t ShadowMask; + uint64_t ShadowOffs[3]; +} ShadowParams; + +static const ShadowMemoryParams ShadowParams47 = { + 0x00000fffffffffffull, + { + 0x0000130000000000ull, 0x0000220000000000ull, 0x0000440000000000ull, + }}; + +static const ShadowMemoryParams ShadowParams40 = { + 0x0fffffffffull, + { + 0x1300000000ull, 0x2200000000ull, 0x4400000000ull, + }}; + // This array is indexed by the ToolType enum. static const int ShadowScale[] = { 0, // ESAN_None. @@ -528,6 +539,13 @@ void EfficiencySanitizer::createDestructor(Module &M, Constant *ToolInfoArg) { } bool EfficiencySanitizer::initOnModule(Module &M) { + + Triple TargetTriple(M.getTargetTriple()); + if (TargetTriple.getArch() == Triple::mips64 || TargetTriple.getArch() == Triple::mips64el) + ShadowParams = ShadowParams40; + else + ShadowParams = ShadowParams47; + Ctx = &M.getContext(); const DataLayout &DL = M.getDataLayout(); IRBuilder<> IRB(M.getContext()); @@ -559,13 +577,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, ShadowMask)); + Shadow = IRB.CreateAnd(Shadow, ConstantInt::get(IntptrTy, ShadowParams.ShadowMask)); uint64_t Offs; int Scale = ShadowScale[Options.ToolType]; if (Scale <= 2) - Offs = ShadowOffs[Scale]; + Offs = ShadowParams.ShadowOffs[Scale]; else - Offs = ShadowOffs[0] << Scale; + Offs = ShadowParams.ShadowOffs[0] << Scale; Shadow = IRB.CreateAdd(Shadow, ConstantInt::get(IntptrTy, Offs)); if (Scale > 0) Shadow = IRB.CreateLShr(Shadow, Scale); |

