Files
swift-mirror/test/SILGen/global_init_attribute.swift
Adrian Prantl 37e403db78 Compile libraries in testcases with -parse-as-library (NFC)
This is in preparation to a change in serialization of global variables where
this detail will matter.
2020-01-28 17:37:52 -08:00

32 lines
1.1 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -Xllvm -sil-full-demangle -parse-as-library -emit-module -o %t %S/Inputs/def_global.swift
// RUN: %target-swift-emit-silgen -Xllvm -sil-full-demangle -parse-as-library -I %t %s | %FileCheck %s
//
// Test that SILGen uses the "global_init" attribute for all global
// variable addressors.
import def_global
let InternalConst = 42
// CHECK-NOT: [global_init]
// CHECK: // global_init_attribute.InternalConst.unsafeMutableAddressor : Swift.Int
// CHECK-NEXT: sil hidden [global_init] [ossa] @$s21global_init_attribute13InternalConstSivau
func foo() -> Int {
return ExportedVar
}
func bar(i: Int) {
ExportedVar = i
}
// CHECK-NOT: [global_init]
// CHECK: // def_global.ExportedVar.unsafeMutableAddressor : Swift.Int
// CHECK-NEXT: sil [global_init] @$s10def_global11ExportedVarSivau
var InternalFoo = foo()
// CHECK-NOT: [global_init]
// CHECK: // global_init_attribute.InternalFoo.unsafeMutableAddressor : Swift.Int
// CHECK-NEXT: sil hidden [global_init] [ossa] @$s21global_init_attribute11InternalFooSivau