From 2f6e4ed389a6589f340d7efab2b0c7ee22c3d086 Mon Sep 17 00:00:00 2001 From: Jay Foad Date: Thu, 5 Sep 2024 16:48:22 +0100 Subject: [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. --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp') 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; } -- cgit v1.1