CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
120 lines
4.4 KiB
LLVM
120 lines
4.4 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
; Test that the modular format string library call simplifier works correctly.
|
|
;
|
|
; RUN: opt < %s -passes=instcombine -S | FileCheck %s
|
|
|
|
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
|
|
|
|
@.str.int = constant [3 x i8] c"%d\00"
|
|
@.str.float = constant [3 x i8] c"%f\00"
|
|
@.str.multi = constant [6 x i8] c"%f %d\00"
|
|
@.str.noargs = constant [1 x i8] c"\00"
|
|
|
|
;; No aspects are specified, so no transformation occurs.
|
|
define void @test_basic(i32 %arg) {
|
|
; CHECK-LABEL: @test_basic(
|
|
; CHECK-NEXT: call void (ptr, ...) @basic(ptr nonnull @.str.int, i32 [[ARG:%.*]])
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
call void (ptr, ...) @basic(ptr @.str.int, i32 %arg)
|
|
ret void
|
|
}
|
|
|
|
declare void @basic(ptr, ...) #0
|
|
|
|
;; The "float" aspect is present and needed, so no transformation occurs.
|
|
define void @test_float_present(double %arg) {
|
|
; CHECK-LABEL: @test_float_present(
|
|
; CHECK-NEXT: call void (ptr, ...) @float_present(ptr nonnull @.str.float, double [[ARG:%.*]])
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
call void (ptr, ...) @float_present(ptr @.str.float, double %arg)
|
|
ret void
|
|
}
|
|
|
|
declare void @float_present(ptr, ...) #1
|
|
|
|
;; The "float" aspect is present but not needed, so the call is transformed.
|
|
define void @test_float_absent(i32 %arg) {
|
|
; CHECK-LABEL: @test_float_absent(
|
|
; CHECK-NEXT: call void (ptr, ...) @float_present_mod(ptr nonnull @.str.int, i32 [[ARG:%.*]])
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
call void (ptr, ...) @float_absent(ptr @.str.int, i32 %arg)
|
|
ret void
|
|
}
|
|
|
|
declare void @float_absent(ptr, ...) #1
|
|
|
|
;; Unknown aspects are always considered needed, so no transformation occurs.
|
|
define void @test_unknown_aspects(i32 %arg) {
|
|
; CHECK-LABEL: @test_unknown_aspects(
|
|
; CHECK-NEXT: call void (ptr, ...) @unknown_aspects(ptr nonnull @.str.int, i32 [[ARG:%.*]])
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
call void (ptr, ...) @unknown_aspects(ptr @.str.int, i32 %arg)
|
|
ret void
|
|
}
|
|
|
|
declare void @unknown_aspects(ptr, ...) #2
|
|
|
|
;; The call has no arguments to check, so the "float" aspect is not needed and
|
|
;; the call is transformed.
|
|
define void @test_no_args_to_check() {
|
|
; CHECK-LABEL: @test_no_args_to_check(
|
|
; CHECK-NEXT: call void (ptr, ...) @float_present_mod(ptr nonnull @.str.noargs)
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
call void (ptr, ...) @no_args_to_check(ptr @.str.noargs)
|
|
ret void
|
|
}
|
|
|
|
declare void @no_args_to_check(ptr, ...) #1
|
|
|
|
;; The first argument index is not 2. The "float" aspect is needed, so no
|
|
;; transformation occurs.
|
|
define void @test_first_arg_idx(i32 %ignored, double %arg) {
|
|
; CHECK-LABEL: @test_first_arg_idx(
|
|
; CHECK-NEXT: call void (i32, ptr, ...) @first_arg_idx(i32 [[IGNORED:%.*]], ptr nonnull @.str.float, double [[ARG:%.*]])
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
call void (i32, ptr, ...) @first_arg_idx(i32 %ignored, ptr @.str.float, double %arg)
|
|
ret void
|
|
}
|
|
|
|
declare void @first_arg_idx(i32, ptr, ...) #3
|
|
|
|
;; One aspect ("unknown") is needed, but one ("float") is not. The call is
|
|
;; transformed, and a reference to the needed aspect is emitted.
|
|
define void @test_partial_aspects(i32 %arg) {
|
|
; CHECK-LABEL: @test_partial_aspects(
|
|
; CHECK-NEXT: call void (ptr, ...) @multiple_aspects_mod(ptr nonnull @.str.int, i32 [[ARG:%.*]])
|
|
; CHECK-NEXT: call void @llvm.reloc.none(metadata !"basic_impl_unknown")
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
call void (ptr, ...) @partial_aspects(ptr @.str.int, i32 %arg)
|
|
ret void
|
|
}
|
|
|
|
declare void @partial_aspects(ptr, ...) #4
|
|
|
|
;; The first argument index is 0 (e.g. vsnprintf). We cannot optimize it, so
|
|
;; no transformation occurs and it shouldn't crash.
|
|
define void @test_zero_first_arg(ptr %ap) {
|
|
; CHECK-LABEL: @test_zero_first_arg(
|
|
; CHECK-NEXT: call void @zero_first_arg(ptr nonnull @.str.float, ptr [[AP:%.*]])
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
call void @zero_first_arg(ptr @.str.float, ptr %ap)
|
|
ret void
|
|
}
|
|
|
|
declare void @zero_first_arg(ptr, ptr) #5
|
|
|
|
attributes #0 = { "modular-format"="printf,1,2,basic_mod,basic_impl" }
|
|
attributes #1 = { "modular-format"="printf,1,2,float_present_mod,basic_impl,float" }
|
|
attributes #2 = { "modular-format"="printf,1,2,unknown_aspects_mod,basic_impl,unknown1,unknown2" }
|
|
attributes #3 = { "modular-format"="printf,2,3,first_arg_idx_mod,basic_impl,float" }
|
|
attributes #4 = { "modular-format"="printf,1,2,multiple_aspects_mod,basic_impl,float,unknown" }
|
|
attributes #5 = { "modular-format"="printf,1,0,zero_first_arg_mod,basic_impl,float" }
|