Index: lib/Transforms/Instrumentation/AddressSanitizer.cpp =================================================================== --- lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -460,7 +460,7 @@ // Check if we have dynamic alloca. bool isDynamicAlloca(AllocaInst &AI) const { - return AI.isArrayAllocation() || !AI.isStaticAlloca(); + return !AI.isStaticAlloca(); } /// If it is an interesting memory access, return the PointerOperand Index: projects/compiler-rt/test/asan/TestCases/alloca_constant_size.cc =================================================================== --- projects/compiler-rt/test/asan/TestCases/alloca_constant_size.cc +++ projects/compiler-rt/test/asan/TestCases/alloca_constant_size.cc @@ -0,0 +1,29 @@ +// Regression test for https://github.com/google/sanitizers/issues/691 + +// RUN: %clangxx_asan -O0 %s -o %t +// RUN: %run %t 2>&1 | FileCheck %s + +#include +#include +#include + +void f1() { + char *dynamic_buffer = (char *)alloca(200); + fprintf(stderr, "dynamic_buffer = %p\n", dynamic_buffer); + return; +} + +void f2() { + char buf[1024]; + memset(buf, 'x', 1024); +} + +int main(int argc, const char *argv[]) { + f1(); + f2(); + fprintf(stderr, "Done.\n"); + return 0; +} + +// CHECK-NOT: ERROR: AddressSanitizer +// CHECK: Done. Index: projects/compiler-rt/test/asan/TestCases/alloca_constant_size2.cc =================================================================== --- projects/compiler-rt/test/asan/TestCases/alloca_constant_size2.cc +++ projects/compiler-rt/test/asan/TestCases/alloca_constant_size2.cc @@ -0,0 +1,31 @@ +// Regression test for https://github.com/google/sanitizers/issues/691 + +// RUN: %clangxx_asan -O0 %s -o %t +// RUN: %run %t 2>&1 | FileCheck %s + +#include +#include +#include + +static const int kDynamicArraySize = 200; + +void f1() { + char dynamic_buffer[kDynamicArraySize]; + fprintf(stderr, "dynamic_buffer = %p\n", dynamic_buffer); + return; +} + +void f2() { + char buf[1024]; + memset(buf, 'x', 1024); +} + +int main(int argc, const char *argv[]) { + f1(); + f2(); + fprintf(stderr, "Done.\n"); + return 0; +} + +// CHECK-NOT: ERROR: AddressSanitizer +// CHECK: Done.