lib/IRGen/GenMeta.cpp
llvm::Value *irgen::emitProtocolDescriptorRef(IRGenFunction &IGF,
                                              ProtocolDecl *protocol) {
  if (!protocol->isObjC())
    return IGF.IGM.getAddrOfProtocolDescriptor(protocol);
  
  auto refVar = IGF.IGM.getAddrOfObjCProtocolRef(protocol, NotForDefinition);
  llvm::Value *val
    = IGF.Builder.CreateLoad(refVar, IGF.IGM.getPointerAlignment());
  val = IGF.Builder.CreateBitCast(val,
                          IGF.IGM.ProtocolDescriptorStructTy->getPointerTo());
  return val;
}
/// \brief Load a reference to the protocol descriptor for the given protocol.
///
/// For Swift protocols, this is a constant reference to the protocol descriptor
/// symbol.
/// For ObjC protocols, descriptors are uniqued at runtime by the ObjC runtime.
/// We need to load the unique reference from a global variable fixed up at
/// startup.
\brief Load a reference to the protocol descriptor for the given protocol.
For Swift protocols, this is a constant reference to the protocol descriptor
symbol.
For ObjC protocols, descriptors are uniqued at runtime by the ObjC runtime.
We need to load the unique reference from a global variable fixed up at
startup.
\ brief Load a reference to the protocol descriptor for the given protocol . For Swift protocols this is a constant reference to the protocol descriptor symbol . For ObjC protocols descriptors are uniqued at runtime by the ObjC runtime . We need to load the unique reference from a global variable fixed up at startup .
llvm::Value *irgen::emitProtocolDescriptorRef(IRGenFunction &IGF,
                                              ProtocolDecl *protocol) {
  if (!protocol->isObjC())
    return IGF.IGM.getAddrOfProtocolDescriptor(protocol);
  auto refVar = IGF.IGM.getAddrOfObjCProtocolRef(protocol, NotForDefinition);
  llvm::Value *val
    = IGF.Builder.CreateLoad(refVar, IGF.IGM.getPointerAlignment());
  val = IGF.Builder.CreateBitCast(val,
                          IGF.IGM.ProtocolDescriptorStructTy->getPointerTo());
  return val;
}
llvm :: Value * irgen :: emitProtocolDescriptorRef ( IRGenFunction & IGF , ProtocolDecl * protocol ) { if ( ! protocol -> isObjC ( ) ) return IGF . IGM . getAddrOfProtocolDescriptor ( protocol ) ; auto refVar = IGF . IGM . getAddrOfObjCProtocolRef ( protocol , NotForDefinition ) ; llvm :: Value * val = IGF . Builder . CreateLoad ( refVar , IGF . IGM . getPointerAlignment ( ) ) ; val = IGF . Builder . CreateBitCast ( val , IGF . IGM . ProtocolDescriptorStructTy -> getPointerTo ( ) ) ; return val ; }
\brief Load a reference to the protocol descriptor for the given protocol.
\ brief Load a reference to the protocol descriptor for the given protocol .