Skip to content

Commit d56b360

Browse files
committed
Revert ASan Cherry-picks
1 parent 206e1b2 commit d56b360

File tree

7 files changed

+4
-84
lines changed

7 files changed

+4
-84
lines changed

llvm/include/llvm/Transforms/Instrumentation/AddressSanitizerCommon.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ void getAddressSanitizerParams(const Triple &TargetTriple, int LongSize,
5858
bool IsKasan, uint64_t *ShadowBase,
5959
int *MappingScale, bool *OrShadowOffset);
6060

61-
/// Remove memory attributes that are incompatible with the instrumentation
62-
/// added by AddressSanitizer and HWAddressSanitizer.
63-
/// \p ReadsArgMem - indicates whether function arguments may be read by
64-
/// instrumentation and require removing `writeonly` attributes.
65-
void removeASanIncompatibleFnAttributes(Function &F, bool ReadsArgMem);
66-
6761
} // namespace llvm
6862

6963
#endif

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,6 @@ Expected<AddressSanitizerOptions> parseASanPassOptions(StringRef Params) {
743743

744744
if (ParamName == "kernel") {
745745
Result.CompileKernel = true;
746-
} else if (ParamName == "use-after-scope") {
747-
Result.UseAfterScope = true;
748746
} else {
749747
return make_error<StringError>(
750748
formatv("invalid AddressSanitizer pass parameter '{0}' ", ParamName)

llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -612,45 +612,6 @@ void getAddressSanitizerParams(const Triple &TargetTriple, int LongSize,
612612
*OrShadowOffset = Mapping.OrShadowOffset;
613613
}
614614

615-
void removeASanIncompatibleFnAttributes(Function &F, bool ReadsArgMem) {
616-
// Sanitizer checks read from shadow, which invalidates memory(argmem: *).
617-
//
618-
// This is not only true for sanitized functions, because AttrInfer can
619-
// infer those attributes on libc functions, which is not true if those
620-
// are instrumented (Android) or intercepted.
621-
//
622-
// We might want to model ASan shadow memory more opaquely to get rid of
623-
// this problem altogether, by hiding the shadow memory write in an
624-
// intrinsic, essentially like in the AArch64StackTagging pass. But that's
625-
// for another day.
626-
627-
// The API is weird. `onlyReadsMemory` actually means "does not write", and
628-
// `onlyWritesMemory` actually means "does not read". So we reconstruct
629-
// "accesses memory" && "does not read" <=> "writes".
630-
bool Changed = false;
631-
if (!F.doesNotAccessMemory()) {
632-
bool WritesMemory = !F.onlyReadsMemory();
633-
bool ReadsMemory = !F.onlyWritesMemory();
634-
if ((WritesMemory && !ReadsMemory) || F.onlyAccessesArgMemory()) {
635-
F.removeFnAttr(Attribute::Memory);
636-
Changed = true;
637-
}
638-
}
639-
if (ReadsArgMem) {
640-
for (Argument &A : F.args()) {
641-
if (A.hasAttribute(Attribute::WriteOnly)) {
642-
A.removeAttr(Attribute::WriteOnly);
643-
Changed = true;
644-
}
645-
}
646-
}
647-
if (Changed) {
648-
// nobuiltin makes sure later passes don't restore assumptions about
649-
// the function.
650-
F.addFnAttr(Attribute::NoBuiltin);
651-
}
652-
}
653-
654615
ASanAccessInfo::ASanAccessInfo(int32_t Packed)
655616
: Packed(Packed),
656617
AccessSizeIndex((Packed >> kAccessSizeIndexShift) & kAccessSizeIndexMask),
@@ -1276,9 +1237,7 @@ void AddressSanitizerPass::printPipeline(
12761237
OS, MapClassName2PassName);
12771238
OS << '<';
12781239
if (Options.CompileKernel)
1279-
OS << "kernel;";
1280-
if (Options.UseAfterScope)
1281-
OS << "use-after-scope";
1240+
OS << "kernel";
12821241
OS << '>';
12831242
}
12841243

@@ -2771,9 +2730,6 @@ int ModuleAddressSanitizer::GetAsanVersion(const Module &M) const {
27712730
bool ModuleAddressSanitizer::instrumentModule(Module &M) {
27722731
initializeCallbacks(M);
27732732

2774-
for (Function &F : M)
2775-
removeASanIncompatibleFnAttributes(F, /*ReadsArgMem=*/false);
2776-
27772733
// Create a module constructor. A destructor is created lazily because not all
27782734
// platforms, and not all modules need it.
27792735
if (ConstructorKind == AsanCtorKind::Global) {

llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,11 +594,6 @@ void HWAddressSanitizer::initializeModule() {
594594
LLVM_DEBUG(dbgs() << "Init " << M.getName() << "\n");
595595
TargetTriple = Triple(M.getTargetTriple());
596596

597-
// HWASan may do short granule checks on function arguments read from the
598-
// argument memory (last byte of the granule), which invalidates writeonly.
599-
for (Function &F : M.functions())
600-
removeASanIncompatibleFnAttributes(F, /*ReadsArgMem=*/true);
601-
602597
// x86_64 currently has two modes:
603598
// - Intel LAM (default)
604599
// - pointer aliasing (heap only)

llvm/test/Instrumentation/AddressSanitizer/AMDGPU/asan_instrument_mem_intrinsics.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ declare void @llvm.memset.p5.i32(ptr addrspace(5) nocapture writeonly, i8, i32,
186186

187187
define void @test_mem_intrinsic_memcpy(ptr %dest0,ptr %src0,ptr addrspace(1) %dest1,ptr addrspace(1) %src1,ptr addrspace(2) %dest2,ptr addrspace(2) %src2,ptr addrspace(3) %dest3,ptr addrspace(3) %src3,ptr addrspace(4) %dest4,ptr addrspace(4) %src4,ptr addrspace(5) %dest5,ptr addrspace(5) %src5) #0 {
188188
entry:
189-
;CHECK: define void @test_mem_intrinsic_memcpy(ptr [[DEST0:%.*]], ptr [[SRC0:%.*]], ptr addrspace(1) [[DEST1:%.*]], ptr addrspace(1) [[SRC1:%.*]], ptr addrspace(2) [[DEST2:%.*]], ptr addrspace(2) [[SRC2:%.*]], ptr addrspace(3) [[DEST3:%.*]], ptr addrspace(3) [[SRC3:%.*]], ptr addrspace(4) [[DEST4:%.*]], ptr addrspace(4) [[SRC4:%.*]], ptr addrspace(5) [[DEST5:%.*]], ptr addrspace(5) [[SRC5:%.*]]){{.*}} {
189+
;CHECK: define void @test_mem_intrinsic_memcpy(ptr [[DEST0:%.*]], ptr [[SRC0:%.*]], ptr addrspace(1) [[DEST1:%.*]], ptr addrspace(1) [[SRC1:%.*]], ptr addrspace(2) [[DEST2:%.*]], ptr addrspace(2) [[SRC2:%.*]], ptr addrspace(3) [[DEST3:%.*]], ptr addrspace(3) [[SRC3:%.*]], ptr addrspace(4) [[DEST4:%.*]], ptr addrspace(4) [[SRC4:%.*]], ptr addrspace(5) [[DEST5:%.*]], ptr addrspace(5) [[SRC5:%.*]]) #2 {
190190
;CHECK-NEXT: entry:
191191
;CHECK-NEXT: [[VR0:%.*]] = call ptr @__asan_memcpy(ptr [[DEST0]], ptr [[SRC0]], i64 64)
192192
;CHECK-NEXT: [[VR1:%.*]] = addrspacecast ptr addrspace(1) [[SRC1]] to ptr
@@ -469,7 +469,7 @@ entry:
469469

470470
define void @test_mem_intrinsic_memmove(ptr %dest0,ptr %src0,ptr addrspace(1) %dest1,ptr addrspace(1) %src1,ptr addrspace(2) %dest2,ptr addrspace(2) %src2,ptr addrspace(3) %dest3,ptr addrspace(3) %src3,ptr addrspace(4) %dest4,ptr addrspace(4) %src4,ptr addrspace(5) %dest5,ptr addrspace(5) %src5) #0 {
471471
entry:
472-
;CHECK: define void @test_mem_intrinsic_memmove(ptr [[DEST0:%.*]], ptr [[SRC0:%.*]], ptr addrspace(1) [[DEST1:%.*]], ptr addrspace(1) [[SRC1:%.*]], ptr addrspace(2) [[DEST2:%.*]], ptr addrspace(2) [[SRC2:%.*]], ptr addrspace(3) [[DEST3:%.*]], ptr addrspace(3) [[SRC3:%.*]], ptr addrspace(4) [[DEST4:%.*]], ptr addrspace(4) [[SRC4:%.*]], ptr addrspace(5) [[DEST5:%.*]], ptr addrspace(5) [[SRC5:%.*]]){{.*}} {
472+
;CHECK: define void @test_mem_intrinsic_memmove(ptr [[DEST0:%.*]], ptr [[SRC0:%.*]], ptr addrspace(1) [[DEST1:%.*]], ptr addrspace(1) [[SRC1:%.*]], ptr addrspace(2) [[DEST2:%.*]], ptr addrspace(2) [[SRC2:%.*]], ptr addrspace(3) [[DEST3:%.*]], ptr addrspace(3) [[SRC3:%.*]], ptr addrspace(4) [[DEST4:%.*]], ptr addrspace(4) [[SRC4:%.*]], ptr addrspace(5) [[DEST5:%.*]], ptr addrspace(5) [[SRC5:%.*]]) #2 {
473473
;CHECK-NEXT: entry:
474474
;CHECK-NEXT: [[VR0:%.*]] = call ptr @__asan_memmove(ptr [[DEST0]], ptr [[SRC0]], i64 64)
475475
;CHECK-NEXT: [[VR1:%.*]] = addrspacecast ptr addrspace(1) [[SRC1]] to ptr
@@ -753,7 +753,7 @@ entry:
753753

754754
define void @test_mem_intrinsic_memset(ptr %ptr0,ptr addrspace(1) %ptr1,ptr addrspace(2) %ptr2,ptr addrspace(3) %ptr3,ptr addrspace(4) %ptr4,ptr addrspace(5) %ptr5) #0{
755755
entry:
756-
;CHECK: define void @test_mem_intrinsic_memset(ptr [[PTR0:%.*]], ptr addrspace(1) [[PTR1:%.*]], ptr addrspace(2) [[PTR2:%.*]], ptr addrspace(3) [[PTR3:%.*]], ptr addrspace(4) [[PTR4:%.*]], ptr addrspace(5) [[PTR5:%.*]]){{.*}} {
756+
;CHECK: define void @test_mem_intrinsic_memset(ptr [[PTR0:%.*]], ptr addrspace(1) [[PTR1:%.*]], ptr addrspace(2) [[PTR2:%.*]], ptr addrspace(3) [[PTR3:%.*]], ptr addrspace(4) [[PTR4:%.*]], ptr addrspace(5) [[PTR5:%.*]]) #2 {
757757
;CHECK-NEXT: entry:
758758
;CHECK-NEXT: [[VR0:%.*]] = call ptr @__asan_memset(ptr [[PTR0]], i32 1, i64 128)
759759
;CHECK-NEXT: [[VR1:%.*]] = addrspacecast ptr addrspace(1) [[PTR1]] to ptr

llvm/test/Instrumentation/AddressSanitizer/remove-memory-effects.ll

Lines changed: 0 additions & 20 deletions
This file was deleted.

llvm/test/Other/new-pm-print-pipeline.ll

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,3 @@
120120

121121
; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='speculative-execution<only-if-divergent-target>' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-36
122122
; CHECK-36: function(speculative-execution<only-if-divergent-target>)
123-
124-
; RUN: opt -disable-output -disable-verify -print-pipeline-passes -passes='module(asan<>,asan<kernel;use-after-scope>)' < %s | FileCheck %s --match-full-lines --check-prefixes=CHECK-37
125-
; CHECK-37: asan<>,asan<kernel;use-after-scope>

0 commit comments

Comments
 (0)