|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5 |
| 2 | +; RUN: opt -S -passes=safe-stack -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck %s --check-prefix=TLS |
| 3 | + |
| 4 | +target datalayout = "A5" |
| 5 | + |
| 6 | +; Use has wrong address space for the alloca, addrspacecast is inserted. |
| 7 | +define void @correct_alloca_addrspace() nounwind uwtable safestack { |
| 8 | +; TLS-LABEL: define void @correct_alloca_addrspace( |
| 9 | +; TLS-SAME: ) #[[ATTR0:[0-9]+]] !annotation [[META0:![0-9]+]] { |
| 10 | +; TLS-NEXT: [[ENTRY:.*:]] |
| 11 | +; TLS-NEXT: [[UNSAFE_STACK_PTR:%.*]] = load ptr addrspace(5), ptr @__safestack_unsafe_stack_ptr, align 8 |
| 12 | +; TLS-NEXT: [[UNSAFE_STACK_STATIC_TOP:%.*]] = getelementptr i8, ptr addrspace(5) [[UNSAFE_STACK_PTR]], i32 -16 |
| 13 | +; TLS-NEXT: store ptr addrspace(5) [[UNSAFE_STACK_STATIC_TOP]], ptr @__safestack_unsafe_stack_ptr, align 8 |
| 14 | +; TLS-NEXT: [[TMP0:%.*]] = getelementptr i8, ptr addrspace(5) [[UNSAFE_STACK_PTR]], i32 -8 |
| 15 | +; TLS-NEXT: [[A_UNSAFE:%.*]] = addrspacecast ptr addrspace(5) [[TMP0]] to ptr |
| 16 | +; TLS-NEXT: call void @Capture(ptr [[A_UNSAFE]]) |
| 17 | +; TLS-NEXT: store ptr addrspace(5) [[UNSAFE_STACK_PTR]], ptr @__safestack_unsafe_stack_ptr, align 8 |
| 18 | +; TLS-NEXT: ret void |
| 19 | +; |
| 20 | +entry: |
| 21 | + %a = alloca i8, align 8 |
| 22 | + call void @Capture(ptr %a) |
| 23 | + ret void |
| 24 | +} |
| 25 | + |
| 26 | +declare void @Capture(ptr) |
| 27 | +;. |
| 28 | +; TLS: [[META0]] = !{!"unsafe-stack-size", i32 16} |
| 29 | +;. |
0 commit comments