LLVM API Documentation

LTOModule.cpp
Go to the documentation of this file.
00001 //===-- LTOModule.cpp - LLVM Link Time Optimizer --------------------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file implements the Link Time Optimization library. This library is
00011 // intended to be used by linker to optimize code at link time.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #include "llvm/LTO/LTOModule.h"
00016 #include "llvm/ADT/Triple.h"
00017 #include "llvm/Bitcode/ReaderWriter.h"
00018 #include "llvm/CodeGen/Analysis.h"
00019 #include "llvm/IR/Constants.h"
00020 #include "llvm/IR/LLVMContext.h"
00021 #include "llvm/IR/Metadata.h"
00022 #include "llvm/IR/Module.h"
00023 #include "llvm/MC/MCExpr.h"
00024 #include "llvm/MC/MCInst.h"
00025 #include "llvm/MC/MCInstrInfo.h"
00026 #include "llvm/MC/MCParser/MCAsmParser.h"
00027 #include "llvm/MC/MCSection.h"
00028 #include "llvm/MC/MCSubtargetInfo.h"
00029 #include "llvm/MC/MCSymbol.h"
00030 #include "llvm/MC/MCTargetAsmParser.h"
00031 #include "llvm/MC/SubtargetFeature.h"
00032 #include "llvm/Support/CommandLine.h"
00033 #include "llvm/Support/FileSystem.h"
00034 #include "llvm/Support/Host.h"
00035 #include "llvm/Support/MemoryBuffer.h"
00036 #include "llvm/Support/Path.h"
00037 #include "llvm/Support/SourceMgr.h"
00038 #include "llvm/Support/TargetRegistry.h"
00039 #include "llvm/Support/TargetSelect.h"
00040 #include "llvm/Target/TargetLowering.h"
00041 #include "llvm/Target/TargetLoweringObjectFile.h"
00042 #include "llvm/Target/TargetRegisterInfo.h"
00043 #include "llvm/Target/TargetSubtargetInfo.h"
00044 #include "llvm/Transforms/Utils/GlobalStatus.h"
00045 #include <system_error>
00046 using namespace llvm;
00047 
00048 LTOModule::LTOModule(std::unique_ptr<object::IRObjectFile> Obj,
00049                      llvm::TargetMachine *TM)
00050     : IRFile(std::move(Obj)), _target(TM) {}
00051 
00052 /// isBitcodeFile - Returns 'true' if the file (or memory contents) is LLVM
00053 /// bitcode.
00054 bool LTOModule::isBitcodeFile(const void *mem, size_t length) {
00055   return sys::fs::identify_magic(StringRef((const char *)mem, length)) ==
00056          sys::fs::file_magic::bitcode;
00057 }
00058 
00059 bool LTOModule::isBitcodeFile(const char *path) {
00060   sys::fs::file_magic type;
00061   if (sys::fs::identify_magic(path, type))
00062     return false;
00063   return type == sys::fs::file_magic::bitcode;
00064 }
00065 
00066 bool LTOModule::isBitcodeForTarget(MemoryBuffer *buffer,
00067                                    StringRef triplePrefix) {
00068   std::string Triple =
00069       getBitcodeTargetTriple(buffer->getMemBufferRef(), getGlobalContext());
00070   return StringRef(Triple).startswith(triplePrefix);
00071 }
00072 
00073 LTOModule *LTOModule::createFromFile(const char *path, TargetOptions options,
00074                                      std::string &errMsg) {
00075   ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
00076       MemoryBuffer::getFile(path);
00077   if (std::error_code EC = BufferOrErr.getError()) {
00078     errMsg = EC.message();
00079     return nullptr;
00080   }
00081   std::unique_ptr<MemoryBuffer> Buffer = std::move(BufferOrErr.get());
00082   return makeLTOModule(Buffer->getMemBufferRef(), options, errMsg);
00083 }
00084 
00085 LTOModule *LTOModule::createFromOpenFile(int fd, const char *path, size_t size,
00086                                          TargetOptions options,
00087                                          std::string &errMsg) {
00088   return createFromOpenFileSlice(fd, path, size, 0, options, errMsg);
00089 }
00090 
00091 LTOModule *LTOModule::createFromOpenFileSlice(int fd, const char *path,
00092                                               size_t map_size, off_t offset,
00093                                               TargetOptions options,
00094                                               std::string &errMsg) {
00095   ErrorOr<std::unique_ptr<MemoryBuffer>> BufferOrErr =
00096       MemoryBuffer::getOpenFileSlice(fd, path, map_size, offset);
00097   if (std::error_code EC = BufferOrErr.getError()) {
00098     errMsg = EC.message();
00099     return nullptr;
00100   }
00101   std::unique_ptr<MemoryBuffer> Buffer = std::move(BufferOrErr.get());
00102   return makeLTOModule(Buffer->getMemBufferRef(), options, errMsg);
00103 }
00104 
00105 LTOModule *LTOModule::createFromBuffer(const void *mem, size_t length,
00106                                        TargetOptions options,
00107                                        std::string &errMsg, StringRef path) {
00108   StringRef Data((const char *)mem, length);
00109   MemoryBufferRef Buffer(Data, path);
00110   return makeLTOModule(Buffer, options, errMsg);
00111 }
00112 
00113 LTOModule *LTOModule::makeLTOModule(MemoryBufferRef Buffer,
00114                                     TargetOptions options,
00115                                     std::string &errMsg) {
00116   ErrorOr<Module *> MOrErr = parseBitcodeFile(Buffer, getGlobalContext());
00117   if (std::error_code EC = MOrErr.getError()) {
00118     errMsg = EC.message();
00119     return nullptr;
00120   }
00121   std::unique_ptr<Module> M(MOrErr.get());
00122 
00123   std::string TripleStr = M->getTargetTriple();
00124   if (TripleStr.empty())
00125     TripleStr = sys::getDefaultTargetTriple();
00126   llvm::Triple Triple(TripleStr);
00127 
00128   // find machine architecture for this module
00129   const Target *march = TargetRegistry::lookupTarget(TripleStr, errMsg);
00130   if (!march)
00131     return nullptr;
00132 
00133   // construct LTOModule, hand over ownership of module and target
00134   SubtargetFeatures Features;
00135   Features.getDefaultSubtargetFeatures(Triple);
00136   std::string FeatureStr = Features.getString();
00137   // Set a default CPU for Darwin triples.
00138   std::string CPU;
00139   if (Triple.isOSDarwin()) {
00140     if (Triple.getArch() == llvm::Triple::x86_64)
00141       CPU = "core2";
00142     else if (Triple.getArch() == llvm::Triple::x86)
00143       CPU = "yonah";
00144     else if (Triple.getArch() == llvm::Triple::aarch64)
00145       CPU = "cyclone";
00146   }
00147 
00148   TargetMachine *target = march->createTargetMachine(TripleStr, CPU, FeatureStr,
00149                                                      options);
00150   M->setDataLayout(target->getSubtargetImpl()->getDataLayout());
00151 
00152   std::unique_ptr<object::IRObjectFile> IRObj(
00153       new object::IRObjectFile(Buffer, std::move(M)));
00154 
00155   LTOModule *Ret = new LTOModule(std::move(IRObj), target);
00156 
00157   if (Ret->parseSymbols(errMsg)) {
00158     delete Ret;
00159     return nullptr;
00160   }
00161 
00162   Ret->parseMetadata();
00163 
00164   return Ret;
00165 }
00166 
00167 /// Create a MemoryBuffer from a memory range with an optional name.
00168 std::unique_ptr<MemoryBuffer>
00169 LTOModule::makeBuffer(const void *mem, size_t length, StringRef name) {
00170   const char *startPtr = (const char*)mem;
00171   return MemoryBuffer::getMemBuffer(StringRef(startPtr, length), name, false);
00172 }
00173 
00174 /// objcClassNameFromExpression - Get string that the data pointer points to.
00175 bool
00176 LTOModule::objcClassNameFromExpression(const Constant *c, std::string &name) {
00177   if (const ConstantExpr *ce = dyn_cast<ConstantExpr>(c)) {
00178     Constant *op = ce->getOperand(0);
00179     if (GlobalVariable *gvn = dyn_cast<GlobalVariable>(op)) {
00180       Constant *cn = gvn->getInitializer();
00181       if (ConstantDataArray *ca = dyn_cast<ConstantDataArray>(cn)) {
00182         if (ca->isCString()) {
00183           name = ".objc_class_name_" + ca->getAsCString().str();
00184           return true;
00185         }
00186       }
00187     }
00188   }
00189   return false;
00190 }
00191 
00192 /// addObjCClass - Parse i386/ppc ObjC class data structure.
00193 void LTOModule::addObjCClass(const GlobalVariable *clgv) {
00194   const ConstantStruct *c = dyn_cast<ConstantStruct>(clgv->getInitializer());
00195   if (!c) return;
00196 
00197   // second slot in __OBJC,__class is pointer to superclass name
00198   std::string superclassName;
00199   if (objcClassNameFromExpression(c->getOperand(1), superclassName)) {
00200     NameAndAttributes info;
00201     StringMap<NameAndAttributes>::value_type &entry =
00202       _undefines.GetOrCreateValue(superclassName);
00203     if (!entry.getValue().name) {
00204       const char *symbolName = entry.getKey().data();
00205       info.name = symbolName;
00206       info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;
00207       info.isFunction = false;
00208       info.symbol = clgv;
00209       entry.setValue(info);
00210     }
00211   }
00212 
00213   // third slot in __OBJC,__class is pointer to class name
00214   std::string className;
00215   if (objcClassNameFromExpression(c->getOperand(2), className)) {
00216     StringSet::value_type &entry = _defines.GetOrCreateValue(className);
00217     entry.setValue(1);
00218 
00219     NameAndAttributes info;
00220     info.name = entry.getKey().data();
00221     info.attributes = LTO_SYMBOL_PERMISSIONS_DATA |
00222       LTO_SYMBOL_DEFINITION_REGULAR | LTO_SYMBOL_SCOPE_DEFAULT;
00223     info.isFunction = false;
00224     info.symbol = clgv;
00225     _symbols.push_back(info);
00226   }
00227 }
00228 
00229 /// addObjCCategory - Parse i386/ppc ObjC category data structure.
00230 void LTOModule::addObjCCategory(const GlobalVariable *clgv) {
00231   const ConstantStruct *c = dyn_cast<ConstantStruct>(clgv->getInitializer());
00232   if (!c) return;
00233 
00234   // second slot in __OBJC,__category is pointer to target class name
00235   std::string targetclassName;
00236   if (!objcClassNameFromExpression(c->getOperand(1), targetclassName))
00237     return;
00238 
00239   NameAndAttributes info;
00240   StringMap<NameAndAttributes>::value_type &entry =
00241     _undefines.GetOrCreateValue(targetclassName);
00242 
00243   if (entry.getValue().name)
00244     return;
00245 
00246   const char *symbolName = entry.getKey().data();
00247   info.name = symbolName;
00248   info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;
00249   info.isFunction = false;
00250   info.symbol = clgv;
00251   entry.setValue(info);
00252 }
00253 
00254 /// addObjCClassRef - Parse i386/ppc ObjC class list data structure.
00255 void LTOModule::addObjCClassRef(const GlobalVariable *clgv) {
00256   std::string targetclassName;
00257   if (!objcClassNameFromExpression(clgv->getInitializer(), targetclassName))
00258     return;
00259 
00260   NameAndAttributes info;
00261   StringMap<NameAndAttributes>::value_type &entry =
00262     _undefines.GetOrCreateValue(targetclassName);
00263   if (entry.getValue().name)
00264     return;
00265 
00266   const char *symbolName = entry.getKey().data();
00267   info.name = symbolName;
00268   info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;
00269   info.isFunction = false;
00270   info.symbol = clgv;
00271   entry.setValue(info);
00272 }
00273 
00274 void LTOModule::addDefinedDataSymbol(const object::BasicSymbolRef &Sym) {
00275   SmallString<64> Buffer;
00276   {
00277     raw_svector_ostream OS(Buffer);
00278     Sym.printName(OS);
00279   }
00280 
00281   const GlobalValue *V = IRFile->getSymbolGV(Sym.getRawDataRefImpl());
00282   addDefinedDataSymbol(Buffer.c_str(), V);
00283 }
00284 
00285 void LTOModule::addDefinedDataSymbol(const char *Name, const GlobalValue *v) {
00286   // Add to list of defined symbols.
00287   addDefinedSymbol(Name, v, false);
00288 
00289   if (!v->hasSection() /* || !isTargetDarwin */)
00290     return;
00291 
00292   // Special case i386/ppc ObjC data structures in magic sections:
00293   // The issue is that the old ObjC object format did some strange
00294   // contortions to avoid real linker symbols.  For instance, the
00295   // ObjC class data structure is allocated statically in the executable
00296   // that defines that class.  That data structures contains a pointer to
00297   // its superclass.  But instead of just initializing that part of the
00298   // struct to the address of its superclass, and letting the static and
00299   // dynamic linkers do the rest, the runtime works by having that field
00300   // instead point to a C-string that is the name of the superclass.
00301   // At runtime the objc initialization updates that pointer and sets
00302   // it to point to the actual super class.  As far as the linker
00303   // knows it is just a pointer to a string.  But then someone wanted the
00304   // linker to issue errors at build time if the superclass was not found.
00305   // So they figured out a way in mach-o object format to use an absolute
00306   // symbols (.objc_class_name_Foo = 0) and a floating reference
00307   // (.reference .objc_class_name_Bar) to cause the linker into erroring when
00308   // a class was missing.
00309   // The following synthesizes the implicit .objc_* symbols for the linker
00310   // from the ObjC data structures generated by the front end.
00311 
00312   // special case if this data blob is an ObjC class definition
00313   std::string Section = v->getSection();
00314   if (Section.compare(0, 15, "__OBJC,__class,") == 0) {
00315     if (const GlobalVariable *gv = dyn_cast<GlobalVariable>(v)) {
00316       addObjCClass(gv);
00317     }
00318   }
00319 
00320   // special case if this data blob is an ObjC category definition
00321   else if (Section.compare(0, 18, "__OBJC,__category,") == 0) {
00322     if (const GlobalVariable *gv = dyn_cast<GlobalVariable>(v)) {
00323       addObjCCategory(gv);
00324     }
00325   }
00326 
00327   // special case if this data blob is the list of referenced classes
00328   else if (Section.compare(0, 18, "__OBJC,__cls_refs,") == 0) {
00329     if (const GlobalVariable *gv = dyn_cast<GlobalVariable>(v)) {
00330       addObjCClassRef(gv);
00331     }
00332   }
00333 }
00334 
00335 void LTOModule::addDefinedFunctionSymbol(const object::BasicSymbolRef &Sym) {
00336   SmallString<64> Buffer;
00337   {
00338     raw_svector_ostream OS(Buffer);
00339     Sym.printName(OS);
00340   }
00341 
00342   const Function *F =
00343       cast<Function>(IRFile->getSymbolGV(Sym.getRawDataRefImpl()));
00344   addDefinedFunctionSymbol(Buffer.c_str(), F);
00345 }
00346 
00347 void LTOModule::addDefinedFunctionSymbol(const char *Name, const Function *F) {
00348   // add to list of defined symbols
00349   addDefinedSymbol(Name, F, true);
00350 }
00351 
00352 void LTOModule::addDefinedSymbol(const char *Name, const GlobalValue *def,
00353                                  bool isFunction) {
00354   // set alignment part log2() can have rounding errors
00355   uint32_t align = def->getAlignment();
00356   uint32_t attr = align ? countTrailingZeros(align) : 0;
00357 
00358   // set permissions part
00359   if (isFunction) {
00360     attr |= LTO_SYMBOL_PERMISSIONS_CODE;
00361   } else {
00362     const GlobalVariable *gv = dyn_cast<GlobalVariable>(def);
00363     if (gv && gv->isConstant())
00364       attr |= LTO_SYMBOL_PERMISSIONS_RODATA;
00365     else
00366       attr |= LTO_SYMBOL_PERMISSIONS_DATA;
00367   }
00368 
00369   // set definition part
00370   if (def->hasWeakLinkage() || def->hasLinkOnceLinkage())
00371     attr |= LTO_SYMBOL_DEFINITION_WEAK;
00372   else if (def->hasCommonLinkage())
00373     attr |= LTO_SYMBOL_DEFINITION_TENTATIVE;
00374   else
00375     attr |= LTO_SYMBOL_DEFINITION_REGULAR;
00376 
00377   // set scope part
00378   if (def->hasLocalLinkage())
00379     // Ignore visibility if linkage is local.
00380     attr |= LTO_SYMBOL_SCOPE_INTERNAL;
00381   else if (def->hasHiddenVisibility())
00382     attr |= LTO_SYMBOL_SCOPE_HIDDEN;
00383   else if (def->hasProtectedVisibility())
00384     attr |= LTO_SYMBOL_SCOPE_PROTECTED;
00385   else if (canBeOmittedFromSymbolTable(def))
00386     attr |= LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN;
00387   else
00388     attr |= LTO_SYMBOL_SCOPE_DEFAULT;
00389 
00390   StringSet::value_type &entry = _defines.GetOrCreateValue(Name);
00391   entry.setValue(1);
00392 
00393   // fill information structure
00394   NameAndAttributes info;
00395   StringRef NameRef = entry.getKey();
00396   info.name = NameRef.data();
00397   assert(info.name[NameRef.size()] == '\0');
00398   info.attributes = attr;
00399   info.isFunction = isFunction;
00400   info.symbol = def;
00401 
00402   // add to table of symbols
00403   _symbols.push_back(info);
00404 }
00405 
00406 /// addAsmGlobalSymbol - Add a global symbol from module-level ASM to the
00407 /// defined list.
00408 void LTOModule::addAsmGlobalSymbol(const char *name,
00409                                    lto_symbol_attributes scope) {
00410   StringSet::value_type &entry = _defines.GetOrCreateValue(name);
00411 
00412   // only add new define if not already defined
00413   if (entry.getValue())
00414     return;
00415 
00416   entry.setValue(1);
00417 
00418   NameAndAttributes &info = _undefines[entry.getKey().data()];
00419 
00420   if (info.symbol == nullptr) {
00421     // FIXME: This is trying to take care of module ASM like this:
00422     //
00423     //   module asm ".zerofill __FOO, __foo, _bar_baz_qux, 0"
00424     //
00425     // but is gross and its mother dresses it funny. Have the ASM parser give us
00426     // more details for this type of situation so that we're not guessing so
00427     // much.
00428 
00429     // fill information structure
00430     info.name = entry.getKey().data();
00431     info.attributes =
00432       LTO_SYMBOL_PERMISSIONS_DATA | LTO_SYMBOL_DEFINITION_REGULAR | scope;
00433     info.isFunction = false;
00434     info.symbol = nullptr;
00435 
00436     // add to table of symbols
00437     _symbols.push_back(info);
00438     return;
00439   }
00440 
00441   if (info.isFunction)
00442     addDefinedFunctionSymbol(info.name, cast<Function>(info.symbol));
00443   else
00444     addDefinedDataSymbol(info.name, info.symbol);
00445 
00446   _symbols.back().attributes &= ~LTO_SYMBOL_SCOPE_MASK;
00447   _symbols.back().attributes |= scope;
00448 }
00449 
00450 /// addAsmGlobalSymbolUndef - Add a global symbol from module-level ASM to the
00451 /// undefined list.
00452 void LTOModule::addAsmGlobalSymbolUndef(const char *name) {
00453   StringMap<NameAndAttributes>::value_type &entry =
00454     _undefines.GetOrCreateValue(name);
00455 
00456   _asm_undefines.push_back(entry.getKey().data());
00457 
00458   // we already have the symbol
00459   if (entry.getValue().name)
00460     return;
00461 
00462   uint32_t attr = LTO_SYMBOL_DEFINITION_UNDEFINED;
00463   attr |= LTO_SYMBOL_SCOPE_DEFAULT;
00464   NameAndAttributes info;
00465   info.name = entry.getKey().data();
00466   info.attributes = attr;
00467   info.isFunction = false;
00468   info.symbol = nullptr;
00469 
00470   entry.setValue(info);
00471 }
00472 
00473 /// Add a symbol which isn't defined just yet to a list to be resolved later.
00474 void LTOModule::addPotentialUndefinedSymbol(const object::BasicSymbolRef &Sym,
00475                                             bool isFunc) {
00476   SmallString<64> name;
00477   {
00478     raw_svector_ostream OS(name);
00479     Sym.printName(OS);
00480   }
00481 
00482   StringMap<NameAndAttributes>::value_type &entry =
00483     _undefines.GetOrCreateValue(name);
00484 
00485   // we already have the symbol
00486   if (entry.getValue().name)
00487     return;
00488 
00489   NameAndAttributes info;
00490 
00491   info.name = entry.getKey().data();
00492 
00493   const GlobalValue *decl = IRFile->getSymbolGV(Sym.getRawDataRefImpl());
00494 
00495   if (decl->hasExternalWeakLinkage())
00496     info.attributes = LTO_SYMBOL_DEFINITION_WEAKUNDEF;
00497   else
00498     info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED;
00499 
00500   info.isFunction = isFunc;
00501   info.symbol = decl;
00502 
00503   entry.setValue(info);
00504 }
00505 
00506 /// parseSymbols - Parse the symbols from the module and model-level ASM and add
00507 /// them to either the defined or undefined lists.
00508 bool LTOModule::parseSymbols(std::string &errMsg) {
00509   for (auto &Sym : IRFile->symbols()) {
00510     const GlobalValue *GV = IRFile->getSymbolGV(Sym.getRawDataRefImpl());
00511     uint32_t Flags = Sym.getFlags();
00512     if (Flags & object::BasicSymbolRef::SF_FormatSpecific)
00513       continue;
00514 
00515     bool IsUndefined = Flags & object::BasicSymbolRef::SF_Undefined;
00516 
00517     if (!GV) {
00518       SmallString<64> Buffer;
00519       {
00520         raw_svector_ostream OS(Buffer);
00521         Sym.printName(OS);
00522       }
00523       const char *Name = Buffer.c_str();
00524 
00525       if (IsUndefined)
00526         addAsmGlobalSymbolUndef(Name);
00527       else if (Flags & object::BasicSymbolRef::SF_Global)
00528         addAsmGlobalSymbol(Name, LTO_SYMBOL_SCOPE_DEFAULT);
00529       else
00530         addAsmGlobalSymbol(Name, LTO_SYMBOL_SCOPE_INTERNAL);
00531       continue;
00532     }
00533 
00534     auto *F = dyn_cast<Function>(GV);
00535     if (IsUndefined) {
00536       addPotentialUndefinedSymbol(Sym, F != nullptr);
00537       continue;
00538     }
00539 
00540     if (F) {
00541       addDefinedFunctionSymbol(Sym);
00542       continue;
00543     }
00544 
00545     if (isa<GlobalVariable>(GV)) {
00546       addDefinedDataSymbol(Sym);
00547       continue;
00548     }
00549 
00550     assert(isa<GlobalAlias>(GV));
00551     addDefinedDataSymbol(Sym);
00552   }
00553 
00554   // make symbols for all undefines
00555   for (StringMap<NameAndAttributes>::iterator u =_undefines.begin(),
00556          e = _undefines.end(); u != e; ++u) {
00557     // If this symbol also has a definition, then don't make an undefine because
00558     // it is a tentative definition.
00559     if (_defines.count(u->getKey())) continue;
00560     NameAndAttributes info = u->getValue();
00561     _symbols.push_back(info);
00562   }
00563 
00564   return false;
00565 }
00566 
00567 /// parseMetadata - Parse metadata from the module
00568 void LTOModule::parseMetadata() {
00569   // Linker Options
00570   if (Value *Val = getModule().getModuleFlag("Linker Options")) {
00571     MDNode *LinkerOptions = cast<MDNode>(Val);
00572     for (unsigned i = 0, e = LinkerOptions->getNumOperands(); i != e; ++i) {
00573       MDNode *MDOptions = cast<MDNode>(LinkerOptions->getOperand(i));
00574       for (unsigned ii = 0, ie = MDOptions->getNumOperands(); ii != ie; ++ii) {
00575         MDString *MDOption = cast<MDString>(MDOptions->getOperand(ii));
00576         StringRef Op = _linkeropt_strings.
00577             GetOrCreateValue(MDOption->getString()).getKey();
00578         StringRef DepLibName = _target->getSubtargetImpl()
00579                                    ->getTargetLowering()
00580                                    ->getObjFileLowering()
00581                                    .getDepLibFromLinkerOpt(Op);
00582         if (!DepLibName.empty())
00583           _deplibs.push_back(DepLibName.data());
00584         else if (!Op.empty())
00585           _linkeropts.push_back(Op.data());
00586       }
00587     }
00588   }
00589 
00590   // Add other interesting metadata here.
00591 }