[PATCH] Fix line mapping information in LLVM JIT profiling with Vtune

Alexey Bataev a.bataev at hotmail.com
Sun Dec 14 20:46:35 PST 2014


REPOSITORY
  rL LLVM

http://reviews.llvm.org/D6603

Files:
  llvm/trunk/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp
  llvm/trunk/tools/llvm-jitlistener/llvm-jitlistener.cpp

Index: llvm/trunk/tools/llvm-jitlistener/llvm-jitlistener.cpp
===================================================================
--- llvm/trunk/tools/llvm-jitlistener/llvm-jitlistener.cpp
+++ llvm/trunk/tools/llvm-jitlistener/llvm-jitlistener.cpp
@@ -140,7 +140,7 @@
     TheJIT.reset(EngineBuilder(std::move(TheModule))
       .setEngineKind(EngineKind::JIT)
       .setErrorStr(&Error)
-      .setMCJITMemoryManager(MemMgr)
+      .setMCJITMemoryManager(std::unique_ptr<RTDyldMemoryManager>(MemMgr))
       .create());
     if (Error.empty() == false)
       errs() << Error;
Index: llvm/trunk/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp
===================================================================
--- llvm/trunk/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp
+++ llvm/trunk/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp
@@ -149,6 +149,18 @@
           FunctionMessage.line_number_size = 0;
           FunctionMessage.line_number_table = 0;
         } else {
+          // Source line information for the address range is provided as 
+          // a code offset for the start of the corresponding sub-range and
+          // a source line. JIT API treats offsets in LineNumberInfo structures
+          // as the end of the corresponding code region. The start of the code
+          // is taken from the previous element. Need to shift the elements.
+
+          LineNumberInfo last = LineInfo.back();
+          last.Offset = FunctionMessage.method_size;
+          LineInfo.push_back(last);
+          for (size_t i = LineInfo.size() - 2; i > 0; --i)
+            LineInfo[i].LineNumber = LineInfo[i - 1].LineNumber;
+
           SourceFileName = Lines.front().second.FileName;
           FunctionMessage.source_file_name = const_cast<char *>(SourceFileName.c_str());
           FunctionMessage.line_number_size = LineInfo.size();

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6603.17267.patch
Type: text/x-patch
Size: 1892 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141215/d9e933a4/attachment.bin>


More information about the llvm-commits mailing list