<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi.<div><br></div><div>I've tried to export inheritance of CXX classes into Metadata:</div><div>!ISPDIL_INH_<class or struct name> = {!0}</div><div>!0 = {!metadata <one of parent>, !metadata <another parent>}</div><div><br></div><div>For achieving this I've changed ConvertRecordDeclType in CodeGenTypes.cpp:</div><div><br></div><div><div>llvm::StructType *CodeGenTypes::ConvertRecordDeclType(const RecordDecl *RD) {</div><div> // TagDecl's are not necessarily unique, instead use the (clang)</div><div> // type connected to the decl.</div><div> const Type *Key = Context.getTagDeclType(RD).getTypePtr();</div><div><br></div><div> llvm::StructType *&Entry = RecordDeclTypes[Key];</div><div><br></div><div> // If we don't have a StructType at all yet, create the forward declaration.</div><div> if (Entry == 0) {</div><div> Entry = llvm::StructType::create(getLLVMContext());</div><div> addRecordTypeName(RD, Entry, "");</div><div> }</div><div> llvm::StructType *Ty = Entry;</div><div> </div><div> // If this is still a forward declaration, or the LLVM type is already</div><div> // complete, there's nothing more to do.</div><div> RD = RD->getDefinition();</div><div> if (RD == 0 || !RD->isCompleteDefinition() || !Ty->isOpaque())</div><div> return Ty;</div><div> </div><div> // If converting this type would cause us to infinitely loop, don't do it!</div><div> if (!isSafeToConvert(RD, *this)) {</div><div> DeferredRecords.push_back(RD);</div><div> return Ty;</div><div> }</div><div><br></div><div> // Okay, this is a definition of a type. Compile the implementation now.</div><div> bool InsertResult = RecordsBeingLaidOut.insert(Key); (void)InsertResult;</div><div> assert(InsertResult && "Recursively compiling a struct?");</div><div> </div><div> // Force conversion of non-virtual base classes recursively.</div><div><br></div><div><br></div><div> if (const CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {</div><div><b><span class="Apple-tab-span" style="white-space:pre"> </span>std::vector<llvm::StructType *> parentsForISPDIL;</b></div><div> for (CXXRecordDecl::base_class_const_iterator i = CRD->bases_begin(), e = CRD->bases_end(); i != e; ++i) {</div><div> if (i->isVirtual()) continue;</div><div> </div><div><b> parentsForISPDIL.push_back(ConvertRecordDeclType(i->getType()->getAs<RecordType>()->getDecl()));</b></div><div><b> </b> }</div><div><br></div><div><b> // ISPDIL inheritance import</b></div><div><b><br></b></div><div><b> std::vector<llvm::Value*> parents;</b></div><div><b> for (std::vector<llvm::StructType*>::iterator p = parentsForISPDIL.begin(); p!=parentsForISPDIL.end(); p++) {</b></div><div><b> <span class="Apple-tab-span" style="white-space:pre"> </span> parents.push_back(llvm::MDString::get(Ty->getContext(), (*p)->getName()));</b></div><div><b> }</b></div><div><b><br></b></div><div><b> llvm::MDNode* Node = llvm::MDNode::get(Ty->getContext(), parents);</b></div><div><b> llvm::NamedMDNode* NMD = TheModule.getOrInsertNamedMetadata(std::string("ISPDIL_INH_").append(Ty->getName()));</b></div><div><b> NMD->addOperand(Node);</b></div><div><br></div><div> }</div><div><br></div><div> // Layout fields.</div><div> CGRecordLayout *Layout = ComputeRecordLayout(RD, Ty);</div><div> CGRecordLayouts[Key] = Layout;</div><div><br></div><div> // We're done laying out this struct.</div><div> bool EraseResult = RecordsBeingLaidOut.erase(Key); (void)EraseResult;</div><div> assert(EraseResult && "struct not in RecordsBeingLaidOut set?");</div><div> </div><div> // If this struct blocked a FunctionType conversion, then recompute whatever</div><div> // was derived from that.</div><div> // FIXME: This is hugely overconservative.</div><div> if (SkippedLayout)</div><div> TypeCache.clear();</div><div> </div><div> // If we're done converting the outer-most record, then convert any deferred</div><div> // structs as well.</div><div> if (RecordsBeingLaidOut.empty())</div><div> while (!DeferredRecords.empty())</div><div> ConvertRecordDeclType(DeferredRecords.pop_back_val());</div><div><br></div><div> return Ty;</div><div>}</div></div><div><br></div><div><br></div><div>But with that patch I haven't some classes from Module in my Metadata in one cases and I have some names in my metadata but module haven't StructTypes according this names. </div><div><br></div><div>How can I solve my problem correctly? Thanks!</div><div><br></div><div><br><div><div apple-content-edited="true">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div></div><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Yours sincerely,</div><div>Kadysev Mikhail</div></div></span></div>
</div>
<br></div></div></body></html>