[all-commits] [llvm/llvm-project] a6d401: [StackSafetyAnalysis] Bail out if MemIntrinsic len...

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Jan 11 13:54:19 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a6d401703b7542e00c85767513be0851df6c67cf
      https://github.com/llvm/llvm-project/commit/a6d401703b7542e00c85767513be0851df6c67cf
  Author: Fangrui Song <i at maskray.me>
  Date:   2024-01-11 (Thu, 11 Jan 2024)

  Changed paths:
    M llvm/lib/Analysis/StackSafetyAnalysis.cpp
    M llvm/test/Analysis/StackSafetyAnalysis/memintrin.ll

  Log Message:
  -----------
  [StackSafetyAnalysis] Bail out if MemIntrinsic length is -1 (#77837)

Clang generates llvm.memset.p0.i64 with a length of -1 for the following
code in
`-stdlib=libc++ -std=c++20` mode

(https://github.com/llvm/llvm-project/pull/77210#issuecomment-1887650010)
```cpp
bool strtof_clamp(const std::string &str);
void floatsuffix_check(char *yytext_r) {
  std::string text = yytext_r;
  text.resize(text.size() - 1);
  strtof_clamp(text);
}
```

`Sizes = [0xffffffffffffffff, 0)`. `SizeRange = [0, 0-1)`, leading to
`assert(!isUnsafe(SizeRange));` failure. Bail out if the length is -1.
Other negative values are handled by the existing condition.




More information about the All-commits mailing list