[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.

llvm-svn: 343690
This commit is contained in:
Simon Pilgrim 2018-10-03 14:51:09 +00:00
parent 925b64be64
commit 92d02027c2
1 changed files with 4 additions and 2 deletions

View File

@ -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);