[llvm-branch-commits] [llvm] 5b8c1ed - [llvm-exegesis] Fix D80610.

Clement Courbet via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jun 2 01:13:01 PDT 2020


Author: Clement Courbet
Date: 2020-06-02T10:10:01+02:00
New Revision: 5b8c1ed2c802d3ae016363bab6d1e117b09ecdc9

URL: https://github.com/llvm/llvm-project/commit/5b8c1ed2c802d3ae016363bab6d1e117b09ecdc9
DIFF: https://github.com/llvm/llvm-project/commit/5b8c1ed2c802d3ae016363bab6d1e117b09ecdc9.diff

LOG: [llvm-exegesis] Fix D80610.

Summary:
Using a .data() member on a StringRef was discarding the StringRef
size, breaking llvm-exegesis on machines with counter sums (e.g.
Zen2).

Reviewers: oontvoo

Subscribers: mstojanovic, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D80982

Added: 
    

Modified: 
    llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
    llvm/tools/llvm-exegesis/lib/Target.cpp
    llvm/tools/llvm-exegesis/lib/Target.h

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
index 522d4210245c..a5565bdfa723 100644
--- a/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
+++ b/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp
@@ -55,7 +55,7 @@ class FunctionExecutorImpl : public BenchmarkRunner::FunctionExecutor {
     for (auto &CounterName : CounterNames) {
       CounterName = CounterName.trim();
       auto CounterOrError =
-          State.getExegesisTarget().createCounter(CounterName.data(), State);
+          State.getExegesisTarget().createCounter(CounterName, State);
 
       if (!CounterOrError)
         return CounterOrError.takeError();

diff  --git a/llvm/tools/llvm-exegesis/lib/Target.cpp b/llvm/tools/llvm-exegesis/lib/Target.cpp
index 61821bf4bb4d..6150c738dad8 100644
--- a/llvm/tools/llvm-exegesis/lib/Target.cpp
+++ b/llvm/tools/llvm-exegesis/lib/Target.cpp
@@ -30,8 +30,7 @@ const ExegesisTarget *ExegesisTarget::lookup(Triple TT) {
 }
 
 Expected<std::unique_ptr<pfm::Counter>>
-ExegesisTarget::createCounter(const char *CounterName,
-                              const LLVMState &) const {
+ExegesisTarget::createCounter(StringRef CounterName, const LLVMState &) const {
   pfm::PerfEvent Event(CounterName);
   if (!Event.valid())
     return llvm::make_error<Failure>(

diff  --git a/llvm/tools/llvm-exegesis/lib/Target.h b/llvm/tools/llvm-exegesis/lib/Target.h
index 937b88ddb4cc..bcc283ee8fe7 100644
--- a/llvm/tools/llvm-exegesis/lib/Target.h
+++ b/llvm/tools/llvm-exegesis/lib/Target.h
@@ -69,7 +69,7 @@ class ExegesisTarget {
 
   // 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;
+  createCounter(StringRef CounterName, const LLVMState &State) const;
 
   // Targets can use this to add target-specific passes in assembleToStream();
   virtual void addTargetSpecificPasses(PassManagerBase &PM) const {}


        


More information about the llvm-branch-commits mailing list