[llvm] r202463 - Now that it is possible, use the mangler in IRObjectFile.

Rafael Espindola rafael.espindola at gmail.com
Thu Feb 27 18:17:23 PST 2014


Author: rafael
Date: Thu Feb 27 20:17:23 2014
New Revision: 202463

URL: http://llvm.org/viewvc/llvm-project?rev=202463&view=rev
Log:
Now that it is possible, use the mangler in IRObjectFile.

A really simple patch marks the end of a lot of yak shaving :-)

Added:
    llvm/trunk/test/Object/mangle-ir.ll
Modified:
    llvm/trunk/docs/ReleaseNotes.rst
    llvm/trunk/include/llvm/Object/IRObjectFile.h
    llvm/trunk/lib/Object/IRObjectFile.cpp

Modified: llvm/trunk/docs/ReleaseNotes.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ReleaseNotes.rst?rev=202463&r1=202462&r2=202463&view=diff
==============================================================================
--- llvm/trunk/docs/ReleaseNotes.rst (original)
+++ llvm/trunk/docs/ReleaseNotes.rst Thu Feb 27 20:17:23 2014
@@ -52,6 +52,9 @@ Non-comprehensive list of changes in thi
   for assembly output as well. The integrated assembler can be disabled with
   the ``-no-integrated-as`` option,
 
+* llvm-ar now handles IR files like regular object files. In particular, a
+  regular symbol table is created for symbols defined in IR files.
+
 .. NOTE
    For small 1-3 sentence descriptions, just add an entry at the end of
    this list. If your description won't fit comfortably in one bullet

Modified: llvm/trunk/include/llvm/Object/IRObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/IRObjectFile.h?rev=202463&r1=202462&r2=202463&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/IRObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/IRObjectFile.h Thu Feb 27 20:17:23 2014
@@ -17,12 +17,14 @@
 #include "llvm/Object/SymbolicFile.h"
 
 namespace llvm {
+class Mangler;
 class Module;
 class GlobalValue;
 
 namespace object {
 class IRObjectFile : public SymbolicFile {
   OwningPtr<Module> M;
+  OwningPtr<Mangler> Mang;
 public:
   IRObjectFile(MemoryBuffer *Object, error_code &EC, LLVMContext &Context,
                bool BufferOwned);

Modified: llvm/trunk/lib/Object/IRObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/IRObjectFile.cpp?rev=202463&r1=202462&r2=202463&view=diff
==============================================================================
--- llvm/trunk/lib/Object/IRObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/IRObjectFile.cpp Thu Feb 27 20:17:23 2014
@@ -13,6 +13,7 @@
 
 #include "llvm/Bitcode/ReaderWriter.h"
 #include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Mangler.h"
 #include "llvm/IR/Module.h"
 #include "llvm/Object/IRObjectFile.h"
 #include "llvm/Support/raw_ostream.h"
@@ -27,6 +28,13 @@ IRObjectFile::IRObjectFile(MemoryBuffer
     return;
 
   M.reset(MOrErr.get());
+
+  // If we have a DataLayout, setup a mangler.
+  const DataLayout *DL = M->getDataLayout();
+  if (!DL)
+    return;
+
+  Mang.reset(new Mangler(DL));
 }
 
 static const GlobalValue &getGV(DataRefImpl &Symb) {
@@ -86,9 +94,13 @@ void IRObjectFile::moveSymbolNext(DataRe
 
 error_code IRObjectFile::printSymbolName(raw_ostream &OS,
                                          DataRefImpl Symb) const {
-  // FIXME: This should use the Mangler.
   const GlobalValue &GV = getGV(Symb);
-  OS << GV.getName();
+
+  if (Mang)
+    Mang->getNameWithPrefix(OS, &GV, false);
+  else
+    OS << GV.getName();
+
   return object_error::success;
 }
 

Added: llvm/trunk/test/Object/mangle-ir.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/mangle-ir.ll?rev=202463&view=auto
==============================================================================
--- llvm/trunk/test/Object/mangle-ir.ll (added)
+++ llvm/trunk/test/Object/mangle-ir.ll Thu Feb 27 20:17:23 2014
@@ -0,0 +1,8 @@
+; RUN: llvm-as %s -o - | llvm-nm - | FileCheck %s
+
+target datalayout = "m:o"
+
+; CHECK: T _f
+define void @f() {
+  ret void
+}





More information about the llvm-commits mailing list