From 9a8d357d0b46df5d4df7bbfec14321dd6f28119a Mon Sep 17 00:00:00 2001 From: Rafael Auler Date: Fri, 16 Oct 2015 17:00:36 -0700 Subject: [PATCH] Fix DataReader to work with new local sym perf2flo format Summary: In a recent commit, we changed local symbols to be specially tagged with the number 2 (local sym) instead of 1 (sym). This patch modifies the reader to don't choke when seeing a 2 in the symbol id field. (cherry picked from FBD2552776) --- bolt/DataReader.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/bolt/DataReader.cpp b/bolt/DataReader.cpp index 1a762735d019..a0db59b401d2 100644 --- a/bolt/DataReader.cpp +++ b/bolt/DataReader.cpp @@ -92,12 +92,14 @@ ErrorOr DataReader::parseNumberField(char EndChar) { ErrorOr DataReader::parseLocation() { // Read whether the location of the branch should be DSO or a symbol - if (ParsingBuf[0] != '0' && ParsingBuf[0] != '1') { - reportError("expected 0 or 1"); + // 0 means it is a DSO. 1 means it is a global symbol. 2 means it is a local + // symbol. + if (ParsingBuf[0] != '0' && ParsingBuf[0] != '1' && ParsingBuf[0] != '2') { + reportError("expected 0, 1 or 2"); return make_error_code(llvm::errc::io_error); } - bool IsSymbol = ParsingBuf[0] == '1'; + bool IsSymbol = ParsingBuf[0] == '1' || ParsingBuf[0] == '2'; ParsingBuf = ParsingBuf.drop_front(1); Col += 1; @@ -153,7 +155,7 @@ bool DataReader::hasData() { if (ParsingBuf.size() == 0) return false; - if (ParsingBuf[0] == '0' || ParsingBuf[0] == '1') + if (ParsingBuf[0] == '0' || ParsingBuf[0] == '1' || ParsingBuf[0] == '2') return true; return false; }