[llvm] r224229 - Fix line mapping information in LLVM JIT profiling with Vtune

Alexey Bataev a.bataev at hotmail.com
Sun Dec 14 20:45:43 PST 2014


Author: abataev
Date: Sun Dec 14 22:45:43 2014
New Revision: 224229

URL: http://llvm.org/viewvc/llvm-project?rev=224229&view=rev
Log:
Fix line mapping information in LLVM JIT profiling with Vtune
The line mapping information for dynamic code is reported incorrectly. It causes VTune to map LLVM generated code to source lines incorrectly. This patch fix this issue.
Patch by Denis Pravdin.
Differential Revision: http://reviews.llvm.org/D6603

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

Modified: llvm/trunk/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp?rev=224229&r1=224228&r2=224229&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/IntelJITEvents/IntelJITEventListener.cpp Sun Dec 14 22:45:43 2014
@@ -149,6 +149,18 @@ void IntelJITEventListener::NotifyObject
           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();

Modified: llvm/trunk/tools/llvm-jitlistener/llvm-jitlistener.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-jitlistener/llvm-jitlistener.cpp?rev=224229&r1=224228&r2=224229&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-jitlistener/llvm-jitlistener.cpp (original)
+++ llvm/trunk/tools/llvm-jitlistener/llvm-jitlistener.cpp Sun Dec 14 22:45:43 2014
@@ -140,7 +140,7 @@ protected:
     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;





More information about the llvm-commits mailing list