1; The test is generated by Clang from the following source:
2;
3; void foo32(int a, int b, int *c) {
4;   *c = a + b;
5; }
6;
7; void foo64(long a, long b, long *c) {
8;   *c = a + b;
9; }
10;
11; With the following options:
12; -emit-llvm -fno-discard-value-names -O2 -g0 -ftrapv -target spir
13
14; RUN: llvm-as < %s -o %t.bc
15; RUN: llvm-spirv -s %t.bc -o - | llvm-dis -o - | FileCheck %s
16
17; CHECK: call { i32, i1 } @llvm_sadd_with_overflow_i32
18; CHECK-NOT: call { i32, i1 } @llvm.sadd.with.overflow.i32
19
20; CHECK: call { i64, i1 } @llvm_sadd_with_overflow_i64
21; CHECK-NOT: call { i64, i1 } @llvm.sadd.with.overflow.i64
22
23; CHECK-NOT: call { i16, i1 } @llvm_sadd_with_overflow_i16
24
25
26target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
27target triple = "spir"
28
29; Function Attrs: nounwind
30define dso_local spir_func void @foo32(i32 %a, i32 %b, i32* nocapture %c) local_unnamed_addr #0 {
31entry:
32  %0 = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %a, i32 %b), !nosanitize !2
33  %1 = extractvalue { i32, i1 } %0, 1, !nosanitize !2
34  br i1 %1, label %trap, label %cont, !nosanitize !2
35
36trap:                                             ; preds = %entry
37  tail call void @llvm.trap() #3, !nosanitize !2
38  unreachable, !nosanitize !2
39
40cont:                                             ; preds = %entry
41  %2 = extractvalue { i32, i1 } %0, 0, !nosanitize !2
42  store i32 %2, i32* %c, align 4, !tbaa !3
43  ret void
44}
45
46; Function Attrs: nounwind readnone speculatable willreturn
47declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) #1
48
49; Function Attrs: cold noreturn nounwind
50declare void @llvm.trap() #2
51
52; Function Attrs: nounwind
53define dso_local spir_func void @foo64(i64 %a, i64 %b, i64* nocapture %c) local_unnamed_addr #0 {
54entry:
55  %0 = tail call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %a, i64 %b), !nosanitize !2
56  %1 = extractvalue { i64, i1 } %0, 1, !nosanitize !2
57  br i1 %1, label %trap, label %cont, !nosanitize !2
58
59trap:                                             ; preds = %entry
60  tail call void @llvm.trap() #3, !nosanitize !2
61  unreachable, !nosanitize !2
62
63cont:                                             ; preds = %entry
64  %2 = extractvalue { i64, i1 } %0, 0, !nosanitize !2
65  store i64 %2, i64* %c, align 8, !tbaa !7
66  ret void
67}
68
69; Function Attrs: nounwind readnone speculatable willreturn
70declare { i64, i1 } @llvm.sadd.with.overflow.i64(i64, i64) #1
71
72attributes #0 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
73attributes #1 = { nounwind readnone speculatable willreturn }
74attributes #2 = { cold noreturn nounwind }
75attributes #3 = { noreturn nounwind }
76
77!llvm.module.flags = !{!0}
78!llvm.ident = !{!1}
79
80!0 = !{i32 1, !"wchar_size", i32 4}
81!1 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 576fa5a50c8509977835031d190f8906e1dbb075)"}
82!2 = !{}
83!3 = !{!4, !4, i64 0}
84!4 = !{!"int", !5, i64 0}
85!5 = !{!"omnipotent char", !6, i64 0}
86!6 = !{!"Simple C/C++ TBAA"}
87!7 = !{!8, !8, i64 0}
88!8 = !{!"long", !5, i64 0}
89