diff options
author | Ivan Krasin <krasin@chromium.org> | 2011-09-08 07:36:39 +0000 |
---|---|---|
committer | Ivan Krasin <krasin@chromium.org> | 2011-09-08 07:36:39 +0000 |
commit | 603e103988d98c0ea5d37e7cceaf5bbffe076f28 (patch) | |
tree | a5e038213a077534b2d83ca80288f909a2070d3b /tools/lto | |
parent | 78091804c8b15ca9f517a7e7f608bc36aa8e00a5 (diff) | |
download | external_llvm-603e103988d98c0ea5d37e7cceaf5bbffe076f28.zip external_llvm-603e103988d98c0ea5d37e7cceaf5bbffe076f28.tar.gz external_llvm-603e103988d98c0ea5d37e7cceaf5bbffe076f28.tar.bz2 |
lto/addAsmGlobalSymbols: fail fracefully when the target does not define AsmParser.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139283 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lto')
-rw-r--r-- | tools/lto/LTOModule.cpp | 14 | ||||
-rw-r--r-- | tools/lto/LTOModule.h | 5 |
2 files changed, 13 insertions, 6 deletions
diff --git a/tools/lto/LTOModule.cpp b/tools/lto/LTOModule.cpp index f6dc7d9..6b4e2d2 100644 --- a/tools/lto/LTOModule.cpp +++ b/tools/lto/LTOModule.cpp @@ -165,7 +165,7 @@ LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer, std::string CPU; TargetMachine *target = march->createTargetMachine(Triple, CPU, FeatureStr); LTOModule *Ret = new LTOModule(m.take(), target); - bool Err = Ret->ParseSymbols(); + bool Err = Ret->ParseSymbols(errMsg); if (Err) { delete Ret; return NULL; @@ -613,7 +613,7 @@ namespace { }; } -bool LTOModule::addAsmGlobalSymbols(MCContext &Context) { +bool LTOModule::addAsmGlobalSymbols(MCContext &Context, std::string &errMsg) { const std::string &inlineAsm = _module->getModuleInlineAsm(); OwningPtr<RecordStreamer> Streamer(new RecordStreamer(Context)); @@ -629,6 +629,12 @@ bool LTOModule::addAsmGlobalSymbols(MCContext &Context) { _target->getTargetFeatureString())); OwningPtr<MCTargetAsmParser> TAP(_target->getTarget().createMCAsmParser(*STI, *Parser.get())); + if (!TAP) { + errMsg = "target " + std::string(_target->getTarget().getName()) + + " does not define AsmParser."; + return true; + } + Parser->setTargetParser(*TAP); int Res = Parser->Run(false); if (Res) @@ -661,7 +667,7 @@ static bool isAliasToDeclaration(const GlobalAlias &V) { return isDeclaration(*V.getAliasedGlobal()); } -bool LTOModule::ParseSymbols() { +bool LTOModule::ParseSymbols(std::string &errMsg) { // Use mangler to add GlobalPrefix to names to match linker names. MCContext Context(*_target->getMCAsmInfo(), *_target->getRegisterInfo(),NULL); Mangler mangler(Context, *_target->getTargetData()); @@ -684,7 +690,7 @@ bool LTOModule::ParseSymbols() { } // add asm globals - if (addAsmGlobalSymbols(Context)) + if (addAsmGlobalSymbols(Context, errMsg)) return true; // add aliases diff --git a/tools/lto/LTOModule.h b/tools/lto/LTOModule.h index 0b64a90..ca08aea 100644 --- a/tools/lto/LTOModule.h +++ b/tools/lto/LTOModule.h @@ -76,7 +76,7 @@ struct LTOModule { private: LTOModule(llvm::Module* m, llvm::TargetMachine* t); - bool ParseSymbols(); + bool ParseSymbols(std::string &errMsg); void addDefinedSymbol(llvm::GlobalValue* def, llvm::Mangler& mangler, bool isFunction); @@ -86,7 +86,8 @@ private: llvm::Mangler &mangler); void addDefinedDataSymbol(llvm::GlobalValue* v, llvm::Mangler &mangler); - bool addAsmGlobalSymbols(llvm::MCContext &Context); + bool addAsmGlobalSymbols(llvm::MCContext &Context, + std::string &errMsg); void addAsmGlobalSymbol(const char *, lto_symbol_attributes scope); void addAsmGlobalSymbolUndef(const char *); |