mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-15 07:34:33 +00:00
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
This commit is contained in:
parent
78091804c8
commit
603e103988
@ -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
|
||||
|
@ -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 *);
|
||||
|
Loading…
x
Reference in New Issue
Block a user