Files
swift-mirror/test/DebugInfo/generic_arg2.swift
Joe Groff 2d3eba9e0d IRGen: Reuse value witness table projections.
Don't project every value witness from the metadata every time we need one; this wastes code size in a way LLVM can't really optimize since it doesn't know the metadata is immutable. The code size wins on the standard library are disappointingly small (stdlib only shrinks by 4KB), but this makes generic IR a lot more compact and easier to read.

Swift SVN r28095
2015-05-03 05:00:40 +00:00

33 lines
980 B
Swift

// RUN: %target-swift-frontend %s -emit-ir -g -o - | FileCheck %s
func markUsed<T>(t: T) {}
// CHECK: @_TFC12generic_arg25Class3foo{{.*}}, %swift.type* %U
// CHECK: %[[Y:.*]] = call %swift.opaque* %allocateBuffer4([{{(24|12)}} x i8]* %{{.*}}, %swift.type* %U)
// store %swift.opaque* %[[Y]], %swift.opaque** %[[Y_SHADOW:.*]], align
// CHECK: call void @llvm.dbg.value(metadata %swift.opaque* %[[Y]], {{.*}}metadata ![[U:.*]], metadata !{{[0-9]+}}), !dbg
// Make sure there is no conflicting dbg.value for this variable.x
// CHECK-NOT: dbg.value{{.*}}metadata ![[U]]
class Class <T> {
// CHECK: ![[U]] = !DILocalVariable(tag: DW_TAG_arg_variable, name: "y",{{.*}} line: [[@LINE+1]],
func foo<U>(var x: T, var y: U) {
markUsed("hello world")
}
func bar(var x: String, var y: Int) {
markUsed("hello world")
}
init() {}
}
func main() {
var object: Class<String> = Class()
var x = "hello"
var y = 1234
object.bar(x, y: y)
object.foo(x, y: y)
}
main()