<div dir="ltr">This seems to break VS2015:Â <a href="http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/3874">http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/3874</a><div><br></div><div>-- Sean Silva</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 21, 2016 at 9:28 PM, Mehdi Amini via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: mehdi_amini<br>
Date: Thu Apr 21 23:28:05 2016<br>
New Revision: 267103<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=267103&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=267103&view=rev</a><br>
Log:<br>
Refactor IRObjectFile, extract a static CollectAsmUndefinedRefs() method to parse inline assembly (NFC)<br>
<br>
I plan to call this from ThinLTOCodeGenerator.<br>
<br>
From: Mehdi Amini <<a href="mailto:mehdi.amini@apple.com">mehdi.amini@apple.com</a>><br>
<br>
Modified:<br>
  llvm/trunk/include/llvm/Object/IRObjectFile.h<br>
  llvm/trunk/lib/Object/IRObjectFile.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/Object/IRObjectFile.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/IRObjectFile.h?rev=267103&r1=267102&r2=267103&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/IRObjectFile.h?rev=267103&r1=267102&r2=267103&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Object/IRObjectFile.h (original)<br>
+++ llvm/trunk/include/llvm/Object/IRObjectFile.h Thu Apr 21 23:28:05 2016<br>
@@ -59,6 +59,16 @@ public:<br>
  /// error code if not found.<br>
  static ErrorOr<MemoryBufferRef> findBitcodeInObject(const ObjectFile &Obj);<br>
<br>
+Â /// Parse inline ASM and collect the symbols that are not defined in<br>
+Â /// the current module.<br>
+Â ///<br>
+Â /// For each found symbol, call \p AsmUndefinedRefs with the name of the<br>
+Â /// symbol found and the associated flags.<br>
+Â static void CollectAsmUndefinedRefs(<br>
+Â Â Â Module &TheModule,<br>
+Â Â Â const std::function<void(StringRef, BasicSymbolRef::Flags)> &<br>
+Â Â Â Â Â AsmUndefinedRefs);<br>
+<br>
  /// \brief Finds and returns bitcode in the given memory buffer (which may<br>
  /// be either a bitcode file or a native object file with embedded bitcode),<br>
  /// or an error code if not found.<br>
<br>
Modified: llvm/trunk/lib/Object/IRObjectFile.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/IRObjectFile.cpp?rev=267103&r1=267102&r2=267103&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/IRObjectFile.cpp?rev=267103&r1=267102&r2=267103&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Object/IRObjectFile.cpp (original)<br>
+++ llvm/trunk/lib/Object/IRObjectFile.cpp Thu Apr 21 23:28:05 2016<br>
@@ -38,12 +38,24 @@ using namespace object;<br>
 IRObjectFile::IRObjectFile(MemoryBufferRef Object, std::unique_ptr<Module> Mod)<br>
   : SymbolicFile(Binary::ID_IR, Object), M(std::move(Mod)) {<br>
  Mang.reset(new Mangler());<br>
+Â CollectAsmUndefinedRefs(*M, [this](StringRef Name,<br>
+Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â BasicSymbolRef::Flags Flags) {<br>
+Â Â AsmSymbols.push_back(std::make_pair<std::string, uint32_t>(Name, Flags));<br>
+Â });<br>
+}<br>
+<br>
+// Parse inline ASM and collect the list of symbols that are not defined in<br>
+// the current module. This is inspired from IRObjectFile.<br>
+void IRObjectFile::CollectAsmUndefinedRefs(<br>
+Â Â Module &TheModule,<br>
+Â Â const std::function<void(StringRef, BasicSymbolRef::Flags)> &<br>
+Â Â Â Â AsmUndefinedRefs) {<br>
<br>
-Â const std::string &InlineAsm = M->getModuleInlineAsm();<br>
+Â const std::string &InlineAsm = TheModule.getModuleInlineAsm();<br>
  if (InlineAsm.empty())<br>
   return;<br>
<br>
-Â Triple TT(M->getTargetTriple());<br>
+Â Triple TT(TheModule.getTargetTriple());<br>
  std::string Err;<br>
  const Target *T = TargetRegistry::lookupTarget(TT.str(), Err);<br>
  if (!T)<br>
@@ -106,8 +118,7 @@ IRObjectFile::IRObjectFile(MemoryBufferR<br>
    Res |= BasicSymbolRef::SF_Global;<br>
    break;<br>
   }<br>
-Â Â AsmSymbols.push_back(<br>
-Â Â Â Â std::make_pair<std::string, uint32_t>(Key, std::move(Res)));<br>
+Â Â AsmUndefinedRefs(Key, BasicSymbolRef::Flags(Res));<br>
  }<br>
 }<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>