xref: /llvm-project/llvm/test/Transforms/GlobalOpt/MallocSROA-section-no-null-opt.ll (revision d586bd5ca231a6022f439d4c6e43cfeeb53eb1d6)
1; RUN: opt -passes=globalopt -S < %s | FileCheck %s
2; CHECK: @Y
3; CHECK: section ".foo"
4
5%struct.xyz = type { double, i32 }
6
7@Y = internal global ptr null ,section ".foo"            ; <ptr> [#uses=2]
8@numf2s = external global i32                     ; <ptr> [#uses=1]
9
10define void @init_net() #0 {
11; CHECK-LABEL: init_net(
12; CHECK: load i32, ptr @numf2s
13; CHECK: call ptr @malloc
14; CHECK: store ptr {{.*}}, ptr @Y
15entry:
16  %0 = load i32, ptr @numf2s, align 4                 ; <i32> [#uses=1]
17  %mallocsize2 = shl i32 %0, 4                    ; <i32> [#uses=1]
18  %malloccall3 = tail call ptr @malloc(i32 %mallocsize2)  ; <ptr> [#uses=1]
19  store ptr %malloccall3, ptr @Y, align 8
20  ret void
21}
22
23define ptr @load_train() #0 {
24; CHECK-LABEL: load_train(
25; CHECK: load ptr, ptr @Y
26entry:
27  %0 = load ptr, ptr @Y, align 8             ; <ptr> [#uses=0]
28  ret ptr %0
29}
30
31declare noalias ptr @malloc(i32)
32
33attributes #0 = { null_pointer_is_valid }
34