diff --git a/clang/test/CodeGen/asan-use-callbacks.cpp b/clang/test/CodeGen/asan-use-callbacks.cpp --- a/clang/test/CodeGen/asan-use-callbacks.cpp +++ b/clang/test/CodeGen/asan-use-callbacks.cpp @@ -4,10 +4,14 @@ // RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - \ // RUN: -fsanitize=address %s -fsanitize-address-outline-instrumentation \ // RUN: | FileCheck %s --check-prefixes=CHECK-OUTLINE +// RUN: %clang -target x86_64-linux-gnu -S -emit-llvm -o - \ +// RUN: -fsanitize=address %s -fsanitize-address-outline-instrumentation \ +// RUN: -mllvm -asan-inline-small-callbacks \ +// RUN: | FileCheck %s --check-prefixes=CHECK-NO-OUTLINE -// CHECK-NO-OUTLINE-NOT: call{{.*}}@__asan_load4 -// CHECK-OUTLINE: call{{.*}}@__asan_load4 +// CHECK-NO-OUTLINE-NOT: call{{.*}}@__asan_load8 +// CHECK-OUTLINE: call{{.*}}@__asan_load8 -int deref(int *p) { +long deref(long *p) { return *p; } diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -306,6 +306,11 @@ cl::desc("Realign stack to the value of this flag (power of two)"), cl::Hidden, cl::init(32)); +static cl::opt ClInlineSmallCallbacks( + "asan-inline-small-callbacks", + cl::desc("Inline callbacks for 8 and 16 byte types."), cl::Hidden, + cl::init(false)); + static cl::opt ClInstrumentationWithCallsThreshold( "asan-instrumentation-with-call-threshold", cl::desc( @@ -1741,6 +1746,10 @@ Value *AddrLong = IRB.CreatePointerCast(Addr, IntptrTy); size_t AccessSizeIndex = TypeSizeToSizeIndex(TypeSize); + if (ClInlineSmallCallbacks && AccessSizeIndex > 2) { + UseCalls = false; + } + if (UseCalls) { if (Exp == 0) IRB.CreateCall(AsanMemoryAccessCallback[IsWrite][0][AccessSizeIndex],