[llvm] [ORC][JITLink] Add Intel VTune support to JITLink (PR #81826)
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 28 16:14:33 PST 2024
================
@@ -0,0 +1,191 @@
+//===--- VTuneSupportPlugin.cpp -- Support for VTune profiler --*- C++ -*--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Handles support for registering code with VIntel Tune's Amplfiier JIT API.
+//
+//===----------------------------------------------------------------------===//
+#include "llvm/ExecutionEngine/Orc/Debugging/VTuneSupportPlugin.h"
+#include "llvm/DebugInfo/DWARF/DWARFContext.h"
+#include "llvm/ExecutionEngine/Orc/Debugging/DebugInfoSupport.h"
+
+using namespace llvm;
+using namespace llvm::orc;
+using namespace llvm::jitlink;
+
+namespace {
+
+constexpr StringRef RegisterVTuneImplName = "llvm_orc_registerVTuneImpl";
+constexpr StringRef UnregisterVTuneImplName = "llvm_orc_unregisterVTuneImpl";
+constexpr StringRef RegisterTestVTuneImplName =
+ "llvm_orc_test_registerVTuneImpl";
+
+static VTuneMethodBatch getMethodBatch(LinkGraph &G, bool EmitDebugInfo) {
+ VTuneMethodBatch Batch;
+ std::unique_ptr<DWARFContext> DC;
+ StringMap<std::unique_ptr<MemoryBuffer>> DCBacking;
+ if (EmitDebugInfo) {
+ auto EDC = createDWARFContext(G);
+ if (!EDC) {
+ // ERROR
+ EmitDebugInfo = false;
+ } else {
+ DC = std::move(EDC->first);
+ DCBacking = std::move(EDC->second);
+ }
+ }
+
+ auto GetStringIdx = [Deduplicator = StringMap<uint32_t>(),
+ &Batch](StringRef S) mutable {
+ auto I = Deduplicator.find(S);
+ if (I != Deduplicator.end()) {
+ return I->second;
+ }
----------------
lhames wrote:
The LLVM style guide omits braces for single line statements, so this could just be:
```c++
if (I != Deduplicator.end())
return I->second;
```
https://github.com/llvm/llvm-project/pull/81826
More information about the llvm-commits
mailing list