[llvm-commits] [llvm] r139283 - in /llvm/trunk/tools/lto: LTOModule.cpp LTOModule.h
Ivan Krasin
krasin at chromium.org
Thu Sep 8 00:36:39 PDT 2011
Author: krasin
Date: Thu Sep 8 02:36:39 2011
New Revision: 139283
URL: http://llvm.org/viewvc/llvm-project?rev=139283&view=rev
Log:
lto/addAsmGlobalSymbols: fail fracefully when the target does not define AsmParser.
Modified:
llvm/trunk/tools/lto/LTOModule.cpp
llvm/trunk/tools/lto/LTOModule.h
Modified: llvm/trunk/tools/lto/LTOModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=139283&r1=139282&r2=139283&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOModule.cpp (original)
+++ llvm/trunk/tools/lto/LTOModule.cpp Thu Sep 8 02:36:39 2011
@@ -165,7 +165,7 @@
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 @@
};
}
-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 @@
_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 @@
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 @@
}
// add asm globals
- if (addAsmGlobalSymbols(Context))
+ if (addAsmGlobalSymbols(Context, errMsg))
return true;
// add aliases
Modified: llvm/trunk/tools/lto/LTOModule.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.h?rev=139283&r1=139282&r2=139283&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOModule.h (original)
+++ llvm/trunk/tools/lto/LTOModule.h Thu Sep 8 02:36:39 2011
@@ -76,7 +76,7 @@
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 @@
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 *);
More information about the llvm-commits
mailing list