[llvm-commits] [llvm] r168545 - in /llvm/trunk: include/llvm-c/lto.h lib/MC/MCDisassembler/Disassembler.cpp tools/lto/CMakeLists.txt tools/lto/LTODisassembler.cpp tools/lto/lto.exports
Benjamin Kramer
benny.kra at googlemail.com
Sat Nov 24 08:59:11 PST 2012
Author: d0k
Date: Sat Nov 24 10:59:10 2012
New Revision: 168545
URL: http://llvm.org/viewvc/llvm-project?rev=168545&view=rev
Log:
libLTO: Add a utility method to initialize the disassemblers.
Necessary to give disassembler users (like darwin's otool) a possibility to
dlopen libLTO and still initialize the required LLVM bits. This used to go
through libMCDisassembler but that's a gross layering violation, the MC layer
can't pull in functions from the targets. Adding a function to libLTO is a bit
of a hack but not worse than exposing other disassembler bits from libLTO.
Fixes PR14362.
Added:
llvm/trunk/tools/lto/LTODisassembler.cpp
Modified:
llvm/trunk/include/llvm-c/lto.h
llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp
llvm/trunk/tools/lto/CMakeLists.txt
llvm/trunk/tools/lto/lto.exports
Modified: llvm/trunk/include/llvm-c/lto.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/lto.h?rev=168545&r1=168544&r2=168545&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/lto.h (original)
+++ llvm/trunk/include/llvm-c/lto.h Sat Nov 24 10:59:10 2012
@@ -291,6 +291,13 @@
extern void
lto_codegen_debug_options(lto_code_gen_t cg, const char *);
+/**
+ * Initializes LLVM disassemblers.
+ * FIXME: This doesn't really belong here.
+ */
+extern void
+lto_initialize_disassembler(void);
+
#ifdef __cplusplus
}
#endif
Modified: llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp?rev=168545&r1=168544&r2=168545&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp (original)
+++ llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp Sat Nov 24 10:59:10 2012
@@ -20,7 +20,6 @@
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/Support/MemoryObject.h"
#include "llvm/Support/TargetRegistry.h"
-#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/ErrorHandling.h"
namespace llvm {
@@ -38,18 +37,6 @@
LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
int TagType, LLVMOpInfoCallback GetOpInfo,
LLVMSymbolLookupCallback SymbolLookUp) {
- // Initialize targets and assembly printers/parsers.
- // FIXME: Clients are responsible for initializing the targets. And this
- // would be done by calling routines in "llvm-c/Target.h" which are static
- // line functions. But the current use of LLVMCreateDisasm() is to dynamically
- // load libLTO with dlopen() and then lookup the symbols using dlsym().
- // And since these initialize routines are static that does not work which
- // is why the call to them in this 'C' library API was added back.
- llvm::InitializeAllTargetInfos();
- llvm::InitializeAllTargetMCs();
- llvm::InitializeAllAsmParsers();
- llvm::InitializeAllDisassemblers();
-
// Get the target.
std::string Error;
const Target *TheTarget = TargetRegistry::lookupTarget(TripleName, Error);
Modified: llvm/trunk/tools/lto/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/CMakeLists.txt?rev=168545&r1=168544&r2=168545&view=diff
==============================================================================
--- llvm/trunk/tools/lto/CMakeLists.txt (original)
+++ llvm/trunk/tools/lto/CMakeLists.txt Sat Nov 24 10:59:10 2012
@@ -6,6 +6,7 @@
set(SOURCES
LTOCodeGenerator.cpp
+ LTODisassembler.cpp
lto.cpp
LTOModule.cpp
)
Added: llvm/trunk/tools/lto/LTODisassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTODisassembler.cpp?rev=168545&view=auto
==============================================================================
--- llvm/trunk/tools/lto/LTODisassembler.cpp (added)
+++ llvm/trunk/tools/lto/LTODisassembler.cpp Sat Nov 24 10:59:10 2012
@@ -0,0 +1,26 @@
+//===-- LTODisassembler.cpp - LTO Disassembler interface ------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This function provides utility methods used by clients of libLTO that want
+// to use the disassembler.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm-c/lto.h"
+#include "llvm/Support/TargetSelect.h"
+
+using namespace llvm;
+
+void lto_initialize_disassembler() {
+ // Initialize targets and assembly printers/parsers.
+ llvm::InitializeAllTargetInfos();
+ llvm::InitializeAllTargetMCs();
+ llvm::InitializeAllAsmParsers();
+ llvm::InitializeAllDisassemblers();
+}
Modified: llvm/trunk/tools/lto/lto.exports
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.exports?rev=168545&r1=168544&r2=168545&view=diff
==============================================================================
--- llvm/trunk/tools/lto/lto.exports (original)
+++ llvm/trunk/tools/lto/lto.exports Sat Nov 24 10:59:10 2012
@@ -1,5 +1,6 @@
lto_get_error_message
lto_get_version
+lto_initialize_disassembler
lto_module_create
lto_module_create_from_fd
lto_module_create_from_fd_at_offset
More information about the llvm-commits
mailing list