r306622 - CodeGen: handle missed case of COMDAT handling
Saleem Abdulrasool via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 28 17:54:44 PDT 2017
Author: compnerd
Date: Wed Jun 28 17:54:44 2017
New Revision: 306622
URL: http://llvm.org/viewvc/llvm-project?rev=306622&view=rev
Log:
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.
Modified:
cfe/trunk/lib/CodeGen/CGObjCMac.cpp
cfe/trunk/test/CodeGenObjC/protocol-comdat.m
Modified: cfe/trunk/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCMac.cpp?rev=306622&r1=306621&r2=306622&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCMac.cpp Wed Jun 28 17:54:44 2017
@@ -6381,16 +6381,15 @@ llvm::Value *CGObjCNonFragileABIMac::Gen
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);
}
Modified: cfe/trunk/test/CodeGenObjC/protocol-comdat.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/protocol-comdat.m?rev=306622&r1=306621&r2=306622&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/protocol-comdat.m (original)
+++ cfe/trunk/test/CodeGenObjC/protocol-comdat.m Wed Jun 28 17:54:44 2017
@@ -4,6 +4,9 @@
- (void) method;
@end
+ at protocol Q;
+ at 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
More information about the cfe-commits
mailing list