[llvm] [AArch64] Stack probing for dynamic allocas in GlobalISel (PR #67123)

Oskar Wirga via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 28 17:27:40 PDT 2023


https://github.com/oskarwirga commented:

I found an interaction between -fstack-clash-protection and -ftrivial-auto-var-init=zero that can be triggered with:
```
// RUN: %clang_cc1 "-triple" "aarch64-none-linux-android28" "-emit-obj" "-Os" "-fstack-clash-protection" "-mstack-probe-size=65536" "-ftrivial-auto-var-init=zero" "-vectorize-loops" "-x" "c" "%s" "-o" "/dev/null"

// This test case examines a specific interaction between the -fstack-clash-protection
// mitigation and the -ftrivial-auto-var-init=zero option.
// The -fstack-clash-protection option inserts a stack probe loop into the compiled code to protect
// against stack clashes. The -ftrivial-auto-var-init=zero option initializes automatic variables to zero.
// The test case was reduced from an instance where the compiler crashed when these options were used together.
// The crash occurred when condition flags were situated at the insertion point of the stack probe loop.

# 4 "" 3
typedef a;
typedef b;
typedef struct {
  b c
} d;
#define e(f, g, h) h f[g]
i(d *j) {
  a k;
  e(l, j->c == 2, a);
  if (j->c == 2)
    k = l;
  m(k);
}
```

I have a fix but I do not know if it is the correct way to do it. I will add it inline. 


https://github.com/llvm/llvm-project/pull/67123


More information about the llvm-commits mailing list