1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature
2 ; RUN: opt -S -passes=globalopt -o - < %s | FileCheck %s
4 ; No malloc promotion with non-null check.
6 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
7 target triple = "x86_64-unknown-linux-gnu"
9 @_ZL3g_i = internal global ptr null, align 8
10 @_ZL3g_j = global ptr null, align 8
11 @.str = private unnamed_addr constant [2 x i8] c"0\00", align 1
12 @.str.1 = private unnamed_addr constant [2 x i8] c"1\00", align 1
14 define dso_local i32 @main() {
15 ; CHECK-LABEL: define {{[^@]+}}@main() local_unnamed_addr {
17 ; CHECK-NEXT: store ptr null, ptr @_ZL3g_i, align 8
18 ; CHECK-NEXT: call fastcc void @_ZL13PutsSomethingv()
19 ; CHECK-NEXT: ret i32 0
22 store ptr null, ptr @_ZL3g_i, align 8
23 call void @_ZL13PutsSomethingv()
27 define internal void @_ZL13PutsSomethingv() {
28 ; CHECK-LABEL: define {{[^@]+}}@_ZL13PutsSomethingv() unnamed_addr {
30 ; CHECK-NEXT: [[I:%.*]] = load ptr, ptr @_ZL3g_i, align 8
31 ; CHECK-NEXT: [[I1:%.*]] = load ptr, ptr @_ZL3g_j, align 8
32 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq ptr [[I]], [[I1]]
33 ; CHECK-NEXT: br i1 [[CMP]], label [[BB2:%.*]], label [[BB6:%.*]]
35 ; CHECK-NEXT: [[I3:%.*]] = call noalias ptr @malloc(i64 4)
36 ; CHECK-NEXT: store ptr [[I3]], ptr @_ZL3g_i, align 8
37 ; CHECK-NEXT: [[I5:%.*]] = call i32 @puts(ptr @.str)
38 ; CHECK-NEXT: br label [[BB8:%.*]]
40 ; CHECK-NEXT: [[I7:%.*]] = call i32 @puts(ptr @.str.1)
41 ; CHECK-NEXT: br label [[BB8]]
43 ; CHECK-NEXT: ret void
46 %i = load ptr, ptr @_ZL3g_i, align 8
47 %i1 = load ptr, ptr @_ZL3g_j, align 8
48 %cmp = icmp eq ptr %i, %i1
49 br i1 %cmp, label %bb2, label %bb6
52 %i3 = call noalias ptr @malloc(i64 4)
53 store ptr %i3, ptr @_ZL3g_i, align 8
54 %i5 = call i32 @puts(ptr @.str)
58 %i7 = call i32 @puts(ptr @.str.1)
61 bb8: ; preds = %bb6, %bb2
65 declare dso_local noalias ptr @malloc(i64)
67 declare dso_local i32 @puts(ptr nocapture readonly)