diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-22 04:28:05 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-22 04:28:05 +0000 |
commit | e9cffafdf71771af6c5af38f4901e69753c923f8 (patch) | |
tree | 147817c04b9163eb3d4705c36521f89f71d069d0 /llvm/lib/Object/IRObjectFile.cpp | |
parent | b0c97487094ce0fd14ec4516a382b449a5631bbf (diff) | |
download | bcm5719-llvm-e9cffafdf71771af6c5af38f4901e69753c923f8.tar.gz bcm5719-llvm-e9cffafdf71771af6c5af38f4901e69753c923f8.zip |
Refactor IRObjectFile, extract a static CollectAsmUndefinedRefs() method to parse inline assembly (NFC)
I plan to call this from ThinLTOCodeGenerator.
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 267103
Diffstat (limited to 'llvm/lib/Object/IRObjectFile.cpp')
-rw-r--r-- | llvm/lib/Object/IRObjectFile.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/llvm/lib/Object/IRObjectFile.cpp b/llvm/lib/Object/IRObjectFile.cpp index a4b97efc645..8184e04a3ae 100644 --- a/llvm/lib/Object/IRObjectFile.cpp +++ b/llvm/lib/Object/IRObjectFile.cpp @@ -38,12 +38,24 @@ using namespace object; IRObjectFile::IRObjectFile(MemoryBufferRef Object, std::unique_ptr<Module> Mod) : SymbolicFile(Binary::ID_IR, Object), M(std::move(Mod)) { Mang.reset(new Mangler()); + CollectAsmUndefinedRefs(*M, [this](StringRef Name, + BasicSymbolRef::Flags Flags) { + AsmSymbols.push_back(std::make_pair<std::string, uint32_t>(Name, Flags)); + }); +} + +// Parse inline ASM and collect the list of symbols that are not defined in +// the current module. This is inspired from IRObjectFile. +void IRObjectFile::CollectAsmUndefinedRefs( + Module &TheModule, + const std::function<void(StringRef, BasicSymbolRef::Flags)> & + AsmUndefinedRefs) { - const std::string &InlineAsm = M->getModuleInlineAsm(); + const std::string &InlineAsm = TheModule.getModuleInlineAsm(); if (InlineAsm.empty()) return; - Triple TT(M->getTargetTriple()); + Triple TT(TheModule.getTargetTriple()); std::string Err; const Target *T = TargetRegistry::lookupTarget(TT.str(), Err); if (!T) @@ -106,8 +118,7 @@ IRObjectFile::IRObjectFile(MemoryBufferRef Object, std::unique_ptr<Module> Mod) Res |= BasicSymbolRef::SF_Global; break; } - AsmSymbols.push_back( - std::make_pair<std::string, uint32_t>(Key, std::move(Res))); + AsmUndefinedRefs(Key, BasicSymbolRef::Flags(Res)); } } |