diff options
author | Jay Foad <jay.foad@amd.com> | 2024-09-05 16:48:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-05 16:48:22 +0100 |
commit | 2f6e4ed389a6589f340d7efab2b0c7ee22c3d086 (patch) | |
tree | ff7c670e5dd7083d2571ea9119ba76f70f8f4e36 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | 56b2be4a7608770bae5db9d467f50c232c3cf19a (diff) | |
download | llvm-2f6e4ed389a6589f340d7efab2b0c7ee22c3d086.zip llvm-2f6e4ed389a6589f340d7efab2b0c7ee22c3d086.tar.gz llvm-2f6e4ed389a6589f340d7efab2b0c7ee22c3d086.tar.bz2 |
[IR] Check parameters of target extension types on construction (#107268)
Since IR Types are immutable it makes sense to check them on
construction instead of in the IR Verifier pass.
This patch checks that some TargetExtTypes are well-formed in the sense
that they have the expected number of type parameters and integer
parameters. When called from LLParser it gives a diagnostic message.
When called from anywhere else it just asserts that they are
well-formed.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 654be98..1cd9ec6 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2679,7 +2679,11 @@ Error BitcodeReader::parseTypeTableBody() { return error("Integer parameter too large"); IntParams.push_back(Record[i]); } - ResultTy = TargetExtType::get(Context, TypeName, TypeParams, IntParams); + auto TTy = + TargetExtType::getOrError(Context, TypeName, TypeParams, IntParams); + if (auto E = TTy.takeError()) + return E; + ResultTy = *TTy; TypeName.clear(); break; } |