[llvm] r343690 - [llvm-exegesis] Avoid yaml parser from calling sscanf for obvious non-matches (PR39102)

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 3 07:51:09 PDT 2018


Author: rksimon
Date: Wed Oct  3 07:51:09 2018
New Revision: 343690

URL: http://llvm.org/viewvc/llvm-project?rev=343690&view=rev
Log:
[llvm-exegesis] Avoid yaml parser from calling sscanf for obvious non-matches (PR39102)

deserializeMCOperand - ensure that we at least match the first character of the sscanf pattern before calling

This reduces llvm-exegesis uops analysis of the instructions supported from btver2 from 5m13s to 2m1s on debug builds.

Modified:
    llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp

Modified: llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp?rev=343690&r1=343689&r2=343690&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/BenchmarkResult.cpp Wed Oct  3 07:51:09 2018
@@ -90,9 +90,11 @@ private:
     assert(!String.empty());
     int64_t IntValue = 0;
     double DoubleValue = 0;
-    if (sscanf(String.data(), kIntegerFormat, &IntValue) == 1)
+    if (String[0] == kIntegerFormat[0] &&
+        sscanf(String.data(), kIntegerFormat, &IntValue) == 1)
       return llvm::MCOperand::createImm(IntValue);
-    if (sscanf(String.data(), kDoubleFormat, &DoubleValue) == 1)
+    if (String[0] == kDoubleFormat[0] &&
+        sscanf(String.data(), kDoubleFormat, &DoubleValue) == 1)
       return llvm::MCOperand::createFPImm(DoubleValue);
     if (unsigned RegNo = getRegNo(String))
       return llvm::MCOperand::createReg(RegNo);




More information about the llvm-commits mailing list