From 8975eb327427ea1963571c5c5bd1eb6778594f28 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 11 Dec 2025 15:52:40 +0100 Subject: [PATCH] [FuzzerMutate] Allow implicit truncation If the fixed value 42 does not fit the integer type, truncate it. --- llvm/lib/FuzzMutate/OpDescriptor.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/lib/FuzzMutate/OpDescriptor.cpp b/llvm/lib/FuzzMutate/OpDescriptor.cpp index 6ec70d917918..c7c5d77b7b9f 100644 --- a/llvm/lib/FuzzMutate/OpDescriptor.cpp +++ b/llvm/lib/FuzzMutate/OpDescriptor.cpp @@ -22,7 +22,8 @@ void fuzzerop::makeConstantsWithType(Type *T, std::vector &Cs) { uint64_t W = IntTy->getBitWidth(); Cs.push_back(ConstantInt::get(IntTy, 0)); Cs.push_back(ConstantInt::get(IntTy, 1)); - Cs.push_back(ConstantInt::get(IntTy, 42)); + Cs.push_back(ConstantInt::get(IntTy, 42, /*IsSigned=*/false, + /*ImplicitTrunc=*/true)); Cs.push_back(ConstantInt::get(IntTy, APInt::getMaxValue(W))); Cs.push_back(ConstantInt::get(IntTy, APInt::getMinValue(W))); Cs.push_back(ConstantInt::get(IntTy, APInt::getSignedMaxValue(W)));