diff options
author | Yunzhong Gao <Yunzhong_Gao@playstation.sony.com> | 2014-01-21 18:31:27 +0000 |
---|---|---|
committer | Yunzhong Gao <Yunzhong_Gao@playstation.sony.com> | 2014-01-21 18:31:27 +0000 |
commit | a88d7abeb1edc9029f27d35e89ea4eb3dc6f49f0 (patch) | |
tree | d244300c8cbf50034a5957fb0bde758a9f253430 /llvm/lib/LTO | |
parent | cb6e1257ffb92a8ebad80bb62e3b331a9460f8e8 (diff) | |
download | bcm5719-llvm-a88d7abeb1edc9029f27d35e89ea4eb3dc6f49f0.tar.gz bcm5719-llvm-a88d7abeb1edc9029f27d35e89ea4eb3dc6f49f0.zip |
Adding new LTO APIs to parse metadata nodes and extract linker options and
dependent libraries from a bitcode module.
Differential Revision: http://llvm-reviews.chandlerc.com/D2343
llvm-svn: 199759
Diffstat (limited to 'llvm/lib/LTO')
-rw-r--r-- | llvm/lib/LTO/LTOModule.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/llvm/lib/LTO/LTOModule.cpp b/llvm/lib/LTO/LTOModule.cpp index 79cff1f68fe..f73a608e3c4 100644 --- a/llvm/lib/LTO/LTOModule.cpp +++ b/llvm/lib/LTO/LTOModule.cpp @@ -18,6 +18,7 @@ #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/IR/Constants.h" #include "llvm/IR/LLVMContext.h" +#include "llvm/IR/Metadata.h" #include "llvm/IR/Module.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" @@ -37,6 +38,8 @@ #include "llvm/Support/TargetRegistry.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/system_error.h" +#include "llvm/Target/TargetLowering.h" +#include "llvm/Target/TargetLoweringObjectFile.h" #include "llvm/Target/TargetRegisterInfo.h" #include "llvm/Transforms/Utils/GlobalStatus.h" using namespace llvm; @@ -177,6 +180,8 @@ LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer, return NULL; } + Ret->parseMetadata(); + return Ret; } @@ -798,3 +803,27 @@ bool LTOModule::parseSymbols(std::string &errMsg) { return false; } + +/// parseMetadata - Parse metadata from the module +void LTOModule::parseMetadata() { + // Linker Options + if (Value *Val = _module->getModuleFlag("Linker Options")) { + MDNode *LinkerOptions = cast<MDNode>(Val); + for (unsigned i = 0, e = LinkerOptions->getNumOperands(); i != e; ++i) { + MDNode *MDOptions = cast<MDNode>(LinkerOptions->getOperand(i)); + for (unsigned ii = 0, ie = MDOptions->getNumOperands(); ii != ie; ++ii) { + MDString *MDOption = cast<MDString>(MDOptions->getOperand(ii)); + StringRef Op = _linkeropt_strings. + GetOrCreateValue(MDOption->getString()).getKey(); + StringRef DepLibName = _target->getTargetLowering()-> + getObjFileLowering().getDepLibFromLinkerOpt(Op); + if (!DepLibName.empty()) + _deplibs.push_back(DepLibName.data()); + else if (!Op.empty()) + _linkeropts.push_back(Op.data()); + } + } + } + + // Add other interesting metadata here. +} |