diff options
author | Fangrui Song <i@maskray.me> | 2024-01-11 13:54:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-11 13:54:07 -0800 |
commit | a6d401703b7542e00c85767513be0851df6c67cf (patch) | |
tree | f918e1d8a071408b0610eccf9de436e617fe9d00 /llvm/test/Analysis | |
parent | 238b5790ba2027a88706a320fe61bd21601b788b (diff) | |
download | llvm-a6d401703b7542e00c85767513be0851df6c67cf.zip llvm-a6d401703b7542e00c85767513be0851df6c67cf.tar.gz llvm-a6d401703b7542e00c85767513be0851df6c67cf.tar.bz2 |
[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.
Diffstat (limited to 'llvm/test/Analysis')
-rw-r--r-- | llvm/test/Analysis/StackSafetyAnalysis/memintrin.ll | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/test/Analysis/StackSafetyAnalysis/memintrin.ll b/llvm/test/Analysis/StackSafetyAnalysis/memintrin.ll index 791fb35..6913816 100644 --- a/llvm/test/Analysis/StackSafetyAnalysis/memintrin.ll +++ b/llvm/test/Analysis/StackSafetyAnalysis/memintrin.ll @@ -98,6 +98,40 @@ entry: ret void } +define void @MemsetHugeUpper_m1(i1 %bool) { +; CHECK-LABEL: MemsetHugeUpper_m1 dso_preemptable{{$}} +; CHECK-NEXT: args uses: +; CHECK-NEXT: allocas uses: +; CHECK-NEXT: x[4]: full-set +entry: + %x = alloca i32, align 4 + br i1 %bool, label %if.then, label %if.end + +if.then: + call void @llvm.memset.p0.i64(ptr %x, i8 0, i64 -1, i1 false) + br label %if.end + +if.end: + ret void +} + +define void @MemsetHugeUpper_m2(i1 %bool) { +; CHECK-LABEL: MemsetHugeUpper_m2 dso_preemptable{{$}} +; CHECK-NEXT: args uses: +; CHECK-NEXT: allocas uses: +; CHECK-NEXT: x[4]: full-set +entry: + %x = alloca i32, align 4 + br i1 %bool, label %if.then, label %if.end + +if.then: + call void @llvm.memset.p0.i64(ptr %x, i8 0, i64 -2, i1 false) + br label %if.end + +if.end: + ret void +} + define void @MemcpyInBounds() { ; CHECK-LABEL: MemcpyInBounds dso_preemptable{{$}} ; CHECK-NEXT: args uses: |