interp: fix inserting non-const values in a const aggregate

This bug was triggered by the following code:

    package main

    func foo() byte

    var array = [1]byte{foo()}

    func main() {
    }
This commit is contained in:
Ayke van Laethem
2019-11-17 15:03:16 +01:00
committed by Ron Evans
parent 98eee7c22a
commit 4605cbbc6e
4 changed files with 55 additions and 3 deletions
+9
View File
@@ -1,6 +1,9 @@
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64--linux"
@main.nonConst1 = local_unnamed_addr global [4 x i64] zeroinitializer
@main.nonConst2 = local_unnamed_addr global i64 0
declare void @runtime.printint64(i64) unnamed_addr
declare void @runtime.printnl() unnamed_addr
@@ -9,6 +12,10 @@ define void @runtime.initAll() unnamed_addr {
entry:
call void @runtime.printint64(i64 5)
call void @runtime.printnl()
%value1 = call i64 @someValue()
store i64 %value1, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @main.nonConst1, i32 0, i32 0)
%value2 = load i64, i64* getelementptr inbounds ([4 x i64], [4 x i64]* @main.nonConst1, i32 0, i32 0)
store i64 %value2, i64* @main.nonConst2
ret void
}
@@ -18,3 +25,5 @@ entry:
call void @runtime.printnl()
ret void
}
declare i64 @someValue() local_unnamed_addr