@@ -2,6 +2,8 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
2
2
target triple = "x86_64--linux"
3
3
4
4
@main.v1 = internal global i64 0
5
+ @main.nonConst1 = global [4 x i64 ] zeroinitializer
6
+ @main.nonConst2 = global i64 0
5
7
6
8
declare void @runtime.printint64 (i64 ) unnamed_addr
7
9
@@ -31,6 +33,20 @@ define internal void @main.init() unnamed_addr {
31
33
entry:
32
34
store i64 3 , i64* @main.v1
33
35
call void @"main.init#1" ()
36
+
37
+ ; test the following pattern:
38
+ ; func someValue() int // extern function
39
+ ; var nonConst1 = [4]int{someValue(), 0, 0, 0}
40
+ %value1 = call i64 @someValue ()
41
+ %gep1 = getelementptr [4 x i64 ], [4 x i64 ]* @main.nonConst1 , i32 0 , i32 0
42
+ store i64 %value1 , i64* %gep1
43
+
44
+ ; Test that the global really is marked dirty:
45
+ ; var nonConst2 = nonConst1[0]
46
+ %gep2 = getelementptr [4 x i64 ], [4 x i64 ]* @main.nonConst1 , i32 0 , i32 0
47
+ %value2 = load i64 , i64* %gep2
48
+ store i64 %value2 , i64* @main.nonConst2
49
+
34
50
ret void
35
51
}
36
52
40
56
call void @runtime.printnl ()
41
57
ret void
42
58
}
59
+
60
+ declare i64 @someValue ()
0 commit comments