Skip to content

Commit 8c8ca4a

Browse files
author
Kamil Kashapov
committed
removed MemoryMapParams, removed EagerCheck shadow copy, f fixed alignment
1 parent a9bbb7e commit 8c8ca4a

File tree

1 file changed

+7
-74
lines changed

1 file changed

+7
-74
lines changed

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp

Lines changed: 7 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -411,30 +411,6 @@ static const MemoryMapParams Linux_X86_64_MemoryMapParams = {
411411
0x100000000000, // OriginBase
412412
};
413413

414-
// riscv32 Linux
415-
static const MemoryMapParams Linux_RISCV32_MemoryMapParams = {
416-
0x000080000000, // AndMask
417-
0, // XorMask (not used)
418-
0, // ShadowBase (not used)
419-
0x000040000000, // OriginBase
420-
};
421-
422-
// riscv64 Linux
423-
static const MemoryMapParams Linux_RISCV64_MemoryMapParams = {
424-
0, // AndMask (not used)
425-
0x008000000000, // XorMask
426-
0, // ShadowBase (not used)
427-
0x002000000000, // OriginBase
428-
};
429-
430-
// mips32 Linux
431-
static const MemoryMapParams Linux_MIPS32_MemoryMapParams = {
432-
0x000080000000, // AndMask
433-
0, // XorMask (not used)
434-
0, // ShadowBase (not used)
435-
0x000040000000, // OriginBase
436-
};
437-
438414
// mips64 Linux
439415
static const MemoryMapParams Linux_MIPS64_MemoryMapParams = {
440416
0, // AndMask (not used)
@@ -443,14 +419,6 @@ static const MemoryMapParams Linux_MIPS64_MemoryMapParams = {
443419
0x002000000000, // OriginBase
444420
};
445421

446-
// ppc32 Linux
447-
static const MemoryMapParams Linux_PowerPC32_MemoryMapParams = {
448-
0x000080000000, // AndMask
449-
0, // XorMask (not used)
450-
0, // ShadowBase (not used)
451-
0x000040000000, // OriginBase
452-
};
453-
454422
// ppc64 Linux
455423
static const MemoryMapParams Linux_PowerPC64_MemoryMapParams = {
456424
0xE00000000000, // AndMask
@@ -467,14 +435,6 @@ static const MemoryMapParams Linux_S390X_MemoryMapParams = {
467435
0x1C0000000000, // OriginBase
468436
};
469437

470-
// ARM32 Linux
471-
static const MemoryMapParams Linux_ARM32_MemoryMapParams = {
472-
0x000080000000, // AndMask
473-
0, // XorMask (not used)
474-
0, // ShadowBase (not used)
475-
0x000040000000, // OriginBase
476-
};
477-
478438
// aarch64 Linux
479439
static const MemoryMapParams Linux_AArch64_MemoryMapParams = {
480440
0, // AndMask (not used)
@@ -528,18 +488,13 @@ static const PlatformMemoryMapParams Linux_X86_MemoryMapParams = {
528488
&Linux_X86_64_MemoryMapParams,
529489
};
530490

531-
static const PlatformMemoryMapParams Linux_RISCV_MemoryMapParams = {
532-
&Linux_RISCV32_MemoryMapParams,
533-
&Linux_RISCV64_MemoryMapParams,
534-
};
535-
536491
static const PlatformMemoryMapParams Linux_MIPS_MemoryMapParams = {
537-
&Linux_MIPS32_MemoryMapParams,
492+
nullptr,
538493
&Linux_MIPS64_MemoryMapParams,
539494
};
540495

541496
static const PlatformMemoryMapParams Linux_PowerPC_MemoryMapParams = {
542-
&Linux_PowerPC32_MemoryMapParams,
497+
nullptr,
543498
&Linux_PowerPC64_MemoryMapParams,
544499
};
545500

@@ -549,7 +504,7 @@ static const PlatformMemoryMapParams Linux_S390_MemoryMapParams = {
549504
};
550505

551506
static const PlatformMemoryMapParams Linux_ARM_MemoryMapParams = {
552-
&Linux_ARM32_MemoryMapParams,
507+
nullptr,
553508
&Linux_AArch64_MemoryMapParams,
554509
};
555510

@@ -1059,35 +1014,17 @@ void MemorySanitizer::initializeModule(Module &M) {
10591014
case Triple::x86_64:
10601015
MapParams = Linux_X86_MemoryMapParams.bits64;
10611016
break;
1062-
case Triple::riscv32:
1063-
MapParams = Linux_RISCV_MemoryMapParams.bits32;
1064-
break;
1065-
case Triple::riscv64:
1066-
MapParams = Linux_RISCV_MemoryMapParams.bits64;
1067-
break;
1068-
case Triple::mips:
1069-
case Triple::mipsel:
1070-
MapParams = Linux_MIPS_MemoryMapParams.bits32;
1071-
break;
10721017
case Triple::mips64:
10731018
case Triple::mips64el:
10741019
MapParams = Linux_MIPS_MemoryMapParams.bits64;
10751020
break;
1076-
case Triple::ppc:
1077-
case Triple::ppcle:
1078-
MapParams = Linux_PowerPC_MemoryMapParams.bits32;
1079-
break;
10801021
case Triple::ppc64:
10811022
case Triple::ppc64le:
10821023
MapParams = Linux_PowerPC_MemoryMapParams.bits64;
10831024
break;
10841025
case Triple::systemz:
10851026
MapParams = Linux_S390_MemoryMapParams.bits64;
10861027
break;
1087-
case Triple::arm:
1088-
case Triple::armeb:
1089-
MapParams = Linux_ARM_MemoryMapParams.bits32;
1090-
break;
10911028
case Triple::aarch64:
10921029
case Triple::aarch64_be:
10931030
MapParams = Linux_ARM_MemoryMapParams.bits64;
@@ -4605,10 +4542,6 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
46054542
Size = DL.getTypeAllocSize(A->getType());
46064543
if (ArgOffset + Size > kParamTLSSize)
46074544
break;
4608-
4609-
Value *ArgShadow = getShadow(A);
4610-
Value *ArgShadowBase = getShadowPtrForArgument(IRB, ArgOffset);
4611-
IRB.CreateAlignedStore(ArgShadow, ArgShadowBase, kShadowTLSAlignment);
46124545
} else {
46134546
Value *Store = nullptr;
46144547
// Compute the Shadow for arg even if it is ByVal, because
@@ -5159,13 +5092,13 @@ struct VarArgHelperBase : public VarArgHelper {
51595092
Value *TailSize =
51605093
ConstantInt::getSigned(IRB.getInt32Ty(), kParamTLSSize - BaseOffset);
51615094
IRB.CreateMemSet(ShadowBase, ConstantInt::getNullValue(IRB.getInt8Ty()),
5162-
TailSize, Align(4));
5095+
TailSize, Align(8));
51635096
}
51645097

51655098
void unpoisonVAListTagForInst(IntrinsicInst &I) {
51665099
IRBuilder<> IRB(&I);
51675100
Value *VAListTag = I.getArgOperand(0);
5168-
const Align Alignment = Align(4);
5101+
const Align Alignment = Align(8);
51695102
auto [ShadowPtr, OriginPtr] = MSV.getShadowOriginPtr(
51705103
VAListTag, IRB, IRB.getInt8Ty(), Alignment, /*isStore*/ true);
51715104
// Unpoison the whole __va_list_tag.
@@ -6146,7 +6079,7 @@ struct VarArgI386Helper : public VarArgHelperBase {
61466079
if (!IsFixed) {
61476080
Base = getShadowPtrForVAArgument(IRB, VAArgOffset, ArgSize);
61486081
if (Base)
6149-
IRB.CreateStore(MSV.getShadow(A), Base);
6082+
IRB.CreateAlignedStore(MSV.getShadow(A), Base, kShadowTLSAlignment);
61506083
VAArgOffset += ArgSize;
61516084
VAArgOffset = alignTo(VAArgOffset, Align(IntptrSize));
61526085
}
@@ -6237,7 +6170,7 @@ struct VarArgGenericHelper : public VarArgHelperBase {
62376170
continue;
62386171
}
62396172
Value *Shadow = MSV.getShadow(A);
6240-
IRB.CreateStore(Shadow, Base);
6173+
IRB.CreateAlignedStore(Shadow, Base, kShadowTLSAlignment);
62416174
}
62426175

62436176
Constant *TotalVAArgSize = ConstantInt::get(MS.IntptrTy, VAArgOffset);

0 commit comments

Comments
 (0)