[llvm] [ConstraintElim] Add NUW for mul/shl with NSW and non-positive ops. (PR #219663)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 29 03:32:29 PDT 2026
github-actions[bot] wrote:
<!--PREMERGE ADVISOR COMMENT: Windows-->
# :window: Windows x64 Test Results
* 140604 tests passed
* 3766 tests skipped
* 3 tests failed
## Failed Tests
(click on a test name to see its output)
### Clang
<details>
<summary>Clang.CodeGen/attr-counted-by-or-null-for-pointers.c</summary>
```
Exit Code: 1
Command Output (stdout):
--
# RUN: at line 2
c:\_work\llvm-project\llvm-project\build\bin\clang.exe -cc1 -internal-isystem C:\_work\llvm-project\llvm-project\build\lib\clang\24\include -nostdsysteminc -triple x86_64-unknown-linux-gnu -O2 -DWITH_ATTRS -Wall -fsanitize=array-bounds,object-size,local-bounds -fstrict-flex-arrays=3 -fexperimental-late-parse-attributes -emit-llvm -o - C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-counted-by-or-null-for-pointers.c | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe --check-prefix=SANITIZE-WITH-ATTR C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-counted-by-or-null-for-pointers.c
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\clang.exe' -cc1 -internal-isystem 'C:\_work\llvm-project\llvm-project\build\lib\clang\24\include' -nostdsysteminc -triple x86_64-unknown-linux-gnu -O2 -DWITH_ATTRS -Wall -fsanitize=array-bounds,object-size,local-bounds -fstrict-flex-arrays=3 -fexperimental-late-parse-attributes -emit-llvm -o - 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-counted-by-or-null-for-pointers.c'
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' --check-prefix=SANITIZE-WITH-ATTR 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-counted-by-or-null-for-pointers.c'
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-counted-by-or-null-for-pointers.c:139:29: error: SANITIZE-WITH-ATTR-NEXT: expected string not found in input
# | // SANITIZE-WITH-ATTR-NEXT: [[INDEX_SIZE:%.*]] = shl nsw i64 [[IDXPROM]], 3
# | ^
# | <stdin>:67:43: note: scanning from here
# | %array_size = select i1 %5, i64 0, i64 %6
# | ^
# | <stdin>:67:43: note: with "IDXPROM" equal to "%idxprom"
# | %array_size = select i1 %5, i64 0, i64 %6
# | ^
# | <stdin>:67:43: note: pattern attempts to capture variables: "INDEX_SIZE"
# | %array_size = select i1 %5, i64 0, i64 %6
# | ^
# | <stdin>:69:4: note: possible intended match here
# | %result = sub nsw i64 %array_size, %index_size
# | ^
# |
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-counted-by-or-null-for-pointers.c
# |
# | -dump-input=help explains the following input dump.
# |
# | Input was:
# | <<<<<<
# | .
# | .
# | .
# | 62: %4 = load ptr, ptr %buf, align 8, !tbaa !6
# | 63: %count = zext nneg i32 %.counted_by.load to i64
# | 64: %idxprom = sext i32 %index to i64
# | 65: %5 = icmp eq ptr %4, null
# | 66: %6 = shl nuw nsw i64 %count, 3
# | 67: %array_size = select i1 %5, i64 0, i64 %6
# | next:139'0 { search range start (exclusive)
# | next:139'1 error: no match found in search range
# | next:139'2 with "IDXPROM" equal to "%idxprom"
# | next:139'3 pattern attempts to capture variables: "INDEX_SIZE"
# | 68: %index_size = shl nuw nsw i64 %idxprom, 3
# | 69: %result = sub nsw i64 %array_size, %index_size
# | next:139'4 ? possible intended match
# | 70: %7 = tail call i64 @llvm.smax.i64(i64 %result, i64 0)
# | 71: ret i64 %7
# | 72: }
# | 73:
# | 74: ; Function Attrs: noreturn nounwind uwtable
# | 75: declare void @__ubsan_handle_out_of_bounds_abort(ptr, i64) local_unnamed_addr #1
# | 76:
# | 77: ; Function Attrs: nounwind
# | 78: define dso_local i64 @test_bdos_of_subscript_through_cast(ptr noundef %p, i32 noundef %index) local_unnamed_addr #0 {
# | next:139'5 } search range end (exclusive)
# | 79: entry:
# | 80: %.counted_by.gep = getelementptr inbounds nuw i8, ptr %p, i64 16
# | 81: %.counted_by.load = load i32, ptr %.counted_by.gep, align 8
# | 82: %0 = icmp ult i32 %index, %.counted_by.load, !nosanitize !12
# | 83: %1 = icmp sgt i32 %.counted_by.load, 0, !nosanitize !12
# | .
# | .
# | .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1
--
```
</details>
<details>
<summary>Clang.CodeGen/attr-sized-by-for-pointers.c</summary>
```
Exit Code: 1
Command Output (stdout):
--
# RUN: at line 2
c:\_work\llvm-project\llvm-project\build\bin\clang.exe -cc1 -internal-isystem C:\_work\llvm-project\llvm-project\build\lib\clang\24\include -nostdsysteminc -triple x86_64-unknown-linux-gnu -O2 -DWITH_ATTRS -Wall -fsanitize=array-bounds,object-size,local-bounds -fstrict-flex-arrays=3 -fexperimental-late-parse-attributes -emit-llvm -o - C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-sized-by-for-pointers.c | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe --check-prefix=SANITIZE-WITH-ATTR C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-sized-by-for-pointers.c
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\clang.exe' -cc1 -internal-isystem 'C:\_work\llvm-project\llvm-project\build\lib\clang\24\include' -nostdsysteminc -triple x86_64-unknown-linux-gnu -O2 -DWITH_ATTRS -Wall -fsanitize=array-bounds,object-size,local-bounds -fstrict-flex-arrays=3 -fexperimental-late-parse-attributes -emit-llvm -o - 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-sized-by-for-pointers.c'
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' --check-prefix=SANITIZE-WITH-ATTR 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-sized-by-for-pointers.c'
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-sized-by-for-pointers.c:201:29: error: SANITIZE-WITH-ATTR-NEXT: expected string not found in input
# | // SANITIZE-WITH-ATTR-NEXT: [[INDEX_SIZE:%.*]] = shl nsw i64 [[IDXPROM]], 3
# | ^
# | <stdin>:101:49: note: scanning from here
# | %count = zext nneg i32 %.counted_by.load to i64
# | ^
# | <stdin>:101:49: note: with "IDXPROM" equal to "%idxprom"
# | %count = zext nneg i32 %.counted_by.load to i64
# | ^
# | <stdin>:101:49: note: pattern attempts to capture variables: "INDEX_SIZE"
# | %count = zext nneg i32 %.counted_by.load to i64
# | ^
# | <stdin>:103:4: note: possible intended match here
# | %result = sub nsw i64 %count, %index_size
# | ^
# | C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-sized-by-for-pointers.c:490:29: error: SANITIZE-WITH-ATTR-NEXT: expected string not found in input
# | // SANITIZE-WITH-ATTR-NEXT: [[INDEX_SIZE:%.*]] = shl nsw i64 [[IDXPROM]], 2
# | ^
# | <stdin>:202:49: note: scanning from here
# | %count = zext nneg i32 %.counted_by.load to i64
# | ^
# | <stdin>:202:49: note: with "IDXPROM" equal to "%idxprom"
# | %count = zext nneg i32 %.counted_by.load to i64
# | ^
# | <stdin>:202:49: note: pattern attempts to capture variables: "INDEX_SIZE"
# | %count = zext nneg i32 %.counted_by.load to i64
# | ^
# | <stdin>:204:4: note: possible intended match here
# | %result = sub nsw i64 %count, %index_size
# | ^
# |
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-sized-by-for-pointers.c
# |
# | -dump-input=help explains the following input dump.
# |
# | Input was:
# | <<<<<<
# | .
# | .
# | .
# | 96: tail call void @__ubsan_handle_out_of_bounds_abort(ptr nonnull @6, i64 %3) #5, !nosanitize !6
# | 97: unreachable, !nosanitize !6
# | 98:
# | 99: cont8: ; preds = %entry
# | 100: %idxprom = sext i32 %index to i64
# | 101: %count = zext nneg i32 %.counted_by.load to i64
# | next:201'0 { search range start (exclusive)
# | next:201'1 error: no match found in search range
# | next:201'2 with "IDXPROM" equal to "%idxprom"
# | next:201'3 pattern attempts to capture variables: "INDEX_SIZE"
# | 102: %index_size = shl nuw nsw i64 %idxprom, 3
# | 103: %result = sub nsw i64 %count, %index_size
# | next:201'4 ? possible intended match
# | 104: %4 = tail call i64 @llvm.smax.i64(i64 %result, i64 0)
# | 105: ret i64 %4
# | 106: }
# | 107:
# | 108: ; Function Attrs: nounwind
# | 109: define dso_local range(i64 0, 2147483648) i64 @test_bdos_of_pointer_incomplete_pointee(ptr noundef %p) local_unnamed_addr #0 {
# | next:201'5 } search range end (exclusive)
# | 110: entry:
# | 111: %counted_by.gep = getelementptr inbounds nuw i8, ptr %p, i64 16
# | 112: %counted_by.load = load i32, ptr %counted_by.gep, align 4
# | 113: %narrow = tail call i32 @llvm.smax.i32(i32 %counted_by.load, i32 0)
# | 114: %0 = zext nneg i32 %narrow to i64
# | .
# | .
# | .
# | 197: tail call void @__ubsan_handle_out_of_bounds_abort(ptr nonnull @11, i64 %3) #5, !nosanitize !6
# | 198: unreachable, !nosanitize !6
# | 199:
# | 200: cont8: ; preds = %entry
# | 201: %idxprom = sext i32 %index to i64
# | 202: %count = zext nneg i32 %.counted_by.load to i64
# | next:490'0 { search range start (exclusive)
# | next:490'1 error: no match found in search range
# | next:490'2 with "IDXPROM" equal to "%idxprom"
# | next:490'3 pattern attempts to capture variables: "INDEX_SIZE"
# | 203: %index_size = shl nuw nsw i64 %idxprom, 2
# | 204: %result = sub nsw i64 %count, %index_size
# | next:490'4 ? possible intended match
# | 205: %4 = tail call i64 @llvm.smax.i64(i64 %result, i64 0)
# | 206: ret i64 %4
# | 207: }
# | 208:
# | 209: ; Function Attrs: nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none)
# | .
# | .
# | .
# | 232: !6 = !{}
# | 233: !7 = !{!"branch_weights", i32 1048575, i32 1}
# | 234: !8 = !{!9, !10, i64 0}
# | 235: !9 = !{!"annotated_volatile_ptr", !10, i64 0, !3, i64 8}
# | 236: !10 = !{!"p1 int", !11, i64 0}
# | 237: !11 = !{!"any pointer", !4, i64 0}
# | next:490'5 } search range end (exclusive)
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1
--
```
</details>
<details>
<summary>Clang.CodeGen/attr-sized-by-or-null-for-pointers.c</summary>
```
Exit Code: 1
Command Output (stdout):
--
# RUN: at line 2
c:\_work\llvm-project\llvm-project\build\bin\clang.exe -cc1 -internal-isystem C:\_work\llvm-project\llvm-project\build\lib\clang\24\include -nostdsysteminc -triple x86_64-unknown-linux-gnu -O2 -DWITH_ATTRS -Wall -fsanitize=array-bounds,object-size,local-bounds -fstrict-flex-arrays=3 -fexperimental-late-parse-attributes -emit-llvm -o - C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-sized-by-or-null-for-pointers.c | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe --check-prefix=SANITIZE-WITH-ATTR C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-sized-by-or-null-for-pointers.c
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\clang.exe' -cc1 -internal-isystem 'C:\_work\llvm-project\llvm-project\build\lib\clang\24\include' -nostdsysteminc -triple x86_64-unknown-linux-gnu -O2 -DWITH_ATTRS -Wall -fsanitize=array-bounds,object-size,local-bounds -fstrict-flex-arrays=3 -fexperimental-late-parse-attributes -emit-llvm -o - 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-sized-by-or-null-for-pointers.c'
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' --check-prefix=SANITIZE-WITH-ATTR 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-sized-by-or-null-for-pointers.c'
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-sized-by-or-null-for-pointers.c:237:29: error: SANITIZE-WITH-ATTR-NEXT: expected string not found in input
# | // SANITIZE-WITH-ATTR-NEXT: [[INDEX_SIZE:%.*]] = shl nsw i64 [[IDXPROM]], 3
# | ^
# | <stdin>:118:50: note: scanning from here
# | %count.or.null = select i1 %5, i64 0, i64 %count
# | ^
# | <stdin>:118:50: note: with "IDXPROM" equal to "%idxprom"
# | %count.or.null = select i1 %5, i64 0, i64 %count
# | ^
# | <stdin>:118:50: note: pattern attempts to capture variables: "INDEX_SIZE"
# | %count.or.null = select i1 %5, i64 0, i64 %count
# | ^
# | <stdin>:120:4: note: possible intended match here
# | %result = sub nsw i64 %count.or.null, %index_size
# | ^
# | C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-sized-by-or-null-for-pointers.c:566:29: error: SANITIZE-WITH-ATTR-NEXT: expected string not found in input
# | // SANITIZE-WITH-ATTR-NEXT: [[INDEX_SIZE:%.*]] = shl nsw i64 [[IDXPROM]], 2
# | ^
# | <stdin>:238:50: note: scanning from here
# | %count.or.null = select i1 %5, i64 0, i64 %count
# | ^
# | <stdin>:238:50: note: with "IDXPROM" equal to "%idxprom"
# | %count.or.null = select i1 %5, i64 0, i64 %count
# | ^
# | <stdin>:238:50: note: pattern attempts to capture variables: "INDEX_SIZE"
# | %count.or.null = select i1 %5, i64 0, i64 %count
# | ^
# | <stdin>:240:4: note: possible intended match here
# | %result = sub nsw i64 %count.or.null, %index_size
# | ^
# |
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\clang\test\CodeGen\attr-sized-by-or-null-for-pointers.c
# |
# | -dump-input=help explains the following input dump.
# |
# | Input was:
# | <<<<<<
# | .
# | .
# | .
# | 113: %buf = getelementptr inbounds nuw i8, ptr %p, i64 8
# | 114: %4 = load ptr, ptr %buf, align 8, !tbaa !12
# | 115: %count = zext nneg i32 %.counted_by.load to i64
# | 116: %idxprom = sext i32 %index to i64
# | 117: %5 = icmp eq ptr %4, null
# | 118: %count.or.null = select i1 %5, i64 0, i64 %count
# | next:237'0 { search range start (exclusive)
# | next:237'1 error: no match found in search range
# | next:237'2 with "IDXPROM" equal to "%idxprom"
# | next:237'3 pattern attempts to capture variables: "INDEX_SIZE"
# | 119: %index_size = shl nuw nsw i64 %idxprom, 3
# | 120: %result = sub nsw i64 %count.or.null, %index_size
# | next:237'4 ? possible intended match
# | 121: %6 = tail call i64 @llvm.smax.i64(i64 %result, i64 0)
# | 122: ret i64 %6
# | 123: }
# | 124:
# | 125: ; Function Attrs: nounwind
# | 126: define dso_local range(i64 0, 2147483648) i64 @test_bdos_of_pointer_incomplete_pointee(ptr noundef %p) local_unnamed_addr #0 {
# | next:237'5 } search range end (exclusive)
# | 127: entry:
# | 128: %buf = getelementptr inbounds nuw i8, ptr %p, i64 8
# | 129: %0 = load ptr, ptr %buf, align 8, !tbaa !15
# | 130: %counted_by.gep = getelementptr inbounds nuw i8, ptr %p, i64 16
# | 131: %counted_by.load = load i32, ptr %counted_by.gep, align 8
# | .
# | .
# | .
# | 233: %buf = getelementptr inbounds nuw i8, ptr %p, i64 8
# | 234: %4 = load ptr, ptr %buf, align 8, !tbaa !6
# | 235: %count = zext nneg i32 %.counted_by.load to i64
# | 236: %idxprom = sext i32 %index to i64
# | 237: %5 = icmp eq ptr %4, null
# | 238: %count.or.null = select i1 %5, i64 0, i64 %count
# | next:566'0 { search range start (exclusive)
# | next:566'1 error: no match found in search range
# | next:566'2 with "IDXPROM" equal to "%idxprom"
# | next:566'3 pattern attempts to capture variables: "INDEX_SIZE"
# | 239: %index_size = shl nuw nsw i64 %idxprom, 2
# | 240: %result = sub nsw i64 %count.or.null, %index_size
# | next:566'4 ? possible intended match
# | 241: %6 = tail call i64 @llvm.smax.i64(i64 %result, i64 0)
# | 242: ret i64 %6
# | 243: }
# | 244:
# | 245: ; Function Attrs: nocallback nocreateundeforpoison nofree nosync nounwind speculatable willreturn memory(none)
# | .
# | .
# | .
# | 277: !15 = !{!16, !17, i64 8}
# | 278: !16 = !{!"annotated_sized_ptr_incomplete", !8, i64 0, !17, i64 8, !3, i64 16}
# | 279: !17 = !{!"p1 _ZTS13incomplete_ty", !9, i64 0}
# | 280: !18 = !{!19, !20, i64 0}
# | 281: !19 = !{!"annotated_volatile_ptr", !20, i64 0, !3, i64 8}
# | 282: !20 = !{!"p1 int", !9, i64 0}
# | next:566'5 } search range end (exclusive)
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1
--
```
</details>
If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the `infrastructure` label.
https://github.com/llvm/llvm-project/pull/219663
More information about the llvm-commits
mailing list