aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2021-12-30 13:39:39 +0300
committerRoman Lebedev <lebedev.ri@gmail.com>2021-12-30 13:50:02 +0300
commita5337d6a1c6701eb98e085fb69a6e33c36f9533f (patch)
treede648de3551414f1ac1748c337eff7dede7ce001
parent128c6ed73b8f906a13ae908008c6f415415964bb (diff)
downloadllvm-a5337d6a1c6701eb98e085fb69a6e33c36f9533f.zip
llvm-a5337d6a1c6701eb98e085fb69a6e33c36f9533f.tar.gz
llvm-a5337d6a1c6701eb98e085fb69a6e33c36f9533f.tar.bz2
[BitcodeReader] `bitc::CST_CODE_INLINEASM`: un-hardcode offsets
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 1684f04..3360ad1 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2860,22 +2860,26 @@ Error BitcodeReader::parseConstants() {
case bitc::CST_CODE_INLINEASM: {
if (Record.size() < 2)
return error("Invalid record");
+ unsigned OpNum = 0;
std::string AsmStr, ConstrStr;
- bool HasSideEffects = Record[0] & 1;
- bool IsAlignStack = (Record[0] >> 1) & 1;
- unsigned AsmDialect = (Record[0] >> 2) & 1;
- bool CanThrow = (Record[0] >> 3) & 1;
- unsigned AsmStrSize = Record[1];
- if (2 + AsmStrSize >= Record.size())
+ bool HasSideEffects = Record[OpNum] & 1;
+ bool IsAlignStack = (Record[OpNum] >> 1) & 1;
+ unsigned AsmDialect = (Record[OpNum] >> 2) & 1;
+ bool CanThrow = (Record[OpNum] >> 3) & 1;
+ ++OpNum;
+ unsigned AsmStrSize = Record[OpNum];
+ ++OpNum;
+ if (OpNum + AsmStrSize >= Record.size())
return error("Invalid record");
- unsigned ConstStrSize = Record[2 + AsmStrSize];
- if (3 + AsmStrSize + ConstStrSize > Record.size())
+ unsigned ConstStrSize = Record[OpNum + AsmStrSize];
+ if (OpNum + 1 + AsmStrSize + ConstStrSize > Record.size())
return error("Invalid record");
for (unsigned i = 0; i != AsmStrSize; ++i)
- AsmStr += (char)Record[2 + i];
+ AsmStr += (char)Record[OpNum + i];
+ ++OpNum;
for (unsigned i = 0; i != ConstStrSize; ++i)
- ConstrStr += (char)Record[3 + AsmStrSize + i];
+ ConstrStr += (char)Record[OpNum + AsmStrSize + i];
UpgradeInlineAsmString(&AsmStr);
V = InlineAsm::get(
cast<FunctionType>(cast<PointerType>(CurTy)->getElementType()),