
Just insert addrspacecast in cases where the alloca uses a different address space, since I don't know what else you could possibly do.
30 lines
1.3 KiB
LLVM
30 lines
1.3 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
|
|
; RUN: opt -S -passes=safe-stack -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s --check-prefix=TLS
|
|
|
|
target datalayout = "A5"
|
|
|
|
; Use has wrong address space for the alloca, addrspacecast is inserted.
|
|
define void @correct_alloca_addrspace() nounwind uwtable safestack {
|
|
; TLS-LABEL: define void @correct_alloca_addrspace(
|
|
; TLS-SAME: ) #[[ATTR0:[0-9]+]] !annotation [[META0:![0-9]+]] {
|
|
; TLS-NEXT: [[ENTRY:.*:]]
|
|
; TLS-NEXT: [[UNSAFE_STACK_PTR:%.*]] = load ptr addrspace(5), ptr @__safestack_unsafe_stack_ptr, align 8
|
|
; TLS-NEXT: [[UNSAFE_STACK_STATIC_TOP:%.*]] = getelementptr i8, ptr addrspace(5) [[UNSAFE_STACK_PTR]], i32 -16
|
|
; TLS-NEXT: store ptr addrspace(5) [[UNSAFE_STACK_STATIC_TOP]], ptr @__safestack_unsafe_stack_ptr, align 8
|
|
; TLS-NEXT: [[TMP0:%.*]] = getelementptr i8, ptr addrspace(5) [[UNSAFE_STACK_PTR]], i32 -8
|
|
; TLS-NEXT: [[A_UNSAFE:%.*]] = addrspacecast ptr addrspace(5) [[TMP0]] to ptr
|
|
; TLS-NEXT: call void @Capture(ptr [[A_UNSAFE]])
|
|
; TLS-NEXT: store ptr addrspace(5) [[UNSAFE_STACK_PTR]], ptr @__safestack_unsafe_stack_ptr, align 8
|
|
; TLS-NEXT: ret void
|
|
;
|
|
entry:
|
|
%a = alloca i8, align 8
|
|
call void @Capture(ptr %a)
|
|
ret void
|
|
}
|
|
|
|
declare void @Capture(ptr)
|
|
;.
|
|
; TLS: [[META0]] = !{!"unsafe-stack-size", i32 16}
|
|
;.
|