[PATCH] D80610: [llvm-exegesis] Make createCounter a virtual method on Target to allow targets to create target-specific counters
Vy Nguyen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 26 21:46:22 PDT 2020
oontvoo updated this revision to Diff 266417.
oontvoo added a comment.
fix accidentally mixed-up branches
P.S: actually still not fixed. i've sorted out the branches locally and re-run `arc diff` but that didn't seem to fix it. Any idea which else to try?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80610/new/
https://reviews.llvm.org/D80610
Files:
llvm/tools/llvm-exegesis/lib/Target.cpp
llvm/tools/llvm-exegesis/lib/Target.h
Index: llvm/tools/llvm-exegesis/lib/Target.h
===================================================================
--- llvm/tools/llvm-exegesis/lib/Target.h
+++ llvm/tools/llvm-exegesis/lib/Target.h
@@ -27,6 +27,7 @@
#include "llvm/IR/LegacyPassManager.h"
#include "llvm/MC/MCInst.h"
#include "llvm/MC/MCRegisterInfo.h"
+#include "llvm/Support/Error.h"
namespace llvm {
namespace exegesis {
@@ -65,6 +66,10 @@
explicit ExegesisTarget(ArrayRef<CpuAndPfmCounters> CpuPfmCounters)
: CpuPfmCounters(CpuPfmCounters) {}
+ // Targets can use this to create target-specific perf counters.
+ virtual Expected<std::unique_ptr<pfm::Counter>>
+ createCounter(const char *CounterName, const LLVMState &State) const;
+
// Targets can use this to add target-specific passes in assembleToStream();
virtual void addTargetSpecificPasses(PassManagerBase &PM) const {}
Index: llvm/tools/llvm-exegesis/lib/Target.cpp
===================================================================
--- llvm/tools/llvm-exegesis/lib/Target.cpp
+++ llvm/tools/llvm-exegesis/lib/Target.cpp
@@ -11,6 +11,8 @@
#include "ParallelSnippetGenerator.h"
#include "SerialSnippetGenerator.h"
#include "UopsBenchmarkRunner.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/Support/Error.h"
namespace llvm {
namespace exegesis {
@@ -27,6 +29,19 @@
return nullptr;
}
+Expected<std::unique_ptr<pfm::Counter>>
+ExegesisTarget::createCounter(const char *CounterName,
+ const LLVMState &) const {
+ pfm::PerfEvent Event(CounterName);
+ if (!Event.valid())
+ return llvm::make_error<Failure>(
+ llvm::Twine("Unable to create counter with name '")
+ .concat(CounterName)
+ .concat("'"));
+
+ return std::make_unique<pfm::Counter>(std::move(Event));
+}
+
void ExegesisTarget::registerTarget(ExegesisTarget *Target) {
if (FirstTarget == nullptr) {
FirstTarget = Target;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80610.266417.patch
Type: text/x-patch
Size: 1923 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200527/a8b2c4ba/attachment.bin>
More information about the llvm-commits
mailing list