Skip to content

Commit 9d27962

Browse files
committed
[Tests] Add willreturn to libcalls in some tests
Willreturn would be inferred by FuncAttrs for these. Annotate them to preserve test behavior in the future.
1 parent 42d682a commit 9d27962

File tree

6 files changed

+112
-109
lines changed

6 files changed

+112
-109
lines changed

llvm/test/Transforms/Attributor/nonnull.ll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,23 +1513,23 @@ define void @PR43833_simple(i32* %0, i32 %1) {
15131513
br i1 %11, label %7, label %8
15141514
}
15151515

1516-
declare i8* @strrchr(i8* %0, i32 %1) nofree nounwind readonly
1516+
declare i8* @strrchr(i8* %0, i32 %1) nofree nounwind readonly willreturn
15171517

15181518
; We should not mark the return of @strrchr as `nonnull`, it may well be NULL!
15191519
define i8* @mybasename(i8* nofree readonly %str) {
1520-
; NOT_CGSCC_OPM: Function Attrs: nofree nounwind readonly
1520+
; NOT_CGSCC_OPM: Function Attrs: nofree nounwind readonly willreturn
15211521
; NOT_CGSCC_OPM-LABEL: define {{[^@]+}}@mybasename
15221522
; NOT_CGSCC_OPM-SAME: (i8* nofree readonly [[STR:%.*]]) [[ATTR11:#.*]] {
1523-
; NOT_CGSCC_OPM-NEXT: [[CALL:%.*]] = call i8* @strrchr(i8* nofree readonly [[STR]], i32 noundef 47) [[ATTR14]]
1523+
; NOT_CGSCC_OPM-NEXT: [[CALL:%.*]] = call i8* @strrchr(i8* nofree readonly [[STR]], i32 noundef 47) [[ATTR15:#.*]]
15241524
; NOT_CGSCC_OPM-NEXT: [[TOBOOL:%.*]] = icmp ne i8* [[CALL]], null
15251525
; NOT_CGSCC_OPM-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, i8* [[CALL]], i64 1
15261526
; NOT_CGSCC_OPM-NEXT: [[COND:%.*]] = select i1 [[TOBOOL]], i8* [[ADD_PTR]], i8* [[STR]]
15271527
; NOT_CGSCC_OPM-NEXT: ret i8* [[COND]]
15281528
;
1529-
; IS__CGSCC_OPM: Function Attrs: nofree nounwind readonly
1529+
; IS__CGSCC_OPM: Function Attrs: nofree nounwind readonly willreturn
15301530
; IS__CGSCC_OPM-LABEL: define {{[^@]+}}@mybasename
15311531
; IS__CGSCC_OPM-SAME: (i8* nofree readonly [[STR:%.*]]) [[ATTR12:#.*]] {
1532-
; IS__CGSCC_OPM-NEXT: [[CALL:%.*]] = call i8* @strrchr(i8* nofree readonly [[STR]], i32 noundef 47) [[ATTR15]]
1532+
; IS__CGSCC_OPM-NEXT: [[CALL:%.*]] = call i8* @strrchr(i8* nofree readonly [[STR]], i32 noundef 47) [[ATTR16:#.*]]
15331533
; IS__CGSCC_OPM-NEXT: [[TOBOOL:%.*]] = icmp ne i8* [[CALL]], null
15341534
; IS__CGSCC_OPM-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds i8, i8* [[CALL]], i64 1
15351535
; IS__CGSCC_OPM-NEXT: [[COND:%.*]] = select i1 [[TOBOOL]], i8* [[ADD_PTR]], i8* [[STR]]
Lines changed: 58 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,66 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
12
; RUN: opt < %s -dce -S | FileCheck %s
23
; RUN: opt < %s -passes=dce -S | FileCheck %s
34

4-
declare double @acos(double) nounwind
5-
declare double @asin(double) nounwind
6-
declare double @atan(double) nounwind
7-
declare double @atan2(double, double) nounwind
8-
declare double @ceil(double) nounwind
9-
declare double @cos(double) nounwind
10-
declare double @cosh(double) nounwind
11-
declare double @exp(double) nounwind
12-
declare double @exp2(double) nounwind
13-
declare double @fabs(double) nounwind
14-
declare double @floor(double) nounwind
15-
declare double @fmod(double, double) nounwind
16-
declare double @log(double) nounwind
17-
declare double @log10(double) nounwind
18-
declare double @pow(double, double) nounwind
19-
declare double @sin(double) nounwind
20-
declare double @sinh(double) nounwind
21-
declare double @sqrt(double) nounwind
22-
declare double @tan(double) nounwind
23-
declare double @tanh(double) nounwind
24-
25-
declare float @acosf(float) nounwind
26-
declare float @asinf(float) nounwind
27-
declare float @atanf(float) nounwind
28-
declare float @atan2f(float, float) nounwind
29-
declare float @ceilf(float) nounwind
30-
declare float @cosf(float) nounwind
31-
declare float @coshf(float) nounwind
32-
declare float @expf(float) nounwind
33-
declare float @exp2f(float) nounwind
34-
declare float @fabsf(float) nounwind
35-
declare float @floorf(float) nounwind
36-
declare float @fmodf(float, float) nounwind
37-
declare float @logf(float) nounwind
38-
declare float @log10f(float) nounwind
39-
declare float @powf(float, float) nounwind
40-
declare float @sinf(float) nounwind
41-
declare float @sinhf(float) nounwind
42-
declare float @sqrtf(float) nounwind
43-
declare float @tanf(float) nounwind
44-
declare float @tanhf(float) nounwind
5+
declare double @acos(double) nounwind willreturn
6+
declare double @asin(double) nounwind willreturn
7+
declare double @atan(double) nounwind willreturn
8+
declare double @atan2(double, double) nounwind willreturn
9+
declare double @ceil(double) nounwind willreturn
10+
declare double @cos(double) nounwind willreturn
11+
declare double @cosh(double) nounwind willreturn
12+
declare double @exp(double) nounwind willreturn
13+
declare double @exp2(double) nounwind willreturn
14+
declare double @fabs(double) nounwind willreturn
15+
declare double @floor(double) nounwind willreturn
16+
declare double @fmod(double, double) nounwind willreturn
17+
declare double @log(double) nounwind willreturn
18+
declare double @log10(double) nounwind willreturn
19+
declare double @pow(double, double) nounwind willreturn
20+
declare double @sin(double) nounwind willreturn
21+
declare double @sinh(double) nounwind willreturn
22+
declare double @sqrt(double) nounwind willreturn
23+
declare double @tan(double) nounwind willreturn
24+
declare double @tanh(double) nounwind willreturn
25+
26+
declare float @acosf(float) nounwind willreturn
27+
declare float @asinf(float) nounwind willreturn
28+
declare float @atanf(float) nounwind willreturn
29+
declare float @atan2f(float, float) nounwind willreturn
30+
declare float @ceilf(float) nounwind willreturn
31+
declare float @cosf(float) nounwind willreturn
32+
declare float @coshf(float) nounwind willreturn
33+
declare float @expf(float) nounwind willreturn
34+
declare float @exp2f(float) nounwind willreturn
35+
declare float @fabsf(float) nounwind willreturn
36+
declare float @floorf(float) nounwind willreturn
37+
declare float @fmodf(float, float) nounwind willreturn
38+
declare float @logf(float) nounwind willreturn
39+
declare float @log10f(float) nounwind willreturn willreturn
40+
declare float @powf(float, float) nounwind willreturn
41+
declare float @sinf(float) nounwind willreturn
42+
declare float @sinhf(float) nounwind willreturn
43+
declare float @sqrtf(float) nounwind willreturn
44+
declare float @tanf(float) nounwind willreturn
45+
declare float @tanhf(float) nounwind willreturn
4546

4647
define void @T() {
47-
entry:
4848
; CHECK-LABEL: @T(
49-
; CHECK-NEXT: entry:
49+
; CHECK-NEXT: entry:
50+
; CHECK-NEXT: [[LOG1:%.*]] = call double @log(double 0.000000e+00)
51+
; CHECK-NEXT: [[LOG2:%.*]] = call double @log(double -1.000000e+00)
52+
; CHECK-NEXT: [[EXP2:%.*]] = call double @exp(double 1.000000e+03)
53+
; CHECK-NEXT: [[COS2:%.*]] = call double @cos(double 0x7FF0000000000000)
54+
; CHECK-NEXT: [[COS3:%.*]] = call double @cos(double 0.000000e+00) [[ATTR2:#.*]]
55+
; CHECK-NEXT: [[FMOD2:%.*]] = call double @fmod(double 0x7FF0000000000000, double 1.000000e+00)
56+
; CHECK-NEXT: ret void
57+
;
58+
entry:
5059

5160
; log(0) produces a pole error
52-
; CHECK-NEXT: %log1 = call double @log(double 0.000000e+00)
5361
%log1 = call double @log(double 0.000000e+00)
5462

5563
; log(-1) produces a domain error
56-
; CHECK-NEXT: %log2 = call double @log(double -1.000000e+00)
5764
%log2 = call double @log(double -1.000000e+00)
5865

5966
; log(1) is 0
@@ -63,18 +70,15 @@ entry:
6370
%exp1 = call double @exp(double 1.000000e+02)
6471

6572
; exp(1000) is a range error
66-
; CHECK-NEXT: %exp2 = call double @exp(double 1.000000e+03)
6773
%exp2 = call double @exp(double 1.000000e+03)
6874

6975
; cos(0) is 1
7076
%cos1 = call double @cos(double 0.000000e+00)
7177

7278
; cos(inf) is a domain error
73-
; CHECK-NEXT: %cos2 = call double @cos(double 0x7FF0000000000000)
7479
%cos2 = call double @cos(double 0x7FF0000000000000)
7580

76-
; cos(0) nobuiltin may have side effects
77-
; CHECK-NEXT: %cos3 = call double @cos(double 0.000000e+00)
81+
; cos(0) nobuiltin may have side effects
7882
%cos3 = call double @cos(double 0.000000e+00) nobuiltin
7983

8084
; pow(0, 1) is 0
@@ -88,22 +92,21 @@ entry:
8892
%fmod1 = call double @fmod(double 0x7FF0000000000000, double 0x7FF0000000000001)
8993

9094
; fmod(inf, 1) is a domain error
91-
; CHECK-NEXT: %fmod2 = call double @fmod(double 0x7FF0000000000000, double 1.000000e+00)
9295
%fmod2 = call double @fmod(double 0x7FF0000000000000, double 1.000000e+00)
9396

94-
; CHECK-NEXT: ret void
9597
ret void
9698
}
9799

98100
define void @Tstrict() strictfp {
99-
entry:
100101
; CHECK-LABEL: @Tstrict(
101-
; CHECK-NEXT: entry:
102+
; CHECK-NEXT: entry:
103+
; CHECK-NEXT: [[COS4:%.*]] = call double @cos(double 1.000000e+00) [[ATTR1:#.*]]
104+
; CHECK-NEXT: ret void
105+
;
106+
entry:
102107

103108
; cos(1) strictfp sets FP status flags
104-
; CHECK-NEXT: %cos4 = call double @cos(double 1.000000e+00)
105109
%cos4 = call double @cos(double 1.000000e+00) strictfp
106110

107-
; CHECK-NEXT: ret void
108111
ret void
109112
}

llvm/test/Transforms/InstSimplify/ConstProp/calls-math-finite.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ declare float @__powf_finite(float, float) #0
3030
declare double @__sinh_finite(double) #0
3131
declare float @__sinhf_finite(float) #0
3232

33-
attributes #0 = { nounwind readnone }
33+
attributes #0 = { nounwind readnone willreturn }
3434

3535
define void @T() {
3636
; CHECK-LABEL: @T(

llvm/test/Transforms/InstSimplify/ConstProp/calls.ll

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
11
; RUN: opt < %s -instsimplify -S | FileCheck %s
22
; RUN: opt < %s -instsimplify -disable-simplify-libcalls -S | FileCheck %s --check-prefix=FNOBUILTIN
33

4-
declare double @acos(double) readnone nounwind
5-
declare double @asin(double) readnone nounwind
6-
declare double @atan(double) readnone nounwind
7-
declare double @atan2(double, double) readnone nounwind
8-
declare double @ceil(double) readnone nounwind
9-
declare double @cos(double) readnone nounwind
10-
declare double @cosh(double) readnone nounwind
11-
declare double @exp(double) readnone nounwind
12-
declare double @exp2(double) readnone nounwind
13-
declare double @fabs(double) readnone nounwind
14-
declare double @floor(double) readnone nounwind
15-
declare double @fmod(double, double) readnone nounwind
16-
declare double @log(double) readnone nounwind
17-
declare double @log10(double) readnone nounwind
18-
declare double @pow(double, double) readnone nounwind
19-
declare double @round(double) readnone nounwind
20-
declare double @sin(double) readnone nounwind
21-
declare double @sinh(double) readnone nounwind
22-
declare double @sqrt(double) readnone nounwind
23-
declare double @tan(double) readnone nounwind
24-
declare double @tanh(double) readnone nounwind
4+
declare double @acos(double) readnone nounwind willreturn
5+
declare double @asin(double) readnone nounwind willreturn
6+
declare double @atan(double) readnone nounwind willreturn
7+
declare double @atan2(double, double) readnone nounwind willreturn
8+
declare double @ceil(double) readnone nounwind willreturn
9+
declare double @cos(double) readnone nounwind willreturn
10+
declare double @cosh(double) readnone nounwind willreturn
11+
declare double @exp(double) readnone nounwind willreturn
12+
declare double @exp2(double) readnone nounwind willreturn
13+
declare double @fabs(double) readnone nounwind willreturn
14+
declare double @floor(double) readnone nounwind willreturn
15+
declare double @fmod(double, double) readnone nounwind willreturn
16+
declare double @log(double) readnone nounwind willreturn
17+
declare double @log10(double) readnone nounwind willreturn
18+
declare double @pow(double, double) readnone nounwind willreturn
19+
declare double @round(double) readnone nounwind willreturn
20+
declare double @sin(double) readnone nounwind willreturn
21+
declare double @sinh(double) readnone nounwind willreturn
22+
declare double @sqrt(double) readnone nounwind willreturn
23+
declare double @tan(double) readnone nounwind willreturn
24+
declare double @tanh(double) readnone nounwind willreturn
2525

26-
declare float @acosf(float) readnone nounwind
27-
declare float @asinf(float) readnone nounwind
28-
declare float @atanf(float) readnone nounwind
29-
declare float @atan2f(float, float) readnone nounwind
30-
declare float @ceilf(float) readnone nounwind
31-
declare float @cosf(float) readnone nounwind
32-
declare float @coshf(float) readnone nounwind
33-
declare float @expf(float) readnone nounwind
34-
declare float @exp2f(float) readnone nounwind
35-
declare float @fabsf(float) readnone nounwind
36-
declare float @floorf(float) readnone nounwind
37-
declare float @fmodf(float, float) readnone nounwind
38-
declare float @logf(float) readnone nounwind
39-
declare float @log10f(float) readnone nounwind
40-
declare float @powf(float, float) readnone nounwind
41-
declare float @roundf(float) readnone nounwind
42-
declare float @sinf(float) readnone nounwind
43-
declare float @sinhf(float) readnone nounwind
44-
declare float @sqrtf(float) readnone nounwind
45-
declare float @tanf(float) readnone nounwind
46-
declare float @tanhf(float) readnone nounwind
26+
declare float @acosf(float) readnone nounwind willreturn
27+
declare float @asinf(float) readnone nounwind willreturn
28+
declare float @atanf(float) readnone nounwind willreturn
29+
declare float @atan2f(float, float) readnone nounwind willreturn
30+
declare float @ceilf(float) readnone nounwind willreturn
31+
declare float @cosf(float) readnone nounwind willreturn
32+
declare float @coshf(float) readnone nounwind willreturn
33+
declare float @expf(float) readnone nounwind willreturn
34+
declare float @exp2f(float) readnone nounwind willreturn
35+
declare float @fabsf(float) readnone nounwind willreturn
36+
declare float @floorf(float) readnone nounwind willreturn
37+
declare float @fmodf(float, float) readnone nounwind willreturn
38+
declare float @logf(float) readnone nounwind willreturn
39+
declare float @log10f(float) readnone nounwind willreturn
40+
declare float @powf(float, float) readnone nounwind willreturn
41+
declare float @roundf(float) readnone nounwind willreturn
42+
declare float @sinf(float) readnone nounwind willreturn
43+
declare float @sinhf(float) readnone nounwind willreturn
44+
declare float @sqrtf(float) readnone nounwind willreturn
45+
declare float @tanf(float) readnone nounwind willreturn
46+
declare float @tanhf(float) readnone nounwind willreturn
4747

4848
define double @T() {
4949
; CHECK-LABEL: @T(

llvm/test/Transforms/InstSimplify/ConstProp/round.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
; RUN: opt -S -early-cse -earlycse-debug-hash < %s | FileCheck %s
22

33
declare float @roundf(float) #0
4-
declare float @llvm.round.f32(float) #0
4+
declare float @llvm.round.f32(float)
55
declare double @round(double) #0
6-
declare double @llvm.round.f64(double) #0
6+
declare double @llvm.round.f64(double)
77

88
; CHECK-LABEL: @constant_fold_round_f32_01
99
; CHECK-NEXT: ret float 1.000000e+00
@@ -89,4 +89,4 @@ define double @constant_fold_round_f64_06() #0 {
8989
ret double %x
9090
}
9191

92-
attributes #0 = { nounwind readnone }
92+
attributes #0 = { nounwind readnone willreturn }

llvm/test/Transforms/InstSimplify/ConstProp/trunc.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
; RUN: opt -S -early-cse -earlycse-debug-hash < %s | FileCheck %s
33

44
declare float @truncf(float) #0
5-
declare float @llvm.trunc.f32(float) #0
5+
declare float @llvm.trunc.f32(float)
66
declare double @trunc(double) #0
7-
declare double @llvm.trunc.f64(double) #0
7+
declare double @llvm.trunc.f64(double)
88

99
define float @constant_fold_trunc_f32_01() #0 {
1010
; CHECK-LABEL: @constant_fold_trunc_f32_01(
@@ -102,4 +102,4 @@ define double @constant_fold_trunc_f64_06() #0 {
102102
ret double %x
103103
}
104104

105-
attributes #0 = { nounwind readnone }
105+
attributes #0 = { nounwind readnone willreturn }

0 commit comments

Comments
 (0)