llvm.org GIT mirror llvm / 445c3f1
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343690 91177308-0d34-0410-b5e6-96231b3b80d8 Simon Pilgrim 1 year, 9 months ago
1 changed file(s) with 4 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
8989 assert(!String.empty());
9090 int64_t IntValue = 0;
9191 double DoubleValue = 0;
92 if (sscanf(String.data(), kIntegerFormat, &IntValue) == 1)
92 if (String[0] == kIntegerFormat[0] &&
93 sscanf(String.data(), kIntegerFormat, &IntValue) == 1)
9394 return llvm::MCOperand::createImm(IntValue);
94 if (sscanf(String.data(), kDoubleFormat, &DoubleValue) == 1)
95 if (String[0] == kDoubleFormat[0] &&
96 sscanf(String.data(), kDoubleFormat, &DoubleValue) == 1)
9597 return llvm::MCOperand::createFPImm(DoubleValue);
9698 if (unsigned RegNo = getRegNo(String))
9799 return llvm::MCOperand::createReg(RegNo);