Files
TheRock/compiler/amd-llvm/llvm/test/Transforms/Inline/arg-attr-propagation.ll
T
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

105 lines
3.9 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature
; RUN: opt -passes=inline -S < %s | FileCheck --check-prefixes=CHECK,NO_ASSUME %s
; RUN: opt -passes=inline -S --enable-knowledge-retention < %s | FileCheck %s --check-prefixes=CHECK,USE_ASSUME
; The callee guarantees that the pointer argument is nonnull and dereferenceable.
; That information should transfer to the caller.
define i32 @callee(ptr dereferenceable(32) %t1) {
; CHECK-LABEL: define {{[^@]+}}@callee
; CHECK-SAME: (ptr dereferenceable(32) [[T1:%.*]]) {
; CHECK-NEXT: [[T2:%.*]] = load i32, ptr [[T1]], align 4
; CHECK-NEXT: ret i32 [[T2]]
;
%t2 = load i32, ptr %t1
ret i32 %t2
}
define i32 @callee2(ptr dereferenceable(32) %t1, i32 noundef %t2) {
; CHECK-LABEL: define {{[^@]+}}@callee2
; CHECK-SAME: (ptr dereferenceable(32) [[T1:%.*]], i32 noundef [[T2:%.*]]) {
; CHECK-NEXT: [[V:%.*]] = load i32, ptr [[T1]], align 4
; CHECK-NEXT: ret i32 [[V]]
;
%v = load i32, ptr %t1
ret i32 %v
}
; FIXME: All dereferenceability information is lost.
; The caller argument could be known nonnull and dereferenceable(32).
define i32 @caller1(ptr %t1, i32 %t2) {
; NO_ASSUME-LABEL: define {{[^@]+}}@caller1
; NO_ASSUME-SAME: (ptr [[T1:%.*]], i32 [[T2:%.*]]) {
; NO_ASSUME-NEXT: [[V_I:%.*]] = load i32, ptr [[T1]], align 4
; NO_ASSUME-NEXT: ret i32 [[V_I]]
;
; USE_ASSUME-LABEL: define {{[^@]+}}@caller1
; USE_ASSUME-SAME: (ptr [[T1:%.*]], i32 [[T2:%.*]]) {
; USE_ASSUME-NEXT: call void @llvm.assume(i1 true) [ "dereferenceable"(ptr [[T1]], i64 32), "noundef"(i32 [[T2]]) ]
; USE_ASSUME-NEXT: [[V_I:%.*]] = load i32, ptr [[T1]], align 4
; USE_ASSUME-NEXT: ret i32 [[V_I]]
;
%v = tail call i32 @callee2(ptr dereferenceable(32) %t1, i32 noundef %t2)
ret i32 %v
}
; The caller argument is nonnull, but that can be explicit.
; The dereferenceable amount could be increased.
define i32 @caller2(ptr dereferenceable(31) %t1) {
; NO_ASSUME-LABEL: define {{[^@]+}}@caller2
; NO_ASSUME-SAME: (ptr dereferenceable(31) [[T1:%.*]])
; NO_ASSUME-NEXT: [[T2_I:%.*]] = load i32, ptr [[T1]]
; NO_ASSUME-NEXT: ret i32 [[T2_I]]
;
; USE_ASSUME-LABEL: define {{[^@]+}}@caller2
; USE_ASSUME-SAME: (ptr dereferenceable(31) [[T1:%.*]])
; USE_ASSUME-NEXT: call void @llvm.assume(i1 true) [ "dereferenceable"(ptr [[T1]], i64 32) ]
; USE_ASSUME-NEXT: [[T2_I:%.*]] = load i32, ptr [[T1]]
; USE_ASSUME-NEXT: ret i32 [[T2_I]]
;
%t2 = tail call i32 @callee(ptr dereferenceable(32) %t1)
ret i32 %t2
}
; The caller argument is nonnull, but that can be explicit.
; Make sure that we don't propagate a smaller dereferenceable amount.
define i32 @caller3(ptr dereferenceable(33) %t1) {
; CHECK-LABEL: define {{[^@]+}}@caller3
; CHECK-SAME: (ptr dereferenceable(33) [[T1:%.*]])
; CHECK-NEXT: [[T2_I:%.*]] = load i32, ptr [[T1]]
; CHECK-NEXT: ret i32 [[T2_I]]
;
%t2 = tail call i32 @callee(ptr dereferenceable(32) %t1)
ret i32 %t2
}
; Make sure that we don't propagate a pointer-only attribute to a vector of pointers.
declare void @helper4(<4 x ptr> %ptr)
define void @callee4(ptr readonly %ptr, <4 x i64> %idx) {
; CHECK-LABEL: define {{[^@]+}}@callee4
; CHECK-SAME: (ptr readonly [[PTR:%.*]], <4 x i64> [[IDX:%.*]]) {
; CHECK-NEXT: [[PTRS:%.*]] = getelementptr inbounds i8, ptr [[PTR]], <4 x i64> [[IDX]]
; CHECK-NEXT: call void @helper4(<4 x ptr> [[PTRS]])
; CHECK-NEXT: ret void
;
%ptrs = getelementptr inbounds i8, ptr %ptr, <4 x i64> %idx
call void @helper4(<4 x ptr> %ptrs)
ret void
}
define void @caller4(ptr readonly %ptr, <4 x i64> %idx) {
; CHECK-LABEL: define {{[^@]+}}@caller4
; CHECK-SAME: (ptr readonly [[PTR:%.*]], <4 x i64> [[IDX:%.*]]) {
; CHECK-NEXT: [[PTRS_I:%.*]] = getelementptr inbounds i8, ptr [[PTR]], <4 x i64> [[IDX]]
; CHECK-NEXT: call void @helper4(<4 x ptr> [[PTRS_I]])
; CHECK-NEXT: ret void
;
call void @callee4(ptr readonly %ptr, <4 x i64> %idx)
ret void
}