1 //===-- LTOModule.cpp - LLVM Link Time Optimizer --------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file implements the Link Time Optimization library. This library is
11 // intended to be used by linker to optimize code at link time.
13 //===----------------------------------------------------------------------===//
15 #include "LTOModule.h"
17 #include "llvm/Constants.h"
18 #include "llvm/LLVMContext.h"
19 #include "llvm/Module.h"
20 #include "llvm/ADT/OwningPtr.h"
21 #include "llvm/ADT/Triple.h"
22 #include "llvm/Bitcode/ReaderWriter.h"
23 #include "llvm/Support/SystemUtils.h"
24 #include "llvm/Support/MemoryBuffer.h"
25 #include "llvm/Support/MathExtras.h"
26 #include "llvm/Support/Host.h"
27 #include "llvm/Support/Path.h"
28 #include "llvm/Support/Process.h"
29 #include "llvm/Support/SourceMgr.h"
30 #include "llvm/Support/system_error.h"
31 #include "llvm/Target/Mangler.h"
32 #include "llvm/Target/SubtargetFeature.h"
33 #include "llvm/MC/MCAsmInfo.h"
34 #include "llvm/MC/MCContext.h"
35 #include "llvm/MC/MCExpr.h"
36 #include "llvm/MC/MCInst.h"
37 #include "llvm/MC/MCParser/MCAsmParser.h"
38 #include "llvm/MC/MCStreamer.h"
39 #include "llvm/MC/MCSymbol.h"
40 #include "llvm/Target/TargetAsmParser.h"
41 #include "llvm/Target/TargetMachine.h"
42 #include "llvm/Target/TargetRegistry.h"
43 #include "llvm/Target/TargetSelect.h"
47 bool LTOModule::isBitcodeFile(const void *mem, size_t length) {
48 return llvm::sys::IdentifyFileType((char*)mem, length)
49 == llvm::sys::Bitcode_FileType;
52 bool LTOModule::isBitcodeFile(const char *path) {
53 return llvm::sys::Path(path).isBitcodeFile();
56 bool LTOModule::isBitcodeFileForTarget(const void *mem, size_t length,
57 const char *triplePrefix) {
58 MemoryBuffer *buffer = makeBuffer(mem, length);
61 return isTargetMatch(buffer, triplePrefix);
65 bool LTOModule::isBitcodeFileForTarget(const char *path,
66 const char *triplePrefix) {
67 OwningPtr<MemoryBuffer> buffer;
68 if (MemoryBuffer::getFile(path, buffer))
70 return isTargetMatch(buffer.take(), triplePrefix);
73 // Takes ownership of buffer.
74 bool LTOModule::isTargetMatch(MemoryBuffer *buffer, const char *triplePrefix) {
75 std::string Triple = getBitcodeTargetTriple(buffer, getGlobalContext());
77 return (strncmp(Triple.c_str(), triplePrefix,
78 strlen(triplePrefix)) == 0);
82 LTOModule::LTOModule(Module *m, TargetMachine *t)
83 : _module(m), _target(t)
87 LTOModule *LTOModule::makeLTOModule(const char *path,
88 std::string &errMsg) {
89 OwningPtr<MemoryBuffer> buffer;
90 if (error_code ec = MemoryBuffer::getFile(path, buffer)) {
91 errMsg = ec.message();
94 return makeLTOModule(buffer.get(), errMsg);
97 LTOModule *LTOModule::makeLTOModule(int fd, const char *path,
99 std::string &errMsg) {
100 return makeLTOModule(fd, path, size, size, 0, errMsg);
103 LTOModule *LTOModule::makeLTOModule(int fd, const char *path,
107 std::string &errMsg) {
108 OwningPtr<MemoryBuffer> buffer;
109 if (error_code ec = MemoryBuffer::getOpenFile(fd, path, buffer, file_size,
110 map_size, offset, false)) {
111 errMsg = ec.message();
114 return makeLTOModule(buffer.get(), errMsg);
117 /// makeBuffer - Create a MemoryBuffer from a memory range.
118 MemoryBuffer *LTOModule::makeBuffer(const void *mem, size_t length) {
119 const char *startPtr = (char*)mem;
120 return MemoryBuffer::getMemBuffer(StringRef(startPtr, length), "", false);
124 LTOModule *LTOModule::makeLTOModule(const void *mem, size_t length,
125 std::string &errMsg) {
126 OwningPtr<MemoryBuffer> buffer(makeBuffer(mem, length));
129 return makeLTOModule(buffer.get(), errMsg);
132 LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer,
133 std::string &errMsg) {
134 static bool Initialized = false;
136 InitializeAllTargets();
137 InitializeAllAsmParsers();
141 // parse bitcode buffer
142 OwningPtr<Module> m(ParseBitcodeFile(buffer, getGlobalContext(), &errMsg));
146 std::string Triple = m->getTargetTriple();
148 Triple = sys::getHostTriple();
150 // find machine architecture for this module
151 const Target *march = TargetRegistry::lookupTarget(Triple, errMsg);
155 // construct LTModule, hand over ownership of module and target
156 SubtargetFeatures Features;
157 Features.getDefaultSubtargetFeatures("" /* cpu */, llvm::Triple(Triple));
158 std::string FeatureStr = Features.getString();
159 TargetMachine *target = march->createTargetMachine(Triple, FeatureStr);
160 LTOModule *Ret = new LTOModule(m.take(), target);
161 bool Err = Ret->ParseSymbols();
170 const char *LTOModule::getTargetTriple() {
171 return _module->getTargetTriple().c_str();
174 void LTOModule::setTargetTriple(const char *triple) {
175 _module->setTargetTriple(triple);
178 void LTOModule::addDefinedFunctionSymbol(Function *f, Mangler &mangler) {
179 // add to list of defined symbols
180 addDefinedSymbol(f, mangler, true);
182 // add external symbols referenced by this function.
183 for (Function::iterator b = f->begin(); b != f->end(); ++b) {
184 for (BasicBlock::iterator i = b->begin(); i != b->end(); ++i) {
185 for (unsigned count = 0, total = i->getNumOperands();
186 count != total; ++count) {
187 findExternalRefs(i->getOperand(count), mangler);
193 // Get string that data pointer points to.
194 bool LTOModule::objcClassNameFromExpression(Constant *c, std::string &name) {
195 if (ConstantExpr *ce = dyn_cast<ConstantExpr>(c)) {
196 Constant *op = ce->getOperand(0);
197 if (GlobalVariable *gvn = dyn_cast<GlobalVariable>(op)) {
198 Constant *cn = gvn->getInitializer();
199 if (ConstantArray *ca = dyn_cast<ConstantArray>(cn)) {
200 if (ca->isCString()) {
201 name = ".objc_class_name_" + ca->getAsString();
210 // Parse i386/ppc ObjC class data structure.
211 void LTOModule::addObjCClass(GlobalVariable *clgv) {
212 if (ConstantStruct *c = dyn_cast<ConstantStruct>(clgv->getInitializer())) {
213 // second slot in __OBJC,__class is pointer to superclass name
214 std::string superclassName;
215 if (objcClassNameFromExpression(c->getOperand(1), superclassName)) {
216 NameAndAttributes info;
217 StringMap<NameAndAttributes>::value_type &entry =
218 _undefines.GetOrCreateValue(superclassName.c_str());
219 if (!entry.getValue().name) {
220 const char *symbolName = entry.getKey().data();
221 info.name = symbolName;
222 info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;
223 entry.setValue(info);
226 // third slot in __OBJC,__class is pointer to class name
227 std::string className;
228 if (objcClassNameFromExpression(c->getOperand(2), className)) {
229 StringSet::value_type &entry =
230 _defines.GetOrCreateValue(className.c_str());
232 NameAndAttributes info;
233 info.name = entry.getKey().data();
234 info.attributes = (lto_symbol_attributes)
235 (LTO_SYMBOL_PERMISSIONS_DATA |
236 LTO_SYMBOL_DEFINITION_REGULAR |
237 LTO_SYMBOL_SCOPE_DEFAULT);
238 _symbols.push_back(info);
244 // Parse i386/ppc ObjC category data structure.
245 void LTOModule::addObjCCategory(GlobalVariable *clgv) {
246 if (ConstantStruct *c = dyn_cast<ConstantStruct>(clgv->getInitializer())) {
247 // second slot in __OBJC,__category is pointer to target class name
248 std::string targetclassName;
249 if (objcClassNameFromExpression(c->getOperand(1), targetclassName)) {
250 NameAndAttributes info;
252 StringMap<NameAndAttributes>::value_type &entry =
253 _undefines.GetOrCreateValue(targetclassName.c_str());
255 if (entry.getValue().name)
258 const char *symbolName = entry.getKey().data();
259 info.name = symbolName;
260 info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;
261 entry.setValue(info);
267 // Parse i386/ppc ObjC class list data structure.
268 void LTOModule::addObjCClassRef(GlobalVariable *clgv) {
269 std::string targetclassName;
270 if (objcClassNameFromExpression(clgv->getInitializer(), targetclassName)) {
271 NameAndAttributes info;
273 StringMap<NameAndAttributes>::value_type &entry =
274 _undefines.GetOrCreateValue(targetclassName.c_str());
275 if (entry.getValue().name)
278 const char *symbolName = entry.getKey().data();
279 info.name = symbolName;
280 info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;
281 entry.setValue(info);
286 void LTOModule::addDefinedDataSymbol(GlobalValue *v, Mangler &mangler) {
287 // Add to list of defined symbols.
288 addDefinedSymbol(v, mangler, false);
290 // Special case i386/ppc ObjC data structures in magic sections:
291 // The issue is that the old ObjC object format did some strange
292 // contortions to avoid real linker symbols. For instance, the
293 // ObjC class data structure is allocated statically in the executable
294 // that defines that class. That data structures contains a pointer to
295 // its superclass. But instead of just initializing that part of the
296 // struct to the address of its superclass, and letting the static and
297 // dynamic linkers do the rest, the runtime works by having that field
298 // instead point to a C-string that is the name of the superclass.
299 // At runtime the objc initialization updates that pointer and sets
300 // it to point to the actual super class. As far as the linker
301 // knows it is just a pointer to a string. But then someone wanted the
302 // linker to issue errors at build time if the superclass was not found.
303 // So they figured out a way in mach-o object format to use an absolute
304 // symbols (.objc_class_name_Foo = 0) and a floating reference
305 // (.reference .objc_class_name_Bar) to cause the linker into erroring when
306 // a class was missing.
307 // The following synthesizes the implicit .objc_* symbols for the linker
308 // from the ObjC data structures generated by the front end.
309 if (v->hasSection() /* && isTargetDarwin */) {
310 // special case if this data blob is an ObjC class definition
311 if (v->getSection().compare(0, 15, "__OBJC,__class,") == 0) {
312 if (GlobalVariable *gv = dyn_cast<GlobalVariable>(v)) {
317 // special case if this data blob is an ObjC category definition
318 else if (v->getSection().compare(0, 18, "__OBJC,__category,") == 0) {
319 if (GlobalVariable *gv = dyn_cast<GlobalVariable>(v)) {
324 // special case if this data blob is the list of referenced classes
325 else if (v->getSection().compare(0, 18, "__OBJC,__cls_refs,") == 0) {
326 if (GlobalVariable *gv = dyn_cast<GlobalVariable>(v)) {
332 // add external symbols referenced by this data.
333 for (unsigned count = 0, total = v->getNumOperands();
334 count != total; ++count) {
335 findExternalRefs(v->getOperand(count), mangler);
340 void LTOModule::addDefinedSymbol(GlobalValue *def, Mangler &mangler,
342 // ignore all llvm.* symbols
343 if (def->getName().startswith("llvm."))
346 // ignore available_externally
347 if (def->hasAvailableExternallyLinkage())
350 // string is owned by _defines
351 SmallString<64> Buffer;
352 mangler.getNameWithPrefix(Buffer, def, false);
354 // set alignment part log2() can have rounding errors
355 uint32_t align = def->getAlignment();
356 uint32_t attr = align ? CountTrailingZeros_32(def->getAlignment()) : 0;
358 // set permissions part
360 attr |= LTO_SYMBOL_PERMISSIONS_CODE;
362 GlobalVariable *gv = dyn_cast<GlobalVariable>(def);
363 if (gv && gv->isConstant())
364 attr |= LTO_SYMBOL_PERMISSIONS_RODATA;
366 attr |= LTO_SYMBOL_PERMISSIONS_DATA;
369 // set definition part
370 if (def->hasWeakLinkage() || def->hasLinkOnceLinkage() ||
371 def->hasLinkerPrivateWeakLinkage() ||
372 def->hasLinkerPrivateWeakDefAutoLinkage())
373 attr |= LTO_SYMBOL_DEFINITION_WEAK;
374 else if (def->hasCommonLinkage())
375 attr |= LTO_SYMBOL_DEFINITION_TENTATIVE;
377 attr |= LTO_SYMBOL_DEFINITION_REGULAR;
380 if (def->hasHiddenVisibility())
381 attr |= LTO_SYMBOL_SCOPE_HIDDEN;
382 else if (def->hasProtectedVisibility())
383 attr |= LTO_SYMBOL_SCOPE_PROTECTED;
384 else if (def->hasExternalLinkage() || def->hasWeakLinkage() ||
385 def->hasLinkOnceLinkage() || def->hasCommonLinkage() ||
386 def->hasLinkerPrivateWeakLinkage())
387 attr |= LTO_SYMBOL_SCOPE_DEFAULT;
388 else if (def->hasLinkerPrivateWeakDefAutoLinkage())
389 attr |= LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN;
391 attr |= LTO_SYMBOL_SCOPE_INTERNAL;
393 // add to table of symbols
394 NameAndAttributes info;
395 StringSet::value_type &entry = _defines.GetOrCreateValue(Buffer.c_str());
398 StringRef Name = entry.getKey();
399 info.name = Name.data();
400 assert(info.name[Name.size()] == '\0');
401 info.attributes = (lto_symbol_attributes)attr;
402 _symbols.push_back(info);
405 void LTOModule::addAsmGlobalSymbol(const char *name,
406 lto_symbol_attributes scope) {
407 StringSet::value_type &entry = _defines.GetOrCreateValue(name);
409 // only add new define if not already defined
410 if (entry.getValue())
414 const char *symbolName = entry.getKey().data();
415 uint32_t attr = LTO_SYMBOL_DEFINITION_REGULAR;
417 NameAndAttributes info;
418 info.name = symbolName;
419 info.attributes = (lto_symbol_attributes)attr;
420 _symbols.push_back(info);
423 void LTOModule::addAsmGlobalSymbolUndef(const char *name) {
424 StringMap<NameAndAttributes>::value_type &entry =
425 _undefines.GetOrCreateValue(name);
427 _asm_undefines.push_back(entry.getKey().data());
429 // we already have the symbol
430 if (entry.getValue().name)
433 uint32_t attr = LTO_SYMBOL_DEFINITION_UNDEFINED;;
434 attr |= LTO_SYMBOL_SCOPE_DEFAULT;
435 NameAndAttributes info;
436 info.name = entry.getKey().data();
437 info.attributes = (lto_symbol_attributes)attr;
439 entry.setValue(info);
442 void LTOModule::addPotentialUndefinedSymbol(GlobalValue *decl,
444 // ignore all llvm.* symbols
445 if (decl->getName().startswith("llvm."))
448 // ignore all aliases
449 if (isa<GlobalAlias>(decl))
452 SmallString<64> name;
453 mangler.getNameWithPrefix(name, decl, false);
455 StringMap<NameAndAttributes>::value_type &entry =
456 _undefines.GetOrCreateValue(name.c_str());
458 // we already have the symbol
459 if (entry.getValue().name)
462 NameAndAttributes info;
464 info.name = entry.getKey().data();
465 if (decl->hasExternalWeakLinkage())
466 info.attributes = LTO_SYMBOL_DEFINITION_WEAKUNDEF;
468 info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;
470 entry.setValue(info);
475 // Find external symbols referenced by VALUE. This is a recursive function.
476 void LTOModule::findExternalRefs(Value *value, Mangler &mangler) {
477 if (GlobalValue *gv = dyn_cast<GlobalValue>(value)) {
478 if (!gv->hasExternalLinkage())
479 addPotentialUndefinedSymbol(gv, mangler);
480 // If this is a variable definition, do not recursively process
481 // initializer. It might contain a reference to this variable
482 // and cause an infinite loop. The initializer will be
483 // processed in addDefinedDataSymbol().
487 // GlobalValue, even with InternalLinkage type, may have operands with
488 // ExternalLinkage type. Do not ignore these operands.
489 if (Constant *c = dyn_cast<Constant>(value)) {
490 // Handle ConstantExpr, ConstantStruct, ConstantArry etc.
491 for (unsigned i = 0, e = c->getNumOperands(); i != e; ++i)
492 findExternalRefs(c->getOperand(i), mangler);
497 class RecordStreamer : public MCStreamer {
499 enum State { NeverSeen, Global, Defined, DefinedGlobal, Used};
502 StringMap<State> Symbols;
504 void markDefined(const MCSymbol &Symbol) {
505 State &S = Symbols[Symbol.getName()];
518 void markGlobal(const MCSymbol &Symbol) {
519 State &S = Symbols[Symbol.getName()];
533 void markUsed(const MCSymbol &Symbol) {
534 State &S = Symbols[Symbol.getName()];
548 // FIXME: mostly copied for the obj streamer.
549 void AddValueSymbols(const MCExpr *Value) {
550 switch (Value->getKind()) {
552 // FIXME: What should we do in here?
555 case MCExpr::Constant:
558 case MCExpr::Binary: {
559 const MCBinaryExpr *BE = cast<MCBinaryExpr>(Value);
560 AddValueSymbols(BE->getLHS());
561 AddValueSymbols(BE->getRHS());
565 case MCExpr::SymbolRef:
566 markUsed(cast<MCSymbolRefExpr>(Value)->getSymbol());
570 AddValueSymbols(cast<MCUnaryExpr>(Value)->getSubExpr());
576 typedef StringMap<State>::const_iterator const_iterator;
578 const_iterator begin() {
579 return Symbols.begin();
582 const_iterator end() {
583 return Symbols.end();
586 RecordStreamer(MCContext &Context) : MCStreamer(Context) {}
588 virtual void ChangeSection(const MCSection *Section) {}
589 virtual void InitSections() {}
590 virtual void EmitLabel(MCSymbol *Symbol) {
591 Symbol->setSection(*getCurrentSection());
592 markDefined(*Symbol);
594 virtual void EmitAssemblerFlag(MCAssemblerFlag Flag) {}
595 virtual void EmitThumbFunc(MCSymbol *Func) {}
596 virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
597 // FIXME: should we handle aliases?
598 markDefined(*Symbol);
600 virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) {
601 if (Attribute == MCSA_Global)
604 virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
605 virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {}
606 virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) {}
607 virtual void EmitCOFFSymbolStorageClass(int StorageClass) {}
608 virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol,
609 unsigned Size , unsigned ByteAlignment) {
610 markDefined(*Symbol);
612 virtual void EmitCOFFSymbolType(int Type) {}
613 virtual void EndCOFFSymbolDef() {}
614 virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
615 unsigned ByteAlignment) {
616 markDefined(*Symbol);
618 virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) {}
619 virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size) {}
620 virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
621 uint64_t Size, unsigned ByteAlignment) {}
622 virtual void EmitBytes(StringRef Data, unsigned AddrSpace) {}
623 virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
624 bool isPCRel, unsigned AddrSpace) {}
625 virtual void EmitULEB128Value(const MCExpr *Value,
626 unsigned AddrSpace = 0) {}
627 virtual void EmitSLEB128Value(const MCExpr *Value,
628 unsigned AddrSpace = 0) {}
629 virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,
631 unsigned MaxBytesToEmit) {}
632 virtual void EmitCodeAlignment(unsigned ByteAlignment,
633 unsigned MaxBytesToEmit) {}
634 virtual void EmitValueToOffset(const MCExpr *Offset,
635 unsigned char Value ) {}
636 virtual void EmitFileDirective(StringRef Filename) {}
637 virtual void EmitDwarfAdvanceLineAddr(int64_t LineDelta,
638 const MCSymbol *LastLabel,
639 const MCSymbol *Label) {}
641 virtual void EmitInstruction(const MCInst &Inst) {
643 for (unsigned i = Inst.getNumOperands(); i--; )
644 if (Inst.getOperand(i).isExpr())
645 AddValueSymbols(Inst.getOperand(i).getExpr());
647 virtual void Finish() {}
651 bool LTOModule::addAsmGlobalSymbols(MCContext &Context) {
652 const std::string &inlineAsm = _module->getModuleInlineAsm();
654 OwningPtr<RecordStreamer> Streamer(new RecordStreamer(Context));
655 MemoryBuffer *Buffer = MemoryBuffer::getMemBuffer(inlineAsm);
657 SrcMgr.AddNewSourceBuffer(Buffer, SMLoc());
658 OwningPtr<MCAsmParser> Parser(createMCAsmParser(_target->getTarget(), SrcMgr,
660 *_target->getMCAsmInfo()));
661 OwningPtr<TargetAsmParser>
662 TAP(_target->getTarget().createAsmParser(*Parser.get(), *_target.get()));
663 Parser->setTargetParser(*TAP);
664 int Res = Parser->Run(false);
668 for (RecordStreamer::const_iterator i = Streamer->begin(),
669 e = Streamer->end(); i != e; ++i) {
670 StringRef Key = i->first();
671 RecordStreamer::State Value = i->second;
672 if (Value == RecordStreamer::DefinedGlobal)
673 addAsmGlobalSymbol(Key.data(), LTO_SYMBOL_SCOPE_DEFAULT);
674 else if (Value == RecordStreamer::Defined)
675 addAsmGlobalSymbol(Key.data(), LTO_SYMBOL_SCOPE_INTERNAL);
676 else if (Value == RecordStreamer::Global ||
677 Value == RecordStreamer::Used)
678 addAsmGlobalSymbolUndef(Key.data());
683 bool LTOModule::ParseSymbols() {
684 // Use mangler to add GlobalPrefix to names to match linker names.
685 MCContext Context(*_target->getMCAsmInfo(), NULL);
686 Mangler mangler(Context, *_target->getTargetData());
689 for (Module::iterator f = _module->begin(); f != _module->end(); ++f) {
690 if (f->isDeclaration())
691 addPotentialUndefinedSymbol(f, mangler);
693 addDefinedFunctionSymbol(f, mangler);
697 for (Module::global_iterator v = _module->global_begin(),
698 e = _module->global_end(); v != e; ++v) {
699 if (v->isDeclaration())
700 addPotentialUndefinedSymbol(v, mangler);
702 addDefinedDataSymbol(v, mangler);
706 if (addAsmGlobalSymbols(Context))
710 for (Module::alias_iterator i = _module->alias_begin(),
711 e = _module->alias_end(); i != e; ++i) {
712 if (i->isDeclaration())
713 addPotentialUndefinedSymbol(i, mangler);
715 addDefinedDataSymbol(i, mangler);
718 // make symbols for all undefines
719 for (StringMap<NameAndAttributes>::iterator it=_undefines.begin();
720 it != _undefines.end(); ++it) {
721 // if this symbol also has a definition, then don't make an undefine
722 // because it is a tentative definition
723 if (_defines.count(it->getKey()) == 0) {
724 NameAndAttributes info = it->getValue();
725 _symbols.push_back(info);
732 uint32_t LTOModule::getSymbolCount() {
733 return _symbols.size();
737 lto_symbol_attributes LTOModule::getSymbolAttributes(uint32_t index) {
738 if (index < _symbols.size())
739 return _symbols[index].attributes;
741 return lto_symbol_attributes(0);
744 const char *LTOModule::getSymbolName(uint32_t index) {
745 if (index < _symbols.size())
746 return _symbols[index].name;