Files
TheRock/compiler/amd-llvm/llvm/test/Transforms/ArgumentPromotion/BPF/argpromotion.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

83 lines
3.1 KiB
LLVM

; RUN: opt -passes=argpromotion -mtriple=bpf-pc-linux -S %s | FileCheck %s
; Source:
; struct t {
; int a, b, c, d, e, f, g;
; };
; __attribute__((noinline)) static int foo1(struct t *p1, struct t *p2, struct t *p3) {
; return p1->a + p1->b + p2->c + p2->e + p3->f + p3->g;
; }
; __attribute__((noinline)) static int foo2(struct t *p1, struct t *p2, struct t *p3) {
; return p1->a + p1->b + p2->c + p2->e + p3->f;
; }
; void init(void *);
; int bar(void) {
; struct t v1, v2, v3;
; init(&v1); init(&v2); init(&v3);
; return foo1(&v1, &v2, &v3) + foo2(&v1, &v2, &v3);
; }
; Compilation flag:
; clang -target bpf -O2 -S t.c -mllvm -print-before=argpromotion -mllvm -print-module-scope
; and then do some manual tailoring to remove some attributes/metadata which is not used
; by argpromotion pass.
%struct.t = type { i32, i32, i32, i32, i32, i32, i32 }
define i32 @bar() {
entry:
%v1 = alloca %struct.t, align 4
%v2 = alloca %struct.t, align 4
%v3 = alloca %struct.t, align 4
call void @init(ptr noundef nonnull %v1)
call void @init(ptr noundef nonnull %v2)
call void @init(ptr noundef nonnull %v3)
%call = call fastcc i32 @foo1(ptr noundef nonnull %v1, ptr noundef nonnull %v2, ptr noundef nonnull %v3)
%call1 = call fastcc i32 @foo2(ptr noundef nonnull %v1, ptr noundef nonnull %v2, ptr noundef nonnull %v3)
%add = add nsw i32 %call, %call1
ret i32 %add
}
declare void @init(ptr noundef)
define internal i32 @foo1(ptr nocapture noundef readonly %p1, ptr nocapture noundef readonly %p2, ptr nocapture noundef readonly %p3) {
entry:
%0 = load i32, ptr %p1, align 4
%b = getelementptr inbounds %struct.t, ptr %p1, i64 0, i32 1
%1 = load i32, ptr %b, align 4
%add = add nsw i32 %1, %0
%c = getelementptr inbounds %struct.t, ptr %p2, i64 0, i32 2
%2 = load i32, ptr %c, align 4
%add1 = add nsw i32 %add, %2
%e = getelementptr inbounds %struct.t, ptr %p2, i64 0, i32 4
%3 = load i32, ptr %e, align 4
%add2 = add nsw i32 %add1, %3
%f = getelementptr inbounds %struct.t, ptr %p3, i64 0, i32 5
%4 = load i32, ptr %f, align 4
%add3 = add nsw i32 %add2, %4
%g = getelementptr inbounds %struct.t, ptr %p3, i64 0, i32 6
%5 = load i32, ptr %g, align 4
%add4 = add nsw i32 %add3, %5
ret i32 %add4
}
; CHECK: i32 @foo1(i32 %p1.0.val, i32 %p1.4.val, i32 %p2.8.val, i32 %p2.16.val, i32 %p3.20.val, i32 %p3.24.val)
define internal i32 @foo2(ptr noundef %p1, ptr noundef %p2, ptr noundef %p3) {
entry:
%0 = load i32, ptr %p1, align 4
%b = getelementptr inbounds %struct.t, ptr %p1, i64 0, i32 1
%1 = load i32, ptr %b, align 4
%add = add nsw i32 %0, %1
%c = getelementptr inbounds %struct.t, ptr %p2, i64 0, i32 2
%2 = load i32, ptr %c, align 4
%add1 = add nsw i32 %add, %2
%e = getelementptr inbounds %struct.t, ptr %p2, i64 0, i32 4
%3 = load i32, ptr %e, align 4
%add2 = add nsw i32 %add1, %3
%f = getelementptr inbounds %struct.t, ptr %p3, i64 0, i32 5
%4 = load i32, ptr %f, align 4
%add3 = add nsw i32 %add2, %4
ret i32 %add3
}
; CHECK: i32 @foo2(i32 %p1.0.val, i32 %p1.4.val, i32 %p2.8.val, i32 %p2.16.val, i32 %p3.20.val)