diff --git a/compiler-rt/test/hwasan/TestCases/deep-recursion.c b/compiler-rt/test/hwasan/TestCases/deep-recursion.c index bf390d051d472..792f758958270 100644 --- a/compiler-rt/test/hwasan/TestCases/deep-recursion.c +++ b/compiler-rt/test/hwasan/TestCases/deep-recursion.c @@ -17,9 +17,6 @@ // Stack histories are currently not recorded on x86. // XFAIL: target=x86_64{{.*}} -// Flaky on AArch64 Linux, see https://github.com/llvm/llvm-project/issues/69221. -// UNSUPPORTED: target=aarch64{{.*}} - #include // At least -O1 is needed for this function to not have a stack frame on // AArch64. @@ -29,7 +26,23 @@ void USE(void *x) { // pretend_to_do_something(void *x) volatile int four = 4; -__attribute__((noinline)) void OOB() { int x[4]; x[four] = 0; USE(&x[0]); } +__attribute__((noinline)) void OOB() { + int x[4]; + int y[4]; + + // Tags for stack-allocated variables can occasionally be zero, resulting in + // a false negative for this test. This is not easy to fix, hence we work + // around it: if the tag is zero, we use the neighboring variable instead, + // which must have a different (hence non-zero) tag. + // This tag check assumes aarch64. + if (((uintptr_t)&x) >> 56 == 0) { + y[four] = 0; + } else { + x[four] = 0; + } + USE(&x[0]); + USE(&y[0]); +} __attribute__((noinline)) void FUNC1() { int x; USE(&x); OOB(); } __attribute__((noinline)) void FUNC2() { int x; USE(&x); FUNC1(); } __attribute__((noinline)) void FUNC3() { int x; USE(&x); FUNC2(); }