forked from OSchip/llvm-project
CodeGen: handle missed case of COMDAT handling
When Protocol references are constructed, we need to add the reference symbol to a COMDAT group on non-MachO object file formats (MachO handles this by having a coalesced attribute). This adds the missing case. llvm-svn: 306622
This commit is contained in:
parent
2af2fd5f76
commit
9f83f3b251
|
@ -6381,16 +6381,15 @@ llvm::Value *CGObjCNonFragileABIMac::GenerateProtocolRef(CodeGenFunction &CGF,
|
|||
llvm::GlobalVariable *PTGV = CGM.getModule().getGlobalVariable(ProtocolName);
|
||||
if (PTGV)
|
||||
return CGF.Builder.CreateAlignedLoad(PTGV, Align);
|
||||
PTGV = new llvm::GlobalVariable(
|
||||
CGM.getModule(),
|
||||
Init->getType(), false,
|
||||
llvm::GlobalValue::WeakAnyLinkage,
|
||||
Init,
|
||||
ProtocolName);
|
||||
PTGV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(), false,
|
||||
llvm::GlobalValue::WeakAnyLinkage, Init,
|
||||
ProtocolName);
|
||||
PTGV->setSection(GetSectionName("__objc_protorefs",
|
||||
"coalesced,no_dead_strip"));
|
||||
PTGV->setVisibility(llvm::GlobalValue::HiddenVisibility);
|
||||
PTGV->setAlignment(Align.getQuantity());
|
||||
if (!CGM.getTriple().isOSBinFormatMachO())
|
||||
PTGV->setComdat(CGM.getModule().getOrInsertComdat(ProtocolName));
|
||||
CGM.addCompilerUsedGlobal(PTGV);
|
||||
return CGF.Builder.CreateAlignedLoad(PTGV, Align);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
- (void) method;
|
||||
@end
|
||||
|
||||
@protocol Q;
|
||||
@protocol R;
|
||||
|
||||
@interface I<P>
|
||||
@end
|
||||
|
||||
|
@ -11,9 +14,14 @@
|
|||
- (void) method { }
|
||||
@end
|
||||
|
||||
_Bool f(void) {
|
||||
return @protocol(Q) == @protocol(R);
|
||||
}
|
||||
|
||||
// CHECK: $"\01l_OBJC_PROTOCOL_$_P" = comdat any
|
||||
// CHECK: $"\01l_OBJC_LABEL_PROTOCOL_$_P" = comdat any
|
||||
// CHECK: $"\01l_OBJC_PROTOCOL_REFERENCE_$_Q" = comdat any
|
||||
// CHECK: $"\01l_OBJC_PROTOCOL_REFERENCE_$_R" = comdat any
|
||||
|
||||
// CHECK: @"\01l_OBJC_PROTOCOL_$_P" = {{.*}}, comdat
|
||||
// CHECK: @"\01l_OBJC_LABEL_PROTOCOL_$_P" = {{.*}}, comdat
|
||||
|
|
Loading…
Reference in New Issue