Skip to content

Commit 3617b76

Browse files
Merge pull request #62275 from aschwaighofer/rdar102481054
Revert "Merge pull request #62203 from apple/revert-61984-colocate_in…
2 parents 58a519a + 082349e commit 3617b76

File tree

72 files changed

+119
-90
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+119
-90
lines changed

lib/IRGen/GenClass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2511,6 +2511,7 @@ static llvm::Function *emitObjCMetadataUpdateFunction(IRGenModule &IGM,
25112511
llvm::Function *f =
25122512
IGM.getAddrOfObjCMetadataUpdateFunction(D, ForDefinition);
25132513
f->setAttributes(IGM.constructInitialAttributes());
2514+
IGM.setColocateMetadataSection(f);
25142515

25152516
IRGenFunction IGF(IGM, f);
25162517
if (IGM.DebugInfo)

lib/IRGen/GenDecl.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1974,6 +1974,7 @@ void IRGenerator::emitEagerClassInitialization() {
19741974
IGM->DebugInfo->emitArtificialFunction(RegisterIGF, RegisterIGF.CurFn);
19751975
RegisterFn->setAttributes(IGM->constructInitialAttributes());
19761976
RegisterFn->setCallingConv(IGM->DefaultCC);
1977+
IGM->setColocateMetadataSection(RegisterFn);
19771978

19781979
for (ClassDecl *CD : ClassesForEagerInitialization) {
19791980
auto Ty = CD->getDeclaredType()->getCanonicalType();
@@ -2017,6 +2018,7 @@ void IRGenerator::emitObjCActorsNeedingSuperclassSwizzle() {
20172018
IGM->DebugInfo->emitArtificialFunction(RegisterIGF, RegisterIGF.CurFn);
20182019
RegisterFn->setAttributes(IGM->constructInitialAttributes());
20192020
RegisterFn->setCallingConv(IGM->DefaultCC);
2021+
IGM->setColocateMetadataSection(RegisterFn);
20202022

20212023
// Look up the SwiftNativeNSObject class.
20222024
auto swiftNativeNSObjectName =
@@ -5853,3 +5855,20 @@ IRGenModule::getOrCreateHelperFunction(StringRef fnName, llvm::Type *resultTy,
58535855

58545856
return fn;
58555857
}
5858+
5859+
void IRGenModule::setColocateMetadataSection(llvm::Function *f) {
5860+
switch (TargetInfo.OutputObjectFormat) {
5861+
case llvm::Triple::MachO:
5862+
f->setSection("__TEXT, __swift_colocat, regular, pure_instructions");
5863+
break;
5864+
case llvm::Triple::DXContainer:
5865+
case llvm::Triple::GOFF:
5866+
case llvm::Triple::SPIRV:
5867+
case llvm::Triple::UnknownObjectFormat:
5868+
case llvm::Triple::Wasm:
5869+
case llvm::Triple::ELF:
5870+
case llvm::Triple::XCOFF:
5871+
case llvm::Triple::COFF:
5872+
break;
5873+
}
5874+
}

lib/IRGen/GenMeta.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ static void emitMetadataCompletionFunction(IRGenModule &IGM,
206206
f->setAttributes(IGM.constructInitialAttributes());
207207
f->setDoesNotThrow();
208208
IGM.setHasNoFramePointer(f);
209+
IGM.setColocateMetadataSection(f);
209210

210211
IRGenFunction IGF(IGM, f);
211212

@@ -2969,6 +2970,7 @@ namespace {
29692970
f->setAttributes(IGM.constructInitialAttributes());
29702971
f->setDoesNotThrow();
29712972
IGM.setHasNoFramePointer(f);
2973+
IGM.setColocateMetadataSection(f);
29722974

29732975
IRGenFunction IGF(IGM, f);
29742976

lib/IRGen/IRGenModule.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,6 +1572,8 @@ private: \
15721572
void appendLLVMUsedConditionalEntry(llvm::GlobalVariable *var,
15731573
const ProtocolConformance *conformance);
15741574

1575+
void setColocateMetadataSection(llvm::Function *f);
1576+
15751577
llvm::Constant *
15761578
getAddrOfTypeMetadata(CanType concreteType,
15771579
TypeMetadataCanonicality canonicality =

lib/IRGen/MetadataRequest.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,6 +2052,7 @@ void irgen::emitCacheAccessFunction(IRGenModule &IGM, llvm::Function *accessor,
20522052
accessor->addFnAttr(llvm::Attribute::NoInline);
20532053
// Accessor functions don't need frame pointers.
20542054
IGM.setHasNoFramePointer(accessor);
2055+
IGM.setColocateMetadataSection(accessor);
20552056

20562057
// This function is logically 'readnone': the caller does not need
20572058
// to reason about any side effects or stores it might perform.
@@ -2404,6 +2405,7 @@ MetadataResponse irgen::emitGenericTypeMetadataAccessFunction(
24042405
generateThunkFn,
24052406
/*noinline*/ true));
24062407
}
2408+
IGM.setColocateMetadataSection(thunkFn);
24072409

24082410
// Call out to the helper.
24092411
auto arg0 = numArguments >= 1
@@ -2674,6 +2676,8 @@ irgen::getGenericTypeMetadataAccessFunction(IRGenModule &IGM,
26742676
llvm::Function *accessor =
26752677
IGM.getAddrOfGenericTypeMetadataAccessFunction(
26762678
nominal, genericArgs.Types, shouldDefine);
2679+
if (shouldDefine)
2680+
IGM.setColocateMetadataSection(accessor);
26772681

26782682
// If we're not supposed to define the accessor, or if we already
26792683
// have defined it, just return the pointer.
@@ -2917,6 +2921,7 @@ emitMetadataAccessByMangledName(IRGenFunction &IGF, CanType type,
29172921
IGM.setHasNoFramePointer(subIGF.CurFn);
29182922
if (IGM.DebugInfo)
29192923
IGM.DebugInfo->emitArtificialFunction(subIGF, subIGF.CurFn);
2924+
IGM.setColocateMetadataSection(subIGF.CurFn);
29202925

29212926
auto params = subIGF.collectParameters();
29222927
auto cache = params.claimNext();

test/IRGen/generic_classes.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,5 +415,5 @@ entry(%c : $RootGeneric<Int32>):
415415
// CHECK: ret %swift.metadata_response [[T1]]
416416
// CHECK: }
417417

418-
// OSIZE: define hidden swiftcc %swift.metadata_response @"$s15generic_classes11RootGenericCMa"(i64 %0, %swift.type* {{.*}}) [[ATTRS:#[0-9]+]] {
418+
// OSIZE: define hidden swiftcc %swift.metadata_response @"$s15generic_classes11RootGenericCMa"(i64 %0, %swift.type* {{.*}}) [[ATTRS:#[0-9]+]] {{(section)?.*}}{
419419
// OSIZE: [[ATTRS]] = {{{.*}}noinline

test/IRGen/prespecialized-metadata/class-fileprivate-2argument-1_distinct_use-1st_argument_generic_class-2nd_argument_distinct_generic_class.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func doit() {
234234
}
235235
doit()
236236

237-
// CHECK: define internal swiftcc %swift.metadata_response @"$s4main5Value[[UNIQUE_ID_1]]LLCMa"([[INT]] [[METADATA_REQUEST:%[0-9]+]], %swift.type* [[ARGUMENT1_METADATA:%[0-9]+]], %swift.type* [[ARGUMENT2_METADATA:%[0-9]+]]) #{{[0-9]+}} {
237+
// CHECK: define internal swiftcc %swift.metadata_response @"$s4main5Value[[UNIQUE_ID_1]]LLCMa"([[INT]] [[METADATA_REQUEST:%[0-9]+]], %swift.type* [[ARGUMENT1_METADATA:%[0-9]+]], %swift.type* [[ARGUMENT2_METADATA:%[0-9]+]]) #{{[0-9]+}} {{(section)?.*}}{
238238
// CHECK: entry:
239239
// CHECK: [[ERASED_ARGUMENT1:%[0-9]+]] = bitcast %swift.type* [[ARGUMENT1_METADATA]] to i8*
240240
// CHECK: [[ERASED_ARGUMENT2:%[0-9]+]] = bitcast %swift.type* [[ARGUMENT2_METADATA]] to i8*
@@ -253,7 +253,7 @@ doit()
253253
// CHECK: }
254254

255255

256-
// CHECK: define linkonce_odr hidden swiftcc %swift.metadata_response @"$s4main5Value[[UNIQUE_ID_4]]LLCyAA9Argument1ACLLCySiGAA9Argument2ACLLCySSGGMb"([[INT]] {{%[0-9]+}}) {{#[0-9]}} {
256+
// CHECK: define linkonce_odr hidden swiftcc %swift.metadata_response @"$s4main5Value[[UNIQUE_ID_4]]LLCyAA9Argument1ACLLCySiGAA9Argument2ACLLCySSGGMb"([[INT]] {{%[0-9]+}}) {{#[0-9]}} {{(section)?.*}}{
257257
// CHECK: entry:
258258
// CHECK: call swiftcc %swift.metadata_response @"$s4main9Argument1[[UNIQUE_ID_1]]LLCySiGMb"([[INT]] 0)
259259
// CHECK: call swiftcc %swift.metadata_response @"$s4main9Argument2[[UNIQUE_ID_1]]LLCySSGMb"([[INT]] 0)

test/IRGen/prespecialized-metadata/class-fileprivate-2argument-1_distinct_use-1st_argument_generic_class-2nd_argument_same_generic_class_different_value.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func doit() {
224224
}
225225
doit()
226226

227-
// CHECK: define internal swiftcc %swift.metadata_response @"$s4main5Value[[UNIQUE_ID_1]]LLCMa"([[INT]] [[METADATA_REQUEST:%[0-9]+]], %swift.type* [[ARGUMENT1_METADATA:%[0-9]+]], %swift.type* [[ARGUMENT2_METADATA:%[0-9]+]]) #{{[0-9]+}} {
227+
// CHECK: define internal swiftcc %swift.metadata_response @"$s4main5Value[[UNIQUE_ID_1]]LLCMa"([[INT]] [[METADATA_REQUEST:%[0-9]+]], %swift.type* [[ARGUMENT1_METADATA:%[0-9]+]], %swift.type* [[ARGUMENT2_METADATA:%[0-9]+]]) #{{[0-9]+}} {{(section)?.*}}{
228228
// CHECK: entry:
229229
// CHECK: [[ERASED_ARGUMENT1:%[0-9]+]] = bitcast %swift.type* [[ARGUMENT1_METADATA]] to i8*
230230
// CHECK: [[ERASED_ARGUMENT2:%[0-9]+]] = bitcast %swift.type* [[ARGUMENT2_METADATA]] to i8*
@@ -243,7 +243,7 @@ doit()
243243
// CHECK: }
244244

245245

246-
// CHECK: define linkonce_odr hidden swiftcc %swift.metadata_response @"$s4main5Value[[UNIQUE_ID_4]]LLCyAA9Argument1ACLLCySiGAFySSGGMb"([[INT]] {{%[0-9]+}}) {{#[0-9]}} {
246+
// CHECK: define linkonce_odr hidden swiftcc %swift.metadata_response @"$s4main5Value[[UNIQUE_ID_4]]LLCyAA9Argument1ACLLCySiGAFySSGGMb"([[INT]] {{%[0-9]+}}) {{#[0-9]}} {{(section)?.*}}{
247247
// CHECK: entry:
248248
// CHECK: call swiftcc %swift.metadata_response @"$s4main9Argument1[[UNIQUE_ID_1]]LLCySiGMb"([[INT]] 0)
249249
// CHECK: call swiftcc %swift.metadata_response @"$s4main9Argument1[[UNIQUE_ID_1]]LLCySSGMb"([[INT]] 0)

test/IRGen/prespecialized-metadata/class-fileprivate-2argument-1_distinct_use-1st_argument_generic_class-2nd_argument_same_generic_class_same_value.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func doit() {
224224
}
225225
doit()
226226

227-
// CHECK: define internal swiftcc %swift.metadata_response @"$s4main5Value[[UNIQUE_ID_1]]LLCMa"([[INT]] [[METADATA_REQUEST:%[0-9]+]], %swift.type* [[ARGUMENT1_METADATA:%[0-9]+]], %swift.type* [[ARGUMENT2_METADATA:%[0-9]+]]) #{{[0-9]+}} {
227+
// CHECK: define internal swiftcc %swift.metadata_response @"$s4main5Value[[UNIQUE_ID_1]]LLCMa"([[INT]] [[METADATA_REQUEST:%[0-9]+]], %swift.type* [[ARGUMENT1_METADATA:%[0-9]+]], %swift.type* [[ARGUMENT2_METADATA:%[0-9]+]]) #{{[0-9]+}} {{(section)?.*}}{
228228
// CHECK: entry:
229229
// CHECK: [[ERASED_ARGUMENT1:%[0-9]+]] = bitcast %swift.type* [[ARGUMENT1_METADATA]] to i8*
230230
// CHECK: [[ERASED_ARGUMENT2:%[0-9]+]] = bitcast %swift.type* [[ARGUMENT2_METADATA]] to i8*
@@ -243,7 +243,7 @@ doit()
243243
// CHECK: }
244244

245245

246-
// CHECK: define linkonce_odr hidden swiftcc %swift.metadata_response @"$s4main5Value[[UNIQUE_ID_4]]LLCyAA9Argument1ACLLCySiGAGGMb"([[INT]] {{%[0-9]+}}) {{#[0-9]}} {
246+
// CHECK: define linkonce_odr hidden swiftcc %swift.metadata_response @"$s4main5Value[[UNIQUE_ID_4]]LLCyAA9Argument1ACLLCySiGAGGMb"([[INT]] {{%[0-9]+}}) {{#[0-9]}} {{(section)?.*}}{
247247
// CHECK: entry:
248248
// CHECK: call swiftcc %swift.metadata_response @"$s4main9Argument1[[UNIQUE_ID_1]]LLCySiGMb"([[INT]] 0)
249249
// CHECK-NOT: call swiftcc %swift.metadata_response @"$s4main9Argument1[[UNIQUE_ID_1]]LLCySiGMb"([[INT]] 0)

test/IRGen/prespecialized-metadata/class-fileprivate-inmodule-1arg-2ancs-1distinct_use-1st_anc_gen-1arg-1st_arg_con_int-2nd_anc_gen-1st-arg_con_double.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func doit() {
236236
}
237237
doit()
238238

239-
// CHECK: define internal swiftcc %swift.metadata_response @"$s4main9Ancestor2[[UNIQUE_ID_1]]CMa"([[INT]] [[METADATA_REQUEST:%[0-9]+]], %swift.type* %1) #{{[0-9]+}} {
239+
// CHECK: define internal swiftcc %swift.metadata_response @"$s4main9Ancestor2[[UNIQUE_ID_1]]CMa"([[INT]] [[METADATA_REQUEST:%[0-9]+]], %swift.type* %1) #{{[0-9]+}} {{(section)?.*}}{
240240
// CHECK: entry:
241241
// CHECK: [[ERASED_TYPE:%[0-9]+]] = bitcast %swift.type* %1 to i8*
242242
// CHECK: {{%[0-9]+}} = call swiftcc %swift.metadata_response @__swift_instantiateCanonicalPrespecializedGenericMetadata(
@@ -253,7 +253,7 @@ doit()
253253
// CHECK: ret %swift.metadata_response {{%[0-9]+}}
254254
// CHECK: }
255255

256-
// CHECK: define internal swiftcc %swift.metadata_response @"$s4main9Ancestor1[[UNIQUE_ID_1]]CMa"([[INT]] [[METADATA_REQUEST:%[0-9]+]], %swift.type* %1) #{{[0-9]+}} {
256+
// CHECK: define internal swiftcc %swift.metadata_response @"$s4main9Ancestor1[[UNIQUE_ID_1]]CMa"([[INT]] [[METADATA_REQUEST:%[0-9]+]], %swift.type* %1) #{{[0-9]+}} {{(section)?.*}}{
257257
// CHECK: entry:
258258
// CHECK: [[ERASED_TYPE:%[0-9]+]] = bitcast %swift.type* %1 to i8*
259259
// CHECK: {{%[0-9]+}} = call swiftcc %swift.metadata_response @__swift_instantiateCanonicalPrespecializedGenericMetadata(
@@ -270,7 +270,7 @@ doit()
270270
// CHECK: ret %swift.metadata_response {{%[0-9]+}}
271271
// CHECK: }
272272

273-
// CHECK: define internal swiftcc %swift.metadata_response @"$s4main5Value[[UNIQUE_ID_1]]CMa"([[INT]] [[METADATA_REQUEST:%[0-9]+]], %swift.type* %1) #{{[0-9]+}} {
273+
// CHECK: define internal swiftcc %swift.metadata_response @"$s4main5Value[[UNIQUE_ID_1]]CMa"([[INT]] [[METADATA_REQUEST:%[0-9]+]], %swift.type* %1) #{{[0-9]+}} {{(section)?.*}}{
274274
// CHECK: entry:
275275
// CHECK: [[ERASED_TYPE:%[0-9]+]] = bitcast %swift.type* %1 to i8*
276276
// CHECK: {{%[0-9]+}} = call swiftcc %swift.metadata_response @__swift_instantiateCanonicalPrespecializedGenericMetadata(
@@ -288,7 +288,7 @@ doit()
288288
// CHECK: }
289289

290290
// CHECK: ; Function Attrs: noinline nounwind readnone
291-
// CHECK: define linkonce_odr hidden swiftcc %swift.metadata_response @"$s4main5Value[[UNIQUE_ID_1]]CySSGMb"([[INT]] {{%[0-9]+}}) #{{[0-9]+}} {
291+
// CHECK: define linkonce_odr hidden swiftcc %swift.metadata_response @"$s4main5Value[[UNIQUE_ID_1]]CySSGMb"([[INT]] {{%[0-9]+}}) #{{[0-9]+}} {{(section)?.*}}{
292292
// CHECK: entry:
293293
// CHECK: call swiftcc %swift.metadata_response @"$s4main9Ancestor1[[UNIQUE_ID_1]]CySiGMb"([[INT]] 0)
294294
// CHECK-NOT: call swiftcc %swift.metadata_response @"$s4main9Ancestor2[[UNIQUE_ID_1]]CySiGMb"([[INT]] 0)

0 commit comments

Comments
 (0)