Skip to content

Commit d6d28eb

Browse files
gbaraldiclaude
andcommitted
test: update multiversioning tests for new packed_flags encoding
Update metadata flag values in the three multiversioning .ll tests to match the new packed_flags() format (clone_all=1<<0, opt_size=1<<1, has_new_math=1<<3, has_new_simd=1<<4, etc). Since clone_flags() now always includes LOOP and CPU categories, loop-containing functions get cloned for more targets. Consolidate CHECK lines in annotate-only test where multiple functions now share the same clone mask. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 230d4f4 commit d6d28eb

File tree

3 files changed

+25
-40
lines changed

3 files changed

+25
-40
lines changed

test/llvmpasses/multiversioning-annotate-only.ll

Lines changed: 19 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,17 @@
55
; COM: This test checks that multiversioning correctly picks up on features that should trigger cloning
66
; COM: Note that for annotations alone, we don't need jl_fvars or jl_gvars
77

8-
; COM: Copied from src/processor.h
9-
; COM: JL_TARGET_VEC_CALL = 1 << 0,
10-
; COM: // Clone all functions
11-
; COM: JL_TARGET_CLONE_ALL = 1 << 1,
12-
; COM: // Clone when there's scalar math operations that can benefit from target-specific
13-
; COM: // optimizations. This includes `muladd`, `fma`, `fast`/`contract` flags.
14-
; COM: JL_TARGET_CLONE_MATH = 1 << 2,
15-
; COM: // Clone when the function has a loop
16-
; COM: JL_TARGET_CLONE_LOOP = 1 << 3,
17-
; COM: // Clone when the function uses any vectors
18-
; COM: // When this is specified, the cloning pass should also record if any of the cloned functions
19-
; COM: // used this in any function call (including the signature of the function itself)
20-
; COM: JL_TARGET_CLONE_SIMD = 1 << 4,
21-
; COM: // The CPU name is unknown
22-
; COM: JL_TARGET_UNKNOWN_NAME = 1 << 5,
23-
; COM: // Optimize for size for this target
24-
; COM: JL_TARGET_OPTSIZE = 1 << 6,
25-
; COM: // Only optimize for size for this target
26-
; COM: JL_TARGET_MINSIZE = 1 << 7,
27-
; COM: // Clone when the function queries CPU features
28-
; COM: JL_TARGET_CLONE_CPU = 1 << 8,
29-
; COM: // Clone when the function uses fp16
30-
; COM: JL_TARGET_CLONE_FLOAT16 = 1 << 9,
8+
; COM: Target spec packed_flags() encoding (from llvm-multiversioning.cpp):
9+
; COM: clone_all = 1 << 0
10+
; COM: opt_size = 1 << 1
11+
; COM: min_size = 1 << 2
12+
; COM: has_new_math = 1 << 3
13+
; COM: has_new_simd = 1 << 4
14+
; COM: has_new_float16 = 1 << 5
15+
; COM: has_new_bfloat16 = 1 << 6
16+
; COM:
17+
; COM: clone_flags() always includes LOOP and CPU categories.
18+
; COM: Additionally includes MATH if has_new_math, SIMD if has_new_simd, etc.
3119

3220
; COM: start with the basics, just one feature per function
3321

@@ -78,7 +66,7 @@ define noundef float @simd_fastmath_test(<4 x float> noundef %0) {
7866
ret float %4
7967
}
8068

81-
; CHECK: @loop_fastmath_test{{.*}}#[[LOOP_FASTMATH_TEST_ATTRS:[0-9]+]]
69+
; CHECK: @loop_fastmath_test{{.*}}#[[LOOP_TEST_ATTRS]]
8270
define noundef i32 @loop_fastmath_test(i32 noundef %0) {
8371
%2 = icmp sgt i32 %0, 0
8472
br i1 %2, label %7, label %5
@@ -102,7 +90,7 @@ define noundef i32 @loop_fastmath_test(i32 noundef %0) {
10290
br i1 %14, label %3, label %7, !llvm.loop !9
10391
}
10492

105-
; CHECK: @simd_loop_test{{.*}}#[[SIMD_LOOP_TEST_ATTRS:[0-9]+]]
93+
; CHECK: @simd_loop_test{{.*}}#[[LOOP_TEST_ATTRS]]
10694
define dso_local noundef i32 @simd_loop_test(<4 x i32> noundef %0) {
10795
%2 = extractelement <4 x i32> %0, i64 0
10896
%3 = icmp sgt i32 %2, 0
@@ -122,7 +110,7 @@ define dso_local noundef i32 @simd_loop_test(<4 x i32> noundef %0) {
122110
br i1 %12, label %4, label %6, !llvm.loop !9
123111
}
124112

125-
; CHECK: @simd_loop_fastmath_test{{.*}}#[[SIMD_LOOP_FASTMATH_TEST_ATTRS:[0-9]+]]
113+
; CHECK: @simd_loop_fastmath_test{{.*}}#[[LOOP_TEST_ATTRS]]
126114
define noundef i32 @simd_loop_fastmath_test(<4 x i32> noundef %0) {
127115
%2 = extractelement <4 x i32> %0, i64 0
128116
%3 = icmp sgt i32 %2, 0
@@ -180,12 +168,9 @@ define noundef i32 @uncloned(i32 noundef %0) {
180168
; COM: Note that these strings are hex-encoded bits of the target indices that will be cloned
181169
; CHECK-DAG: attributes #[[BORING_ATTRS]] = { "julia.mv.clones"="2" }
182170
; CHECK-DAG: attributes #[[FASTMATH_TEST_ATTRS]] = { "julia.mv.clones"="6" }
183-
; CHECK-DAG: attributes #[[LOOP_TEST_ATTRS]] = { "julia.mv.clones"="A" }
171+
; CHECK-DAG: attributes #[[LOOP_TEST_ATTRS]] = { "julia.mv.clones"="1E" }
184172
; CHECK-DAG: attributes #[[SIMD_TEST_ATTRS]] = { "julia.mv.clones"="12" }
185173
; CHECK-DAG: attributes #[[SIMD_FASTMATH_TEST_ATTRS]] = { "julia.mv.clones"="16" }
186-
; CHECK-DAG: attributes #[[LOOP_FASTMATH_TEST_ATTRS]] = { "julia.mv.clones"="E" }
187-
; CHECK-DAG: attributes #[[SIMD_LOOP_TEST_ATTRS]] = { "julia.mv.clones"="1A" }
188-
; CHECK-DAG: attributes #[[SIMD_LOOP_FASTMATH_TEST_ATTRS]] = { "julia.mv.clones"="1E" }
189174
; CHECK-DAG: attributes #[[FUNC_IN_GV_ATTRS]]
190175
; CHECK-SAME: "julia.mv.clones"="2"
191176
; CHECK-SAME: "julia.mv.fvar"
@@ -210,9 +195,9 @@ define noundef i32 @uncloned(i32 noundef %0) {
210195
!1 = !{i32 1, !"julia.mv.skipcloning", i32 1}
211196
!2 = !{i32 1, !"julia.mv.specs", !3}
212197
!3 = !{!4, !5, !6, !7, !8}
213-
!4 = !{!"cpubase", !"nofeatures", i32 0, i32 2}
214-
!5 = !{!"cpucloneall", !"cloneall", i32 0, i32 2}
215-
!6 = !{!"cpufastmath", !"fastmathclone", i32 0, i32 4}
216-
!7 = !{!"cpuloop", !"loopclone", i32 0, i32 8}
198+
!4 = !{!"cpubase", !"nofeatures", i32 0, i32 0}
199+
!5 = !{!"cpucloneall", !"cloneall", i32 0, i32 1}
200+
!6 = !{!"cpufastmath", !"fastmathclone", i32 0, i32 8}
201+
!7 = !{!"cpuloop", !"loopclone", i32 0, i32 0}
217202
!8 = !{!"cpusimd", !"simdclone", i32 0, i32 16}
218203
!9 = !{!9}

test/llvmpasses/multiversioning-clone-only.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ attributes #3 = {"julia.mv.clones"="6"}
210210
!1 = !{i32 1, !"julia.mv.annotated", i32 1}
211211
!2 = !{i32 1, !"julia.mv.specs", !3}
212212
!3 = !{!4, !5, !6, !7, !8}
213-
!4 = !{!"cpubase", !"nofeatures", i32 0, i32 2}
214-
!5 = !{!"cpucloneall", !"cloneall", i32 0, i32 2}
215-
!6 = !{!"cpufastmath", !"fastmathclone", i32 0, i32 4}
216-
!7 = !{!"cpuloop", !"loopclone", i32 0, i32 8}
213+
!4 = !{!"cpubase", !"nofeatures", i32 0, i32 0}
214+
!5 = !{!"cpucloneall", !"cloneall", i32 0, i32 1}
215+
!6 = !{!"cpufastmath", !"fastmathclone", i32 0, i32 8}
216+
!7 = !{!"cpuloop", !"loopclone", i32 0, i32 0}
217217
!8 = !{!"cpusimd", !"simdclone", i32 0, i32 16}
218218
; CHECK-DAG: ![[TBAA_CONST_METADATA]] = !{![[JTBAA_CONST_METADATA:[0-9]+]], ![[JTBAA_CONST_METADATA]]
219219
; CHECK-DAG: ![[JTBAA_CONST_METADATA]] = !{!"jtbaa_const"

test/llvmpasses/multiversioning-x86.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,5 +119,5 @@ define noundef i32 @simd_test_call(<4 x i32> noundef %0) {
119119
!2 = !{i32 1, !"julia.mv.specs", !3}
120120
!3 = !{!4, !5, !6}
121121
!4 = !{!"x86-64", !"+cx16,-sse3,-pclmul,-ssse3,-fma,-sse4.1,-sse4.2,-movbe,-popcnt,-aes,-xsave,-avx,-f16c,-rdrnd,-fsgsbase,-bmi,-avx2,-bmi2,-rtm,-avx512f,-avx512dq,-rdseed,-adx,-avx512ifma,-clflushopt,-clwb,-avx512cd,-sha,-avx512bw,-avx512vl,-avx512vbmi,-pku,-waitpkg,-avx512vbmi2,-shstk,-gfni,-vaes,-vpclmulqdq,-avx512vnni,-avx512bitalg,-avx512vpopcntdq,-rdpid,-cldemote,-movdiri,-movdir64b,-enqcmd,-uintr,-avx512vp2intersect,-serialize,-tsxldtrk,-pconfig,-amx-bf16,-avx512fp16,-amx-tile,-amx-int8,-sahf,-lzcnt,-sse4a,-prfchw,-xop,-fma4,-tbm,-mwaitx,-xsaveopt,-xsavec,-xsaves,-clzero,-wbnoinvd,-avxvnni,-avx512bf16,-ptwrite,+sse2,+mmx,+fxsr,+64bit,+cx8", i32 0, i32 0}
122-
!5 = !{!"sandybridge", !"+sahf,+avx,+xsave,+popcnt,+sse4.2,+sse4.1,+cx16,+ssse3,+pclmul,+sse3,-fma,-movbe,-aes,-f16c,-rdrnd,-fsgsbase,-bmi,-avx2,-bmi2,-rtm,-avx512f,-avx512dq,-rdseed,-adx,-avx512ifma,-clflushopt,-clwb,-avx512cd,-sha,-avx512bw,-avx512vl,-avx512vbmi,-pku,-waitpkg,-avx512vbmi2,-shstk,-gfni,-vaes,-vpclmulqdq,-avx512vnni,-avx512bitalg,-avx512vpopcntdq,-rdpid,-cldemote,-movdiri,-movdir64b,-enqcmd,-uintr,-avx512vp2intersect,-serialize,-tsxldtrk,-pconfig,-amx-bf16,-avx512fp16,-amx-tile,-amx-int8,-lzcnt,-sse4a,-prfchw,-xop,-fma4,-tbm,-mwaitx,-xsaveopt,-xsavec,-xsaves,-clzero,-wbnoinvd,-avxvnni,-avx512bf16,-ptwrite,+sse2,+mmx,+fxsr,+64bit,+cx8", i32 0, i32 2}
123-
!6 = !{!"haswell", !"+lzcnt,+sahf,+bmi2,+avx2,+bmi,+fsgsbase,+f16c,+avx,+xsave,+popcnt,+movbe,+sse4.2,+sse4.1,+cx16,+fma,+ssse3,+pclmul,+sse3,-aes,-rdrnd,-rtm,-avx512f,-avx512dq,-rdseed,-adx,-avx512ifma,-clflushopt,-clwb,-avx512cd,-sha,-avx512bw,-avx512vl,-avx512vbmi,-pku,-waitpkg,-avx512vbmi2,-shstk,-gfni,-vaes,-vpclmulqdq,-avx512vnni,-avx512bitalg,-avx512vpopcntdq,-rdpid,-cldemote,-movdiri,-movdir64b,-enqcmd,-uintr,-avx512vp2intersect,-serialize,-tsxldtrk,-pconfig,-amx-bf16,-avx512fp16,-amx-tile,-amx-int8,-sse4a,-prfchw,-xop,-fma4,-tbm,-mwaitx,-xsaveopt,-xsavec,-xsaves,-clzero,-wbnoinvd,-avxvnni,-avx512bf16,-ptwrite,+sse2,+mmx,+fxsr,+64bit,+cx8", i32 1, i32 284}
122+
!5 = !{!"sandybridge", !"+sahf,+avx,+xsave,+popcnt,+sse4.2,+sse4.1,+cx16,+ssse3,+pclmul,+sse3,-fma,-movbe,-aes,-f16c,-rdrnd,-fsgsbase,-bmi,-avx2,-bmi2,-rtm,-avx512f,-avx512dq,-rdseed,-adx,-avx512ifma,-clflushopt,-clwb,-avx512cd,-sha,-avx512bw,-avx512vl,-avx512vbmi,-pku,-waitpkg,-avx512vbmi2,-shstk,-gfni,-vaes,-vpclmulqdq,-avx512vnni,-avx512bitalg,-avx512vpopcntdq,-rdpid,-cldemote,-movdiri,-movdir64b,-enqcmd,-uintr,-avx512vp2intersect,-serialize,-tsxldtrk,-pconfig,-amx-bf16,-avx512fp16,-amx-tile,-amx-int8,-lzcnt,-sse4a,-prfchw,-xop,-fma4,-tbm,-mwaitx,-xsaveopt,-xsavec,-xsaves,-clzero,-wbnoinvd,-avxvnni,-avx512bf16,-ptwrite,+sse2,+mmx,+fxsr,+64bit,+cx8", i32 0, i32 1}
123+
!6 = !{!"haswell", !"+lzcnt,+sahf,+bmi2,+avx2,+bmi,+fsgsbase,+f16c,+avx,+xsave,+popcnt,+movbe,+sse4.2,+sse4.1,+cx16,+fma,+ssse3,+pclmul,+sse3,-aes,-rdrnd,-rtm,-avx512f,-avx512dq,-rdseed,-adx,-avx512ifma,-clflushopt,-clwb,-avx512cd,-sha,-avx512bw,-avx512vl,-avx512vbmi,-pku,-waitpkg,-avx512vbmi2,-shstk,-gfni,-vaes,-vpclmulqdq,-avx512vnni,-avx512bitalg,-avx512vpopcntdq,-rdpid,-cldemote,-movdiri,-movdir64b,-enqcmd,-uintr,-avx512vp2intersect,-serialize,-tsxldtrk,-pconfig,-amx-bf16,-avx512fp16,-amx-tile,-amx-int8,-sse4a,-prfchw,-xop,-fma4,-tbm,-mwaitx,-xsaveopt,-xsavec,-xsaves,-clzero,-wbnoinvd,-avxvnni,-avx512bf16,-ptwrite,+sse2,+mmx,+fxsr,+64bit,+cx8", i32 1, i32 24}

0 commit comments

Comments
 (0)