Files
TheRock/compiler/amd-llvm/llvm/test/Transforms/SafeStack/X86/byval.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

67 lines
2.9 KiB
LLVM

; RUN: opt -safe-stack -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
; RUN: opt -passes='require<libcall-lowering-info>,safe-stack' -S -mtriple=i386-pc-linux-gnu < %s -o - | FileCheck %s
; RUN: opt -passes='require<libcall-lowering-info>,safe-stack' -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
%struct.S = type { [100 x i32] }
; Safe access to a byval argument.
define i32 @ByValSafe(ptr byval(%struct.S) nocapture readonly align 8 %zzz) norecurse nounwind readonly safestack uwtable {
entry:
; CHECK-LABEL: @ByValSafe
; CHECK-NOT: __safestack_unsafe_stack_ptr
; CHECK: ret i32
%arrayidx = getelementptr inbounds %struct.S, ptr %zzz, i64 0, i32 0, i64 3
%0 = load i32, ptr %arrayidx, align 4
ret i32 %0
}
; Unsafe access to a byval argument.
; Argument is copied to the unsafe stack.
define i32 @ByValUnsafe(ptr byval(%struct.S) nocapture readonly align 8 %zzz, i64 %idx) norecurse nounwind readonly safestack uwtable {
entry:
; CHECK-LABEL: @ByValUnsafe
; CHECK: %[[A:.*]] = load {{.*}} @__safestack_unsafe_stack_ptr
; CHECK: store {{.*}} @__safestack_unsafe_stack_ptr
; CHECK: %[[B:.*]] = getelementptr i8, ptr %[[A]], i32 -400
; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %[[B]], ptr align 8 %zzz, i64 400, i1 false)
; CHECK: ret i32
%arrayidx = getelementptr inbounds %struct.S, ptr %zzz, i64 0, i32 0, i64 %idx
%0 = load i32, ptr %arrayidx, align 4
ret i32 %0
}
; Unsafe access to a byval argument.
; Argument is copied to the unsafe stack.
; Check that dest align of memcpy is set according to datalayout prefered alignment
define i32 @ByValUnsafe2(ptr byval(%struct.S) nocapture readonly %zzz, i64 %idx) norecurse nounwind readonly safestack uwtable {
entry:
; CHECK-LABEL: @ByValUnsafe
; CHECK: %[[A:.*]] = load {{.*}} @__safestack_unsafe_stack_ptr
; CHECK: store {{.*}} @__safestack_unsafe_stack_ptr
; CHECK: %[[B:.*]] = getelementptr i8, ptr %[[A]], i32 -400
; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %[[B]], ptr %zzz, i64 400, i1 false)
; CHECK: ret i32
%arrayidx = getelementptr inbounds %struct.S, ptr %zzz, i64 0, i32 0, i64 %idx
%0 = load i32, ptr %arrayidx, align 4
ret i32 %0
}
; Highly aligned byval argument.
define i32 @ByValUnsafeAligned(ptr byval(%struct.S) nocapture readonly align 64 %zzz, i64 %idx) norecurse nounwind readonly safestack uwtable {
entry:
; CHECK-LABEL: @ByValUnsafeAligned
; CHECK: %[[A:.*]] = load {{.*}} @__safestack_unsafe_stack_ptr
; CHECK: call ptr @llvm.ptrmask.p0.i64(ptr %[[A]], i64 -64)
; CHECK: ret i32
%0 = load i32, ptr %zzz, align 64
%arrayidx2 = getelementptr inbounds %struct.S, ptr %zzz, i64 0, i32 0, i64 %idx
%1 = load i32, ptr %arrayidx2, align 4
%add = add nsw i32 %1, %0
ret i32 %add
}