[llvm-branch-commits] [llvm] 5f991d0 - Revert "[compiler-rt][asan] Add asan checks for __builtin_assume_dereferencab…"
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Apr 22 20:53:01 PDT 2026
Author: Mariusz Borsa
Date: 2026-04-22T20:52:57-07:00
New Revision: 5f991d079478fc117e65c53280024e42ddea28d6
URL: https://github.com/llvm/llvm-project/commit/5f991d079478fc117e65c53280024e42ddea28d6
DIFF: https://github.com/llvm/llvm-project/commit/5f991d079478fc117e65c53280024e42ddea28d6.diff
LOG: Revert "[compiler-rt][asan] Add asan checks for __builtin_assume_dereferencab…"
This reverts commit bf8cf4b7b31b956ea4dfec93b0b4d77b359b188b.
Added:
Modified:
compiler-rt/include/sanitizer/asan_interface.h
compiler-rt/lib/asan/AIX/asan.link_with_main_exec.txt
compiler-rt/lib/asan/asan_errors.cpp
compiler-rt/lib/asan/asan_errors.h
compiler-rt/lib/asan/asan_interface.inc
compiler-rt/lib/asan/asan_report.cpp
compiler-rt/lib/asan/asan_report.h
compiler-rt/lib/asan/asan_rtl.cpp
compiler-rt/test/asan/TestCases/debug_report.cpp
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Removed:
compiler-rt/test/asan/TestCases/assume_dereferenceable.cpp
compiler-rt/test/asan/TestCases/assume_dereferenceable_fully_poisoned.cpp
compiler-rt/test/asan/TestCases/assume_dereferenceable_halt_on_error.cpp
compiler-rt/test/asan/TestCases/assume_dereferenceable_pass.cpp
llvm/test/Instrumentation/AddressSanitizer/assume-dereferenceable.ll
################################################################################
diff --git a/compiler-rt/include/sanitizer/asan_interface.h b/compiler-rt/include/sanitizer/asan_interface.h
index c75a698008b8d..6060d60322287 100644
--- a/compiler-rt/include/sanitizer/asan_interface.h
+++ b/compiler-rt/include/sanitizer/asan_interface.h
@@ -160,10 +160,10 @@ void *SANITIZER_CDECL __asan_get_report_address(void);
/// Gets access type of an ASan error (useful for calling from the debugger).
///
-/// Returns access type (read or write or assumption) if an error has been (or
-/// is being) reported. Otherwise returns 0.
+/// Returns access type (read or write) if an error has been (or is being)
+/// reported. Otherwise returns 0.
///
-/// \returns Access type (0 = read, 1 = write, 2 = assumption).
+/// \returns Access type (0 = read, 1 = write).
int SANITIZER_CDECL __asan_get_report_access_type(void);
/// Gets access size of an ASan error (useful for calling from the debugger).
diff --git a/compiler-rt/lib/asan/AIX/asan.link_with_main_exec.txt b/compiler-rt/lib/asan/AIX/asan.link_with_main_exec.txt
index d3b8e98bd020f..5efc48c262369 100644
--- a/compiler-rt/lib/asan/AIX/asan.link_with_main_exec.txt
+++ b/compiler-rt/lib/asan/AIX/asan.link_with_main_exec.txt
@@ -1,7 +1,5 @@
#! .
__asan_report_load_n
-__asan_report_assume_dereferenceable
-__asan_report_assume_dereferenceable_noabort
__asan_loadN
__asan_report_load1
__asan_load1
diff --git a/compiler-rt/lib/asan/asan_errors.cpp b/compiler-rt/lib/asan/asan_errors.cpp
index 749a50b5bc640..c4100cf7244e3 100644
--- a/compiler-rt/lib/asan/asan_errors.cpp
+++ b/compiler-rt/lib/asan/asan_errors.cpp
@@ -454,14 +454,14 @@ static bool AdjacentShadowValuesAreFullyPoisoned(u8 *s) {
}
ErrorGeneric::ErrorGeneric(u32 tid, uptr pc_, uptr bp_, uptr sp_, uptr addr,
- AccessType access_type_, uptr access_size_)
+ bool is_write_, uptr access_size_)
: ErrorBase(tid),
addr_description(addr, access_size_, /*shouldLockThreadRegistry=*/false),
pc(pc_),
bp(bp_),
sp(sp_),
access_size(access_size_),
- access_type(access_type_),
+ is_write(is_write_),
shadow_val(0) {
scariness.Clear();
if (access_size) {
@@ -472,13 +472,7 @@ ErrorGeneric::ErrorGeneric(u32 tid, uptr pc_, uptr bp_, uptr sp_, uptr addr,
} else if (access_size >= 10) {
scariness.Scare(15, "multi-byte");
}
- if (access_type == AccessType::Write) {
- scariness.Scare(20, "write");
- } else if (access_type == AccessType::Read) {
- scariness.Scare(1, "read");
- } else if (access_type == AccessType::Assumption) {
- scariness.Scare(1, "assumption");
- }
+ is_write ? scariness.Scare(20, "write") : scariness.Scare(1, "read");
// Determine the error type.
bug_descr = "unknown-crash";
@@ -504,8 +498,7 @@ ErrorGeneric::ErrorGeneric(u32 tid, uptr pc_, uptr bp_, uptr sp_, uptr addr,
case kAsanHeapFreeMagic:
bug_descr = "heap-use-after-free";
bug_type_score = 20;
- if (access_type == AccessType::Read)
- read_after_free_bonus = 18;
+ if (!is_write) read_after_free_bonus = 18;
break;
case kAsanStackLeftRedzoneMagic:
bug_descr = "stack-buffer-underflow";
@@ -525,8 +518,7 @@ ErrorGeneric::ErrorGeneric(u32 tid, uptr pc_, uptr bp_, uptr sp_, uptr addr,
case kAsanStackAfterReturnMagic:
bug_descr = "stack-use-after-return";
bug_type_score = 30;
- if (access_type == AccessType::Read)
- read_after_free_bonus = 18;
+ if (!is_write) read_after_free_bonus = 18;
break;
case kAsanUserPoisonedMemoryMagic:
bug_descr = "use-after-poison";
@@ -701,23 +693,9 @@ void ErrorGeneric::Print() {
bug_descr, (void *)addr, (void *)pc, (void *)bp, (void *)sp);
Printf("%s", d.Default());
- const char* access_type = "ACCESS";
- if (access_size) {
- switch (this->access_type) {
- case AccessType::Assumption:
- access_type = "ASSUME";
- break;
- case AccessType::Read:
- access_type = "READ";
- break;
- case AccessType::Write:
- access_type = "WRITE";
- break;
- }
- }
- Printf("%s%s of size %zu at %p thread %s%s\n", d.Access(), access_type,
- access_size, (void*)addr, AsanThreadIdAndName(tid).c_str(),
- d.Default());
+ Printf("%s%s of size %zu at %p thread %s%s\n", d.Access(),
+ access_size ? (is_write ? "WRITE" : "READ") : "ACCESS", access_size,
+ (void *)addr, AsanThreadIdAndName(tid).c_str(), d.Default());
scariness.Print();
GET_STACK_TRACE_FATAL(pc, bp);
diff --git a/compiler-rt/lib/asan/asan_errors.h b/compiler-rt/lib/asan/asan_errors.h
index aee2737933578..9c6843774f376 100644
--- a/compiler-rt/lib/asan/asan_errors.h
+++ b/compiler-rt/lib/asan/asan_errors.h
@@ -423,22 +423,16 @@ struct ErrorInvalidPointerPair : ErrorBase {
};
struct ErrorGeneric : ErrorBase {
- enum class AccessType : u8 {
- Read = 0,
- Write = 1,
- Assumption = 2,
- };
-
AddressDescription addr_description;
uptr pc, bp, sp;
uptr access_size;
const char *bug_descr;
- AccessType access_type;
+ bool is_write;
u8 shadow_val;
ErrorGeneric() = default; // (*)
- ErrorGeneric(u32 tid, uptr pc_, uptr bp_, uptr sp_, uptr addr,
- AccessType access_type_, uptr access_size_);
+ ErrorGeneric(u32 tid, uptr pc_, uptr bp_, uptr sp_, uptr addr, bool is_write_,
+ uptr access_size_);
void Print();
};
diff --git a/compiler-rt/lib/asan/asan_interface.inc b/compiler-rt/lib/asan/asan_interface.inc
index 3c794376fa959..b465356b1e443 100644
--- a/compiler-rt/lib/asan/asan_interface.inc
+++ b/compiler-rt/lib/asan/asan_interface.inc
@@ -93,8 +93,6 @@ INTERFACE_FUNCTION(__asan_report_load8_noabort)
INTERFACE_FUNCTION(__asan_report_load16_noabort)
INTERFACE_FUNCTION(__asan_report_load_n_noabort)
INTERFACE_FUNCTION(__asan_report_present)
-INTERFACE_FUNCTION(__asan_report_assume_dereferenceable)
-INTERFACE_FUNCTION(__asan_report_assume_dereferenceable_noabort)
INTERFACE_FUNCTION(__asan_report_store1)
INTERFACE_FUNCTION(__asan_report_store2)
INTERFACE_FUNCTION(__asan_report_store4)
diff --git a/compiler-rt/lib/asan/asan_report.cpp b/compiler-rt/lib/asan/asan_report.cpp
index 02c503a7ed8ed..e50faf0223212 100644
--- a/compiler-rt/lib/asan/asan_report.cpp
+++ b/compiler-rt/lib/asan/asan_report.cpp
@@ -538,27 +538,11 @@ void ReportGenericError(uptr pc, uptr bp, uptr sp, uptr addr, bool is_write,
(void)exp;
ScopedInErrorReport in_report(fatal);
- ErrorGeneric error(GetCurrentTidOrInvalid(), pc, bp, sp, addr,
- is_write ? ErrorGeneric::AccessType::Write
- : ErrorGeneric::AccessType::Read,
+ ErrorGeneric error(GetCurrentTidOrInvalid(), pc, bp, sp, addr, is_write,
access_size);
in_report.ReportError(error);
}
-void ReportAssumeDereferenceableError(uptr pc, uptr bp, uptr sp, uptr addr,
- uptr dereferenceable_size, bool fatal) {
- if (!fatal && SuppressErrorReport(pc))
- return;
- ENABLE_FRAME_POINTER;
-
- ScopedInErrorReport in_report(fatal);
- ErrorGeneric error(GetCurrentTidOrInvalid(), pc, bp, sp, addr,
- ErrorGeneric::AccessType::Assumption,
- dereferenceable_size);
- error.bug_descr = "dereferenceable-assumption-violation";
- in_report.ReportError(error);
-}
-
} // namespace __asan
// --------------------------- Interface --------------------- {{{1
@@ -616,8 +600,7 @@ uptr __asan_get_report_address() {
int __asan_get_report_access_type() {
if (ScopedInErrorReport::CurrentError().kind == kErrorKindGeneric)
- return static_cast<int>(
- ScopedInErrorReport::CurrentError().Generic.access_type);
+ return ScopedInErrorReport::CurrentError().Generic.is_write;
return 0;
}
diff --git a/compiler-rt/lib/asan/asan_report.h b/compiler-rt/lib/asan/asan_report.h
index 467defa4c64a3..b181849b10f92 100644
--- a/compiler-rt/lib/asan/asan_report.h
+++ b/compiler-rt/lib/asan/asan_report.h
@@ -49,8 +49,6 @@ bool ParseFrameDescription(const char *frame_descr,
// Different kinds of error reports.
void ReportGenericError(uptr pc, uptr bp, uptr sp, uptr addr, bool is_write,
uptr access_size, u32 exp, bool fatal);
-void ReportAssumeDereferenceableError(uptr pc, uptr bp, uptr sp, uptr addr,
- uptr dereferenceable_size, bool fatal);
void ReportDeadlySignal(const SignalContext &sig);
void ReportNewDeleteTypeMismatch(uptr addr, uptr delete_size,
uptr delete_alignment,
diff --git a/compiler-rt/lib/asan/asan_rtl.cpp b/compiler-rt/lib/asan/asan_rtl.cpp
index 9726f8f447b59..c036a13a11029 100644
--- a/compiler-rt/lib/asan/asan_rtl.cpp
+++ b/compiler-rt/lib/asan/asan_rtl.cpp
@@ -156,22 +156,6 @@ void __asan_report_ ## type ## _n_noabort(uptr addr, uptr size) { \
ASAN_REPORT_ERROR_N(load, false)
ASAN_REPORT_ERROR_N(store, true)
-extern "C" NOINLINE INTERFACE_ATTRIBUTE void
-__asan_report_assume_dereferenceable(uptr addr, uptr size) {
- if (__asan_region_is_poisoned(addr, size)) {
- GET_CALLER_PC_BP_SP;
- ReportAssumeDereferenceableError(pc, bp, sp, addr, size, true);
- }
-}
-
-extern "C" NOINLINE INTERFACE_ATTRIBUTE void
-__asan_report_assume_dereferenceable_noabort(uptr addr, uptr size) {
- if (__asan_region_is_poisoned(addr, size)) {
- GET_CALLER_PC_BP_SP;
- ReportAssumeDereferenceableError(pc, bp, sp, addr, size, false);
- }
-}
-
#define ASAN_MEMORY_ACCESS_CALLBACK_BODY(type, is_write, size, exp_arg, fatal) \
uptr sp = MEM_TO_SHADOW(addr); \
uptr s = size <= ASAN_SHADOW_GRANULARITY ? *reinterpret_cast<u8 *>(sp) \
diff --git a/compiler-rt/test/asan/TestCases/assume_dereferenceable.cpp b/compiler-rt/test/asan/TestCases/assume_dereferenceable.cpp
deleted file mode 100644
index f6b33fabbde38..0000000000000
--- a/compiler-rt/test/asan/TestCases/assume_dereferenceable.cpp
+++ /dev/null
@@ -1,87 +0,0 @@
-// RUN: %clangxx_asan -O0 -mllvm -asan-instrument-assume-dereferenceable=1 -fsanitize-recover=address %s -o %t && %env_asan_opts=halt_on_error=0 %run %t 2>&1 | FileCheck %s
-
-#include <stdio.h>
-#include <stdlib.h>
-
-void test_malloc_fully_oob() {
- char *p = (char *)malloc(10);
- fprintf(stderr, "test_malloc_fully_oob\n");
- // CHECK: test_malloc_fully_oob
- // CHECK: ERROR: AddressSanitizer: dereferenceable-assumption-violation on address [[PTR1:0x[0-9a-fA-F]+]]
- // CHECK: ASSUME of size 20 at [[PTR1]] thread T0
- __builtin_assume_dereferenceable(p, 20);
- free(p);
-}
-
-void test_malloc_partial_right() {
- char *p = (char *)malloc(10);
- fprintf(stderr, "test_malloc_partial_right\n");
- // CHECK: test_malloc_partial_right
- // CHECK: ERROR: AddressSanitizer: dereferenceable-assumption-violation on address [[PTR2:0x[0-9a-fA-F]+]]
- // CHECK: ASSUME of size 10 at [[PTR2]] thread T0
- __builtin_assume_dereferenceable(p + 5, 10);
- free(p);
-}
-
-void test_malloc_partial_left() {
- char *p = (char *)malloc(10);
- fprintf(stderr, "test_malloc_partial_left\n");
- // CHECK: test_malloc_partial_left
- // CHECK: ERROR: AddressSanitizer: dereferenceable-assumption-violation on address [[PTR3:0x[0-9a-fA-F]+]]
- // CHECK: ASSUME of size 10 at [[PTR3]] thread T0
- __builtin_assume_dereferenceable(p - 5, 10);
- free(p);
-}
-
-void test_stack_fully_oob(int i) {
- char p[10];
- fprintf(stderr, "test_stack_fully_oob\n");
- // CHECK: test_stack_fully_oob
- // CHECK: ERROR: AddressSanitizer: dereferenceable-assumption-violation on address [[PTR4:0x[0-9a-fA-F]+]]
- // CHECK: ASSUME of size 100 at [[PTR4]] thread T0
- __builtin_assume_dereferenceable(p, 100);
-
- // This is here just to force ASan to emit instrumentation for poisoning
- // redzones around the stack. By default, ASan will not instrument stack
- // allocations that it deems "uninteresting".
- p[i] = 0;
-}
-
-void test_stack_partial_right() {
- char p[10];
- fprintf(stderr, "test_stack_partial_right\n");
- // CHECK: test_stack_partial_right
- // CHECK: ERROR: AddressSanitizer: dereferenceable-assumption-violation on address [[PTR5:0x[0-9a-fA-F]+]]
- // CHECK: ASSUME of size 10 at [[PTR5]] thread T0
- __builtin_assume_dereferenceable(p + 5, 10);
-}
-
-void test_stack_partial_left() {
- char p[10];
- fprintf(stderr, "test_stack_partial_left\n");
- // CHECK: test_stack_partial_left
- // CHECK: ERROR: AddressSanitizer: dereferenceable-assumption-violation on address [[PTR6:0x[0-9a-fA-F]+]]
- // CHECK: ASSUME of size 10 at [[PTR6]] thread T0
- __builtin_assume_dereferenceable(p - 5, 10);
-}
-
-void test_malloc_completely_poisoned() {
- char *p = (char *)malloc(10);
- free(p);
- fprintf(stderr, "test_malloc_completely_poisoned\n");
- // CHECK: test_malloc_completely_poisoned
- // CHECK: ERROR: AddressSanitizer: dereferenceable-assumption-violation on address [[PTR7:0x[0-9a-fA-F]+]]
- // CHECK: ASSUME of size 10 at [[PTR7]] thread T0
- __builtin_assume_dereferenceable(p, 10);
-}
-
-int main() {
- test_malloc_fully_oob();
- test_malloc_partial_right();
- test_malloc_partial_left();
- test_stack_fully_oob(0);
- test_stack_partial_right();
- test_stack_partial_left();
- test_malloc_completely_poisoned();
- return 0;
-}
diff --git a/compiler-rt/test/asan/TestCases/assume_dereferenceable_fully_poisoned.cpp b/compiler-rt/test/asan/TestCases/assume_dereferenceable_fully_poisoned.cpp
deleted file mode 100644
index 962a12b71c70d..0000000000000
--- a/compiler-rt/test/asan/TestCases/assume_dereferenceable_fully_poisoned.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-// RUN: %clangxx_asan -O0 -mllvm -asan-instrument-assume-dereferenceable=1 %s -o %t && not %run %t 2>&1 | FileCheck %s
-
-#include <stdlib.h>
-
-int main() {
- char *p = (char *)malloc(10);
- free(p);
- // CHECK: AddressSanitizer: dereferenceable-assumption-violation
- // CHECK: ASSUME of size 10
- __builtin_assume_dereferenceable(p, 10);
- return 0;
-}
diff --git a/compiler-rt/test/asan/TestCases/assume_dereferenceable_halt_on_error.cpp b/compiler-rt/test/asan/TestCases/assume_dereferenceable_halt_on_error.cpp
deleted file mode 100644
index f382a2955308e..0000000000000
--- a/compiler-rt/test/asan/TestCases/assume_dereferenceable_halt_on_error.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-// RUN: %clangxx_asan -O0 -mllvm -asan-instrument-assume-dereferenceable=1 -fsanitize-recover=address %s -o %t
-// RUN: %env_asan_opts=halt_on_error=1 not %run %t 2>&1 | FileCheck %s
-// RUN: %env_asan_opts=halt_on_error=0 %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER
-
-#include <stdio.h>
-#include <stdlib.h>
-
-int main() {
- char *p = (char *)malloc(10);
-
- // CHECK: ERROR: AddressSanitizer: dereferenceable-assumption-violation on address [[PTR:0x[0-9a-fA-F]+]]
-
- // CHECK-RECOVER: ERROR: AddressSanitizer: dereferenceable-assumption-violation on address [[PTR:0x[0-9a-fA-F]+]]
- __builtin_assume_dereferenceable(p, 20);
- free(p);
-
- fprintf(stderr, "EXECUTED AFTER ERROR\n");
- // CHECK-NOT: EXECUTED AFTER ERROR
- // CHECK-RECOVER: EXECUTED AFTER ERROR
-
- return 0;
-}
diff --git a/compiler-rt/test/asan/TestCases/assume_dereferenceable_pass.cpp b/compiler-rt/test/asan/TestCases/assume_dereferenceable_pass.cpp
deleted file mode 100644
index 9f5a65888df3b..0000000000000
--- a/compiler-rt/test/asan/TestCases/assume_dereferenceable_pass.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-// RUN: %clangxx_asan -O0 -mllvm -asan-instrument-assume-dereferenceable=1 %s -o %t && %run %t
-
-#include <stdlib.h>
-
-void test_pass_1() {
- char *p = (char *)malloc(20);
- __builtin_assume_dereferenceable(p, 10);
- __builtin_assume_dereferenceable(p, 20);
- free(p);
-}
-
-void test_pass_2() {
- char *p = (char *)malloc(10);
- __builtin_assume_dereferenceable(p, 0);
- free(p);
-}
-
-void test_stack_pass_1() {
- char p[20];
- __builtin_assume_dereferenceable(p, 10);
- __builtin_assume_dereferenceable(p, 20);
-}
-
-void test_stack_pass_2() {
- char p[10];
- __builtin_assume_dereferenceable(p, 0);
-}
-
-int main() {
- test_pass_1();
- test_pass_2();
- test_stack_pass_1();
- test_stack_pass_2();
- return 0;
-}
diff --git a/compiler-rt/test/asan/TestCases/debug_report.cpp b/compiler-rt/test/asan/TestCases/debug_report.cpp
index 9147cc9ee94f4..0dbb9f2fb9988 100644
--- a/compiler-rt/test/asan/TestCases/debug_report.cpp
+++ b/compiler-rt/test/asan/TestCases/debug_report.cpp
@@ -45,7 +45,7 @@ __asan_on_error() {
void *bp = __asan_get_report_bp();
void *sp = __asan_get_report_sp();
void *addr = __asan_get_report_address();
- int access_type = __asan_get_report_access_type();
+ int is_write = __asan_get_report_access_type();
size_t access_size = __asan_get_report_access_size();
const char *description = __asan_get_report_description();
@@ -59,19 +59,7 @@ __asan_on_error() {
// CHECK: sp: 0x[[SP:[0-9a-f]+]]
fprintf(stderr, "addr: " PTR_FMT "\n", addr);
// CHECK: addr: 0x[[ADDR:[0-9a-f]+]]
- auto at_name = [access_type]() {
- switch (access_type) {
- case 0:
- return "read";
- case 1:
- return "write";
- case 2:
- return "assumption";
- default:
- __builtin_trap();
- }
- };
- fprintf(stderr, "type: %s\n", at_name());
+ fprintf(stderr, "type: %s\n", (is_write ? "write" : "read"));
// CHECK: type: write
fprintf(stderr, "access_size: %ld\n", access_size);
// CHECK: access_size: 1
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 11ebf4db55466..8b5969ffb3ca0 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -299,11 +299,6 @@ static cl::opt<bool> ClRedzoneByvalArgs("asan-redzone-byval-args",
"required)"), cl::Hidden,
cl::init(true));
-static cl::opt<bool> ClInstrumentAssumeDereferenceable(
- "asan-instrument-assume-dereferenceable",
- cl::desc("instrument llvm.assume(dereferenceable)"), cl::Hidden,
- cl::init(true));
-
static cl::opt<bool> ClUseAfterScope("asan-use-after-scope",
cl::desc("Check stack-use-after-scope"),
cl::Hidden, cl::init(false));
@@ -929,7 +924,6 @@ struct AddressSanitizer {
// These arrays is indexed by AccessIsWrite and Experiment.
FunctionCallee AsanErrorCallbackSized[2][2];
FunctionCallee AsanMemoryAccessCallbackSized[2][2];
- FunctionCallee AsanAssumeDereferenceableCallback;
FunctionCallee AsanMemmove, AsanMemcpy, AsanMemset;
Value *LocalDynamicShadow = nullptr;
@@ -2887,12 +2881,6 @@ bool ModuleAddressSanitizer::instrumentModule() {
void AddressSanitizer::initializeCallbacks(const TargetLibraryInfo *TLI) {
IRBuilder<> IRB(*C);
-
- const std::string EndingStr = Recover ? "_noabort" : "";
- AsanAssumeDereferenceableCallback = M.getOrInsertFunction(
- "__asan_report_assume_dereferenceable" + EndingStr,
- FunctionType::get(IRB.getVoidTy(), {IntptrTy, IntptrTy}, false));
-
// Create __asan_report* callbacks.
// IsWrite, TypeSize and Exp are encoded in the function name.
for (int Exp = 0; Exp < 2; Exp++) {
@@ -3111,7 +3099,6 @@ bool AddressSanitizer::instrumentFunction(Function &F,
SmallVector<Instruction *, 8> NoReturnCalls;
SmallVector<BasicBlock *, 16> AllBlocks;
SmallVector<Instruction *, 16> PointerComparisonsOrSubtracts;
- SmallVector<AssumeInst *, 8> DerefAssumptions;
// Fill the set of memory operations to instrument.
for (auto &BB : F) {
@@ -3126,7 +3113,6 @@ bool AddressSanitizer::instrumentFunction(Function &F,
SmallVector<InterestingMemoryOperand, 1> InterestingOperands;
getInterestingMemoryOperands(&Inst, InterestingOperands, TTI);
- AssumeInst *AI;
if (!InterestingOperands.empty()) {
for (auto &Operand : InterestingOperands) {
if (ClOpt && ClOptSameTemp) {
@@ -3154,12 +3140,6 @@ bool AddressSanitizer::instrumentFunction(Function &F,
// ok, take it.
IntrinToInstrument.push_back(MI);
NumInsnsPerBB++;
- } else if (ClInstrumentAssumeDereferenceable &&
- (AI = dyn_cast<AssumeInst>(&Inst))) {
- if (AI->getOperandBundle("dereferenceable")) {
- DerefAssumptions.push_back(AI);
- NumInsnsPerBB++;
- }
} else {
if (auto *CB = dyn_cast<CallBase>(&Inst)) {
// A call inside BB.
@@ -3209,28 +3189,6 @@ bool AddressSanitizer::instrumentFunction(Function &F,
FunctionModified = true;
}
- for (auto *AI : DerefAssumptions) {
- if (auto Bundle = AI->getOperandBundle("dereferenceable")) {
- Value *Ptr = Bundle->Inputs[0];
- Value *Size = Bundle->Inputs[1];
-
- // Skip if size is exactly 0 without generating IR.
- if (auto *CI = dyn_cast<ConstantInt>(Size)) {
- if (CI->getValue().zextOrTrunc(IntptrTy->getIntegerBitWidth()).isZero())
- continue;
- }
-
- IRBuilder<> IRB(AI);
- Value *AddrLong = IRB.CreatePointerCast(Ptr, IntptrTy);
- Value *SizeExt = IRB.CreateZExtOrTrunc(Size, IntptrTy);
-
- RTCI.createRuntimeCall(IRB, AsanAssumeDereferenceableCallback,
- {AddrLong, SizeExt});
-
- FunctionModified = true;
- }
- }
-
if (ChangedStack || !NoReturnCalls.empty())
FunctionModified = true;
diff --git a/llvm/test/Instrumentation/AddressSanitizer/assume-dereferenceable.ll b/llvm/test/Instrumentation/AddressSanitizer/assume-dereferenceable.ll
deleted file mode 100644
index cb0d69da60639..0000000000000
--- a/llvm/test/Instrumentation/AddressSanitizer/assume-dereferenceable.ll
+++ /dev/null
@@ -1,18 +0,0 @@
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -passes=asan -asan-instrument-assume-dereferenceable=1 -S | FileCheck %s
-
-target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-unknown-linux-gnu"
-
-define void @test(ptr %p, i64 %size) sanitize_address {
-; CHECK-LABEL: @test(
-; CHECK-NEXT: [[TMP17:%.*]] = ptrtoint ptr [[TMP4:%.*]] to i64
-; CHECK-NEXT: call void @__asan_report_assume_dereferenceable(i64 [[TMP17]], i64 [[SIZE:%.*]])
-; CHECK-NEXT: call void @llvm.assume(i1 true) [ "dereferenceable"(ptr [[TMP4]], i64 [[SIZE]]) ]
-; CHECK-NEXT: ret void
-;
- call void @llvm.assume(i1 true) [ "dereferenceable"(ptr %p, i64 %size) ]
- ret void
-}
-
-declare void @llvm.assume(i1)
More information about the llvm-branch-commits
mailing list