[clang] [compiler-rt] [ubsan] Display correct runtime messages for negative _BitInt (PR #96240)

Nikita Popov via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 16 02:57:21 PDT 2024


nikic wrote:

The clang test also fails on s390x (big endian):
```
RUN: at line 2: /builddir/build/BUILD/llvm-project-ec29660c44e5e73d3b78f4884f9178036563fb25/llvm/s390x-redhat-linux-gnu/bin/clang -cc1 -internal-isystem /builddir/build/BUILD/llvm-project-ec29660c44e5e73d3b78f4884f9178036563fb25/llvm/s390x-redhat-linux-gnu/bin/../lib/clang/20/include -nostdsysteminc -Wno-constant-conversion -Wno-array-bounds -Wno-division-by-zero -Wno-shift-negative-value -Wno-shift-count-negative -Wno-int-to-pointer-cast -fsanitize=array-bounds,enum,float-cast-overflow,integer-divide-by-zero,implicit-unsigned-integer-truncation,implicit-signed-integer-truncation,implicit-integer-sign-change,unsigned-integer-overflow,signed-integer-overflow,shift-base,shift-exponent -O0 -emit-llvm -o - /builddir/build/BUILD/llvm-project-ec29660c44e5e73d3b78f4884f9178036563fb25/clang/test/CodeGen/bit-int-ubsan.c | /builddir/build/BUILD/llvm-project-ec29660c44e5e73d3b78f4884f9178036563fb25/llvm/s390x-redhat-linux-gnu/bin/FileCheck /builddir/build/BUILD/llvm-project-ec29660c44e5e73d3b78f4884f9178036563fb25/clang/test/CodeGen/bit-int-ubsan.c
+ /builddir/build/BUILD/llvm-project-ec29660c44e5e73d3b78f4884f9178036563fb25/llvm/s390x-redhat-linux-gnu/bin/clang -cc1 -internal-isystem /builddir/build/BUILD/llvm-project-ec29660c44e5e73d3b78f4884f9178036563fb25/llvm/s390x-redhat-linux-gnu/bin/../lib/clang/20/include -nostdsysteminc -Wno-constant-conversion -Wno-array-bounds -Wno-division-by-zero -Wno-shift-negative-value -Wno-shift-count-negative -Wno-int-to-pointer-cast -fsanitize=array-bounds,enum,float-cast-overflow,integer-divide-by-zero,implicit-unsigned-integer-truncation,implicit-signed-integer-truncation,implicit-integer-sign-change,unsigned-integer-overflow,signed-integer-overflow,shift-base,shift-exponent -O0 -emit-llvm -o - /builddir/build/BUILD/llvm-project-ec29660c44e5e73d3b78f4884f9178036563fb25/clang/test/CodeGen/bit-int-ubsan.c
+ /builddir/build/BUILD/llvm-project-ec29660c44e5e73d3b78f4884f9178036563fb25/llvm/s390x-redhat-linux-gnu/bin/FileCheck /builddir/build/BUILD/llvm-project-ec29660c44e5e73d3b78f4884f9178036563fb25/clang/test/CodeGen/bit-int-ubsan.c
/builddir/build/BUILD/llvm-project-ec29660c44e5e73d3b78f4884f9178036563fb25/clang/test/CodeGen/bit-int-ubsan.c:11:12: error: CHECK: expected string not found in input
 // CHECK: constant { i16, i16, [20 x i8] } { i16 2, i16 13, [20 x i8] c"'_BitInt(37)'\00%\00\00\00\00\00" }
           ^
<stdin>:7:100: note: scanning from here
@0 = private unnamed_addr constant { i16, i16, [8 x i8] } { i16 1, i16 32, [8 x i8] c"'float'\00" }
                                                                                                   ^
<stdin>:8:27: note: possible intended match here
@1 = private unnamed_addr constant { i16, i16, [20 x i8] } { i16 2, i16 13, [20 x i8] c"'_BitInt(37)'\00\00\00\00%\00\00" }
                          ^

Input file: <stdin>
Check file: /builddir/build/BUILD/llvm-project-ec29660c44e5e73d3b78f4884f9178036563fb25/clang/test/CodeGen/bit-int-ubsan.c

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1: ; ModuleID = '/builddir/build/BUILD/llvm-project-ec29660c44e5e73d3b78f4884f9178036563fb25/clang/test/CodeGen/bit-int-ubsan.c' 
            2: source_filename = "/builddir/build/BUILD/llvm-project-ec29660c44e5e73d3b78f4884f9178036563fb25/clang/test/CodeGen/bit-int-ubsan.c" 
            3: target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64" 
            4: target triple = "s390x-redhat-linux-gnu" 
            5:  
            6: @.src = private unnamed_addr constant [111 x i8] c"/builddir/build/BUILD/llvm-project-ec29660c44e5e73d3b78f4884f9178036563fb25/clang/test/CodeGen/bit-int-ubsan.c\00", align 2 
            7: @0 = private unnamed_addr constant { i16, i16, [8 x i8] } { i16 1, i16 32, [8 x i8] c"'float'\00" } 
check:11'0                                                                                                        X error: no match found
            8: @1 = private unnamed_addr constant { i16, i16, [20 x i8] } { i16 2, i16 13, [20 x i8] c"'_BitInt(37)'\00\00\00\00%\00\00" } 
check:11'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:11'1                               ?                                                                                                  possible intended match
            9: @2 = private unnamed_addr global { { ptr, i32, i32 }, ptr, ptr } { { ptr, i32, i32 } { ptr @.src, i32 10, i32 19 }, ptr @0, ptr @1 } 
check:11'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           10: @3 = private unnamed_addr constant { i16, i16, [32 x i8] } { i16 0, i16 10, [32 x i8] c"'uint32_t' (aka 'unsigned int')\00" } 
check:11'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           11: @4 = private unnamed_addr global { { ptr, i32, i32 }, ptr, ptr, i8, i32 } { { ptr, i32, i32 } { ptr @.src, i32 12, i32 10 }, ptr @1, ptr @3, i8 2, i32 0 } 
check:11'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           12: @5 = private unnamed_addr constant { i16, i16, [6 x i8] } { i16 0, i16 11, [6 x i8] c"'int'\00" } 
check:11'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           13: @6 = private unnamed_addr global { { ptr, i32, i32 }, ptr } { { ptr, i32, i32 } { ptr @.src, i32 16, i32 21 }, ptr @5 } 
check:11'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            .
            .
            .
>>>>>>
```

Please pass an explicit `-triple` to `%clang_cc1` if the test is not supposed to be big endian compatible.

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


More information about the cfe-commits mailing list