[RISCV] Add shrinkwrap test cases showing gaps in current impl
[llvm-project.git] / clang / test / CodeGen / unsigned-trapv.c
blob62d547109418f4bfbdecc93ab31470c800f9c9a0
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fsanitize=unsigned-integer-overflow | FileCheck %s --check-prefix=UNSIGNED
2 // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=TRAPV
3 // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fsanitize=unsigned-integer-overflow -ftrapv | FileCheck %s --check-prefix=BOTH
4 // Verify that -ftrapv and -fsanitize=unsigned-integer-overflow
5 // work together as expected
8 // UNSIGNED: @test_signed
9 // TRAPV: @test_signed
10 // BOTH: @test_signed
11 void test_signed(void) {
12 extern volatile int a, b, c;
13 // UNSIGNED: add nsw i32
14 // UNSIGNED-NOT: overflow
15 // TRAPV: sadd.with.overflow.i32
16 // TRAPV-NOT: @__ubsan
17 // TRAPV: llvm.ubsantrap
18 // BOTH: sadd.with.overflow.i32
19 // BOTH-NOT: @__ubsan
20 // BOTH: llvm.ubsantrap
21 a = b + c;
24 // UNSIGNED: @test_unsigned
25 // TRAPV: @test_unsigned
26 // BOTH: @test_unsigned
27 void test_unsigned(void) {
28 extern volatile unsigned x, y, z;
29 // UNSIGNED: uadd.with.overflow.i32
30 // UNSIGNED-NOT: llvm.trap
31 // UNSIGNED: ubsan
32 // TRAPV-NOT: overflow
33 // TRAPV-NOT: llvm.trap
34 // BOTH: uadd.with.overflow.i32
35 // BOTH: @__ubsan
36 // BOTH-NOT: llvm.ubsantrap
37 x = y + z;