[llvm] r185197 - Add flag to lli to enable debugging of IR when used with MCJIT.

Daniel Malea daniel.malea at intel.com
Fri Jun 28 12:11:41 PDT 2013


Author: dmalea
Date: Fri Jun 28 14:11:40 2013
New Revision: 185197

URL: http://llvm.org/viewvc/llvm-project?rev=185197&view=rev
Log:
Add flag to lli to enable debugging of IR when used with MCJIT.
- warn users when -debug-ir is used with old JIT engine (only partial debug
  info is available) 

For example, to debug an IR file with GDB (that supports JIT registration), do:

$ gdb --args lli -use-mcjit -debug-ir testcase.ll
(gdb) break main
(gdb) run
<Process continues to lli main>
(gdb) continue
<Process continues to testcase.ll main()
(gdb) step
<Now stepping through the LLVM IR in testcase.ll>


Modified:
    llvm/trunk/tools/lli/CMakeLists.txt
    llvm/trunk/tools/lli/LLVMBuild.txt
    llvm/trunk/tools/lli/Makefile
    llvm/trunk/tools/lli/lli.cpp

Modified: llvm/trunk/tools/lli/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/CMakeLists.txt?rev=185197&r1=185196&r2=185197&view=diff
==============================================================================
--- llvm/trunk/tools/lli/CMakeLists.txt (original)
+++ llvm/trunk/tools/lli/CMakeLists.txt Fri Jun 28 14:11:40 2013
@@ -1,5 +1,5 @@
 
-set(LLVM_LINK_COMPONENTS mcjit jit interpreter nativecodegen bitreader asmparser irreader selectiondag native)
+set(LLVM_LINK_COMPONENTS mcjit jit interpreter nativecodegen bitreader asmparser irreader selectiondag native instrumentation)
 
 if( LLVM_USE_OPROFILE )
   set(LLVM_LINK_COMPONENTS

Modified: llvm/trunk/tools/lli/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/LLVMBuild.txt?rev=185197&r1=185196&r2=185197&view=diff
==============================================================================
--- llvm/trunk/tools/lli/LLVMBuild.txt (original)
+++ llvm/trunk/tools/lli/LLVMBuild.txt Fri Jun 28 14:11:40 2013
@@ -19,4 +19,4 @@
 type = Tool
 name = lli
 parent = Tools
-required_libraries = AsmParser BitReader IRReader Interpreter JIT MCJIT NativeCodeGen SelectionDAG Native
+required_libraries = AsmParser BitReader IRReader Instrumentation Interpreter JIT MCJIT NativeCodeGen SelectionDAG Native

Modified: llvm/trunk/tools/lli/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/Makefile?rev=185197&r1=185196&r2=185197&view=diff
==============================================================================
--- llvm/trunk/tools/lli/Makefile (original)
+++ llvm/trunk/tools/lli/Makefile Fri Jun 28 14:11:40 2013
@@ -12,7 +12,7 @@ TOOLNAME := lli
 
 include $(LEVEL)/Makefile.config
 
-LINK_COMPONENTS := mcjit jit interpreter nativecodegen bitreader asmparser irreader selectiondag native
+LINK_COMPONENTS := mcjit jit instrumentation interpreter nativecodegen bitreader asmparser irreader selectiondag native
 
 # If Intel JIT Events support is confiured, link against the LLVM Intel JIT
 # Events interface library

Modified: llvm/trunk/tools/lli/lli.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/lli.cpp?rev=185197&r1=185196&r2=185197&view=diff
==============================================================================
--- llvm/trunk/tools/lli/lli.cpp (original)
+++ llvm/trunk/tools/lli/lli.cpp Fri Jun 28 14:11:40 2013
@@ -45,6 +45,7 @@
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/Transforms/Instrumentation.h"
 #include <cerrno>
 
 #ifdef __CYGWIN__
@@ -71,6 +72,10 @@ namespace {
     "use-mcjit", cl::desc("Enable use of the MC-based JIT (if available)"),
     cl::init(false));
 
+  cl::opt<bool> DebugIR(
+    "debug-ir", cl::desc("Generate debug information to allow debugging IR."),
+    cl::init(false));
+
   // The MCJIT supports building for a target address space separate from
   // the JIT compilation process. Use a forked process and a copying
   // memory manager with IPC to execute using this functionality.
@@ -321,6 +326,17 @@ int main(int argc, char **argv, char * c
     }
   }
 
+  if (DebugIR) {
+    if (!UseMCJIT) {
+      errs() << "warning: -debug-ir used without -use-mcjit. Only partial debug"
+        << " information will be emitted by the non-MC JIT engine. To see full"
+        << " source debug information, enable the flag '-use-mcjit'.\n";
+
+    }
+    ModulePass *DebugIRPass = createDebugIRPass();
+    DebugIRPass->runOnModule(*Mod);
+  }
+
   EngineBuilder builder(Mod);
   builder.setMArch(MArch);
   builder.setMCPU(MCPU);





More information about the llvm-commits mailing list