@@ -61,6 +61,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6161#include < llvm/Support/ManagedStatic.h>
6262#include < llvm/Support/MemoryBuffer.h>
6363#include < llvm/ExecutionEngine/GenericValue.h>
64+ #include < llvm/ExecutionEngine/JITEventListener.h>
6465#include < llvm/ExecutionEngine/MCJIT.h>
6566#include < llvm/Support/raw_ostream.h>
6667#include < llvm/Support/TargetSelect.h>
@@ -449,6 +450,17 @@ LLVM_Util::make_jit_execengine (std::string *err)
449450 if (! m_llvm_exec)
450451 return NULL ;
451452
453+ // These magic lines will make it so that enough symbol information
454+ // is injected so that running vtune will kinda tell you which shaders
455+ // you're in, and sometimes which function (only for functions that don't
456+ // get inlined. There doesn't seem to be any perf hit from this, either
457+ // in code quality or JIT time. It is only enabled, however, if your copy
458+ // of LLVM was build with -DLLVM_USE_INTEL_JITEVENTS=ON, otherwise
459+ // createIntelJITEventListener() is a stub that just returns nullptr.
460+ auto vtuneProfiler = llvm::JITEventListener::createIntelJITEventListener ();
461+ if (vtuneProfiler)
462+ m_llvm_exec->RegisterJITEventListener (vtuneProfiler);
463+
452464 // Force it to JIT as soon as we ask it for the code pointer,
453465 // don't take any chances that it might JIT lazily, since we
454466 // will be stealing the JIT code memory from under its nose and
0 commit comments