aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorelhewaty <mohamedatef1698@gmail.com>2024-10-15 12:11:25 +0300
committerGitHub <noreply@github.com>2024-10-15 17:11:25 +0800
commit9efb07f261b2cd673c0a5abf2ed2546ad288ab48 (patch)
tree1aaa512bdb656ee9f9c665634fc39c94410bfa38 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent48521209aa4d95a97564f8a5af7ccca09c6ede5d (diff)
downloadllvm-9efb07f261b2cd673c0a5abf2ed2546ad288ab48.zip
llvm-9efb07f261b2cd673c0a5abf2ed2546ad288ab48.tar.gz
llvm-9efb07f261b2cd673c0a5abf2ed2546ad288ab48.tar.bz2
[IR] Add `samesign` flag to icmp instruction (#111419)
Inspired by https://discourse.llvm.org/t/rfc-signedness-independent-icmps/81423
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index a8b5f96..e09532dc 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -5471,9 +5471,6 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
if (IsFP && Record.size() > OpNum+1)
FMF = getDecodedFastMathFlags(Record[++OpNum]);
- if (OpNum+1 != Record.size())
- return error("Invalid record");
-
if (IsFP) {
if (!CmpInst::isFPPredicate(PredVal))
return error("Invalid fcmp predicate");
@@ -5482,8 +5479,14 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
if (!CmpInst::isIntPredicate(PredVal))
return error("Invalid icmp predicate");
I = new ICmpInst(PredVal, LHS, RHS);
+ if (Record.size() > OpNum + 1 &&
+ (Record[++OpNum] & (1 << bitc::ICMP_SAME_SIGN)))
+ cast<ICmpInst>(I)->setSameSign();
}
+ if (OpNum + 1 != Record.size())
+ return error("Invalid record");
+
ResTypeID = getVirtualTypeID(I->getType()->getScalarType());
if (LHS->getType()->isVectorTy())
ResTypeID = getVirtualTypeID(I->getType(), ResTypeID);