Skip to content

Commit 67e87a1

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-next
2 parents d97678c + e5ef796 commit 67e87a1

File tree

6 files changed

+23
-34
lines changed

6 files changed

+23
-34
lines changed

lib/IRGen/IRGenDebugInfo.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ class IRGenDebugInfoImpl : public IRGenDebugInfo {
179179
bool IsLocalToUnit, bool InFixedBuffer,
180180
Optional<SILLocation> Loc);
181181
void emitTypeMetadata(IRGenFunction &IGF, llvm::Value *Metadata,
182-
unsigned Depth, unsigned Index, StringRef ArchetypeName,
183-
StringRef AssocType);
182+
unsigned Depth, unsigned Index, StringRef Name);
184183

185184
/// Return the DIBuilder.
186185
llvm::DIBuilder &getBuilder() { return DBuilder; }
@@ -2256,8 +2255,7 @@ void IRGenDebugInfoImpl::emitGlobalVariableDeclaration(
22562255
void IRGenDebugInfoImpl::emitTypeMetadata(IRGenFunction &IGF,
22572256
llvm::Value *Metadata, unsigned Depth,
22582257
unsigned Index,
2259-
StringRef ArchetypeName,
2260-
StringRef AssocType) {
2258+
StringRef Name) {
22612259
if (Opts.DebugInfoLevel <= IRGenDebugInfoLevel::LineTables)
22622260
return;
22632261

@@ -2269,9 +2267,9 @@ void IRGenDebugInfoImpl::emitTypeMetadata(IRGenFunction &IGF,
22692267
llvm::SmallString<8> Buf;
22702268
static const char *Tau = u8"\u03C4";
22712269
llvm::raw_svector_ostream OS(Buf);
2272-
OS << '$' << Tau << '_' << Depth << '_' << Index << AssocType;
2270+
OS << '$' << Tau << '_' << Depth << '_' << Index;
22732271
auto DbgTy = DebugTypeInfo::getArchetype(
2274-
getMetadataType(ArchetypeName)->getDeclaredInterfaceType().getPointer(),
2272+
getMetadataType(Name)->getDeclaredInterfaceType().getPointer(),
22752273
Metadata->getType(), Size(CI.getTargetInfo().getPointerWidth(0)),
22762274
Alignment(CI.getTargetInfo().getPointerAlign(0)));
22772275
emitVariableDeclaration(IGF.Builder, Metadata, DbgTy, IGF.getDebugScope(),
@@ -2394,10 +2392,9 @@ void IRGenDebugInfo::emitGlobalVariableDeclaration(
23942392

23952393
void IRGenDebugInfo::emitTypeMetadata(IRGenFunction &IGF, llvm::Value *Metadata,
23962394
unsigned Depth, unsigned Index,
2397-
StringRef ArchetypeName,
2398-
StringRef AssocType) {
2395+
StringRef Name) {
23992396
static_cast<IRGenDebugInfoImpl *>(this)->emitTypeMetadata(
2400-
IGF, Metadata, Depth, Index, ArchetypeName, AssocType);
2397+
IGF, Metadata, Depth, Index, Name);
24012398
}
24022399

24032400
llvm::DIBuilder &IRGenDebugInfo::getBuilder() {

lib/IRGen/IRGenDebugInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ class IRGenDebugInfo {
149149

150150
/// Emit debug metadata for type metadata (for generic types). So meta.
151151
void emitTypeMetadata(IRGenFunction &IGF, llvm::Value *Metadata,
152-
unsigned Depth, unsigned Index, StringRef ArchetypeName,
153-
StringRef AssocType);
152+
unsigned Depth, unsigned Index, StringRef Name);
154153

155154
/// Return the DIBuilder.
156155
llvm::DIBuilder &getBuilder();

lib/IRGen/LocalTypeData.cpp

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -332,17 +332,17 @@ static void maybeEmitDebugInfoForLocalTypeData(IRGenFunction &IGF,
332332
if (key.Kind != LocalTypeDataKind::forFormalTypeMetadata())
333333
return;
334334

335-
// Only for archetypes, and not for opened archetypes.
336-
auto type = dyn_cast<ArchetypeType>(key.Type);
335+
// Only for primary archetypes.
336+
auto type = dyn_cast<PrimaryArchetypeType>(key.Type);
337337
if (!type)
338338
return;
339-
if (isa<OpenedArchetypeType>(type))
340-
return;
339+
340+
auto *typeParam = type->getInterfaceType()->castTo<GenericTypeParamType>();
341+
auto name = typeParam->getName().str();
341342

342343
llvm::Value *data = value.getMetadata();
343344

344345
// At -O0, create an alloca to keep the type alive.
345-
auto name = type->getFullName();
346346
if (!IGF.IGM.IRGen.Opts.shouldOptimize()) {
347347
auto alloca =
348348
IGF.createAlloca(data->getType(), IGF.IGM.getPointerAlignment(), name);
@@ -354,19 +354,10 @@ static void maybeEmitDebugInfoForLocalTypeData(IRGenFunction &IGF,
354354
if (!IGF.IGM.DebugInfo)
355355
return;
356356

357-
// Emit debug info for the metadata.
358-
llvm::SmallString<8> AssocType;
359-
auto *oocTy = type->mapTypeOutOfContext().getPointer();
360-
{
361-
llvm::raw_svector_ostream OS(AssocType);
362-
while (auto *dependentMemberType = dyn_cast<DependentMemberType>(oocTy)) {
363-
OS << '.' << dependentMemberType->getName();
364-
oocTy = dependentMemberType->getBase().getPointer();
365-
}
366-
}
367-
auto *typeParam = cast<GenericTypeParamType>(oocTy);
368-
IGF.IGM.DebugInfo->emitTypeMetadata(IGF, data, typeParam->getDepth(),
369-
typeParam->getIndex(), name, AssocType);
357+
IGF.IGM.DebugInfo->emitTypeMetadata(IGF, data,
358+
typeParam->getDepth(),
359+
typeParam->getIndex(),
360+
name);
370361
}
371362

372363
void

test/DebugInfo/inlined-generics.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ func foo1<T:P>(_ t: T, _ dt: T.DT1) -> T.DT1 {
1212

1313
// CHECK: define {{.*}}@"$s4main4foo2yyxAA1PRzlF"
1414
public func foo2<S:P>(_ s: S) {
15-
// CHECK: call void @llvm.dbg.value(metadata %swift.type* %S.DT1,
15+
// CHECK: call void @llvm.dbg.value(metadata %swift.type* %S,
1616
// CHECK-SAME: metadata ![[META:[0-9]+]]
1717
foo1(s, s.getDT())
18-
// T.DT1 should get substituted with S.DT1.
19-
// CHECK: ![[META]] = !DILocalVariable(name: "$\CF\84_0_0.DT1"
18+
// T should get substituted with S
19+
// CHECK: ![[META]] = !DILocalVariable(name: "$\CF\84_0_0"
2020
}
2121

2222

test/IRGen/associated_types.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,12 @@ func testFastRuncible<T: Runcible, U: FastRuncible>(_ t: T, u: U)
7777
// Note that we actually look things up in T, which is going to prove unfortunate.
7878
// CHECK: [[T2:%.*]] = call swiftcc %swift.metadata_response @swift_getAssociatedTypeWitness([[INT]] 0, i8** %T.Runcible, %swift.type* %T, %swift.protocol_requirement* getelementptr{{.*}}i32 12), i32 -1), %swift.protocol_requirement* getelementptr inbounds (<{{.*}}>, <{{.*}}>* @"$s16associated_types8RuncibleMp", i32 0, i32 14)) [[NOUNWIND_READNONE:#.*]]
7979
// CHECK-NEXT: %T.RuncerType = extractvalue %swift.metadata_response [[T2]], 0
80-
// CHECK-NEXT: store %swift.type*
8180
// 2. Get the witness table for U.RuncerType.Runcee : Speedy
8281
// 2a. Get the protocol witness table for U.RuncerType : FastRuncer.
8382
// CHECK-NEXT: %T.RuncerType.FastRuncer = call swiftcc i8** @swift_getAssociatedConformanceWitness(i8** %U.FastRuncible, %swift.type* %U, %swift.type* %T.RuncerType
8483
// 1c. Get the type metadata for U.RuncerType.Runcee.
8584
// CHECK-NEXT: [[T2:%.*]] = call swiftcc %swift.metadata_response @swift_getAssociatedTypeWitness([[INT]] 0, i8** %T.RuncerType.FastRuncer, %swift.type* %T.RuncerType, {{.*}}, %swift.protocol_requirement* getelementptr inbounds (<{{.*}}>, <{{.*}}>* @"$s16associated_types10FastRuncerMp", i32 0, i32 10))
8685
// CHECK-NEXT: %T.RuncerType.Runcee = extractvalue %swift.metadata_response [[T2]], 0
87-
// CHECK-NEXT: store %swift.type*
8886
// 2b. Get the witness table for U.RuncerType.Runcee : Speedy.
8987
// CHECK-NEXT: %T.RuncerType.Runcee.Speedy = call swiftcc i8** @swift_getAssociatedConformanceWitness(i8** %T.RuncerType.FastRuncer, %swift.type* %T.RuncerType, %swift.type* %T.RuncerType.Runcee
9088
// 3. Perform the actual call.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: %target-swift-emit-silgen %s | %FileCheck %s
2+
3+
// CHECK-LABEL: sil [_weakLinked] [ossa] @$s21weak_linked_attribute0A8FunctionyyF : $@convention(thin) () -> ()
4+
@_weakLinked public func weakFunction() {}

0 commit comments

Comments
 (0)