34using namespace PatternMatch;
43 if (
V.isAggregate()) {
44 for (
auto &SubValue :
V.asAggregate())
54 if (Scalar.isInteger() && !CR.
contains(Scalar.asInteger()))
61 if (Scalar.isFloat() && (Scalar.asFloat().classify() & NoFPClass))
67 if (
V.isPointer() &&
V.asPointer().isNullPtr(AS,
DL))
73 if (Scalar.isPointer() &&
74 Scalar.asPointer().address().countr_zero() <
Log2(Alignment))
80 bool ContainsPoison =
false;
82 if (Scalar.isPoison()) {
83 ContainsPoison =
true;
86 if (Scalar.isByte() && !ContainsPoison) {
89 ContainsPoison =
any_of(Scalar.asByte().bytes(), [](
const Byte &
V) {
90 return V.ConcreteMask != 255;
94 return ContainsPoison;
99 bool OrNull,
unsigned AS,
104 auto &Ptr =
V.asPointer();
105 if (Ptr.isNullPtr(AS, Ctx.getDataLayout())) {
111 auto *MO = Ctx.checkProvenance(Ptr, [&](
const Provenance &) {
122 const APInt &PtrAddr = Ptr.address();
123 return Bytes > MO->getSize() || PtrAddr.
ult(MO->getAddress()) ||
124 PtrAddr.
ugt(MO->getAddress() + MO->getSize() - Bytes);
133 std::list<Frame> CallStack;
135 std::list<AnyValue> UnsupportedConstantValues;
143 UnsupportedConstantValues.push_back(
145 return UnsupportedConstantValues.back();
157 assert(
V.isCompatibleWith(
I.getType()) &&
"Unexpected value storage kind.");
169 if (
Ctx.getRandomBool())
186 if (Val.isAggregate()) {
187 std::vector<AnyValue> ResVec;
188 ResVec.reserve(Val.asAggregate().size());
189 for (
const auto &
A : Val.asAggregate())
190 ResVec.push_back(handleFMFFlags(
A, FMF, IsInput));
194 const APFloat &APVal = Val.asFloat();
211 Candidates.
push_back(std::move(Candidate));
215 assert(!Candidates.
empty() &&
"Need at least one NaN candidate.");
216 return Candidates[
Ctx.getRandomUInt64() % Candidates.
size()];
220 const unsigned NumBits = Sem.
precision - 1;
224 for (
unsigned I = 0;
I != NumWords; ++
I)
226 return APInt(NumBits, RandomWords);
229 bool isPreferredNaN(
const APFloat &Val) {
240 if (
Input->isSignaling() || !isPreferredNaN(*
Input))
247 bool QuietingMode,
bool FlipSign) {
266 if (NoSignedZeros &&
LHS.isZero() &&
RHS.isZero() &&
267 LHS.isNegative() !=
RHS.isNegative() &&
Ctx.mayUseNonDeterminism())
270 case Intrinsic::maximum:
271 case Intrinsic::vector_reduce_fmaximum:
273 case Intrinsic::minimum:
274 case Intrinsic::vector_reduce_fminimum:
276 case Intrinsic::maximumnum:
277 case Intrinsic::vector_reduce_fmaximumnum:
279 case Intrinsic::minimumnum:
280 case Intrinsic::vector_reduce_fminimumnum:
282 case Intrinsic::maxnum:
283 case Intrinsic::vector_reduce_fmax:
284 return maxnum(maybeQuietSNaN(
LHS), maybeQuietSNaN(
RHS));
285 case Intrinsic::minnum:
286 case Intrinsic::vector_reduce_fmin:
287 return minnum(maybeQuietSNaN(
LHS), maybeQuietSNaN(
RHS));
300 addNaNCandidate(Candidates, propagateInputNaN(*
Input, DstSem,
301 QuietingMode, SignChoice));
309 const Triple &TT =
Ctx.getTargetTriple();
311 if (!wasmMayProduceExtraNaNPayload(Inputs))
313 APInt Payload = getRandomNaNPayload(Result.getSemantics());
315 SignChoice, &Payload));
319 if (TT.isSPARC32() || TT.isSPARC64()) {
322 SignChoice, &Payload));
332 Ctx.getEffectiveNaNPropagationBehavior();
333 const bool SignChoice =
Ctx.getRandomBool();
344 addPropagatedNaNCandidates(Candidates, Inputs, ResultSem,
348 addPropagatedNaNCandidates(Candidates, Inputs, ResultSem,
352 addTargetSpecificNaNCandidates(Candidates, Result, Inputs, SignChoice);
356 addPropagatedNaNCandidates(Candidates, Inputs, ResultSem,
358 addPropagatedNaNCandidates(Candidates, Inputs, ResultSem,
360 addTargetSpecificNaNCandidates(Candidates, Result, Inputs, SignChoice);
361 return pickNaNCandidate(Candidates);
368 if (Ty->isVectorTy()) {
370 std::vector<AnyValue> ResVec;
371 ResVec.reserve(OperandVec.size());
372 for (
const auto &Scalar : OperandVec)
373 ResVec.push_back(ScalarFn(Scalar));
374 return std::move(ResVec);
376 return ScalarFn(Operand);
381 setResult(
I, computeUnOp(
I.getType(), getValue(
I.getOperand(0)), ScalarFn));
395 setResult(
I, visitBitwiseFPUnOpWithResult(
397 getValue(
I.getOperand(0)), ScalarFn));
401 visitIntUnOpWithResult(
Type *RetTy,
const AnyValue &Operand,
403 return computeUnOp(RetTy, Operand,
407 return ScalarFn(OperandInner.
asInteger());
411 AnyValue visitBitwiseFPUnOpWithResult(
423 handleFMFFlags(OperandInner, FMF,
true);
425 return ValidatedOperand;
429 return handleFMFFlags(Result, FMF,
false);
436 if (Ty->isVectorTy()) {
437 auto &LHSVec =
LHS.asAggregate();
438 auto &RHSVec =
RHS.asAggregate();
439 std::vector<AnyValue> ResVec;
440 ResVec.reserve(LHSVec.size());
441 for (
const auto &[ScalarLHS, ScalarRHS] :
zip(LHSVec, RHSVec))
442 ResVec.push_back(ScalarFn(ScalarLHS, ScalarRHS));
443 return std::move(ResVec);
445 return ScalarFn(
LHS,
RHS);
451 setResult(
I, computeBinOp(
I.getType(), getValue(
I.getOperand(0)),
452 getValue(
I.getOperand(1)), ScalarFn));
459 if (
LHS.isPoison() ||
RHS.isPoison())
461 return ScalarFn(
LHS.asInteger(),
RHS.asInteger());
468 setResult(
I, visitFPBinOpWithResult(
470 getValue(
I.getOperand(0)), getValue(
I.getOperand(1)),
486 AnyValue visitOverflowIntBinOpWithResult(
490 if (!
LHS.isAggregate()) {
491 if (
LHS.isPoison() ||
RHS.isPoison())
493 auto [Res, Overflow] = ScalarFn(
LHS.asInteger(),
RHS.asInteger());
497 auto &LHSVec =
LHS.asAggregate();
498 auto &RHSVec =
RHS.asAggregate();
499 std::vector<AnyValue> ResVec;
500 std::vector<AnyValue> OverflowVec;
501 ResVec.reserve(LHSVec.size());
502 OverflowVec.reserve(LHSVec.size());
503 for (
const auto &[ScalarLHS, ScalarRHS] :
zip(LHSVec, RHSVec)) {
504 if (ScalarLHS.isPoison() || ScalarRHS.isPoison()) {
509 auto [Res, Overflow] =
510 ScalarFn(ScalarLHS.asInteger(), ScalarRHS.asInteger());
514 return std::vector<AnyValue>{
AnyValue(std::move(ResVec)),
522 DenormalMode DenormMode = getCurrentDenormalMode(RetTy);
524 if (!
Ctx.isDefaultFPEnv())
526 "default floating-point environment";
535 handleFMFFlags(LHSInner, FMF,
true);
537 handleFMFFlags(RHSInner, FMF,
true);
545 DenormMode.
Input,
true);
547 DenormMode.
Input,
true);
549 APFloat RawResult = ScalarFn(FLHS, FRHS);
553 handleDenormal(RawResult, DenormMode.
Output,
false),
561 return applyNaNPropagation(Result, {&FLHS, &FRHS});
571 if (Ty->isVectorTy()) {
575 std::vector<AnyValue> ResVec;
576 ResVec.reserve(Op1Vec.size());
577 for (
const auto &[ScalarOp1, ScalarOp2, ScalarOp3] :
578 zip(Op1Vec, Op2Vec, Op3Vec))
579 ResVec.push_back(ScalarFn(ScalarOp1, ScalarOp2, ScalarOp3));
580 return std::move(ResVec);
582 return ScalarFn(Op1, Op2, Op3);
589 setResult(
I, computeTriOp(
I.getType(), getValue(
I.getOperand(0)),
590 getValue(
I.getOperand(1)),
591 getValue(
I.getOperand(2)), ScalarFn));
614 RetTy, Op1, Op2, Op3,
629 DenormalMode DenormMode = getCurrentDenormalMode(RetTy);
631 if (!
Ctx.isDefaultFPEnv())
633 "default floating-point environment";
636 RetTy, Op1, Op2, Op3,
643 handleFMFFlags(Op1Inner, FMF,
true);
645 handleFMFFlags(Op2Inner, FMF,
true);
647 handleFMFFlags(Op3Inner, FMF,
true);
657 DenormMode.
Input,
true);
659 DenormMode.
Input,
true);
661 DenormMode.
Input,
true);
663 APFloat RawResult = ScalarFn(FOp1, FOp2, FOp3);
667 handleDenormal(RawResult, DenormMode.
Output,
false),
675 return applyNaNPropagation(Result, {&FOp1, &FOp2, &FOp3});
680 if (!
Handler.onBBJump(Terminator, *DestBB)) {
694 AnyValue IncomingVal = getValue(
PHI->getIncomingValueForBlock(From));
701 handleFMFFlags(std::move(IncomingVal), FMF,
true);
711 for (
auto &[
K,
V] : IncomingValues)
712 setResult(*
K, std::move(
V));
719 return Asm->getAsmString().empty() && RetTy->
isVoidTy();
725 Ty->getScalarType()->getFltSemantics());
741 return V.asInteger();
745 return Mask.asAggregate()[
I].asBoolean();
759 const auto &Ptrs = Args[0].asAggregate();
767 for (
size_t I = 0,
E = Ptrs.size();
I !=
E; ++
I) {
768 switch (getMaskLane(Mask,
I)) {
773 <<
"Poison mask lane in experimental vector histogram intrinsic.";
779 if (Ptrs[
I].isPoison()) {
781 "histogram intrinsic.";
794 for (LaneUpdate &Lane : Lanes) {
796 return Other.MO == Lane.MO &&
Other.Offset == Lane.Offset;
798 Lane.Old =
Ctx.load(*Lane.MO, Lane.Offset,
ElemTy);
801 for (LaneUpdate &Lane : Lanes) {
812 case Intrinsic::experimental_vector_histogram_add:
817 case Intrinsic::experimental_vector_histogram_uadd_sat: {
824 case Intrinsic::experimental_vector_histogram_umax:
827 case Intrinsic::experimental_vector_histogram_umin:
836 for (
const LaneUpdate &Lane : Lanes)
837 Ctx.store(*Lane.MO, Lane.Offset, Lane.New,
ElemTy);
859 <<
"llvm.speculative.load with poison number of accessible bytes.";
868 <<
" exceeds the loaded size " <<
Size <<
".";
887 return Ctx.fromBytes(Bytes, RetTy);
891 enum class MaskedAddrMode {
906 MaskedAddrMode
Mode,
bool IsStore) {
911 if (
Mode != MaskedAddrMode::PerLane &&
912 !DL.typeSizeEqualsStoreSize(
ElemTy)) {
914 <<
" is not supported.";
919 const unsigned IndexBW =
922 if (
Mode != MaskedAddrMode::PerLane)
927 if (
Mode == MaskedAddrMode::PerLane)
948 if (
Mode == MaskedAddrMode::Consecutive ||
949 (
Mode == MaskedAddrMode::Compressed &&
952 LanePtr =
Ctx.computePtrAdd(LanePtr,
APInt(IndexBW, AccessSize), Flags,
978 <<
" with poison explicit vector length.";
981 std::vector<AnyValue> EnabledMask(Mask.asAggregate());
983 if (EVLInt.
ugt(EnabledMask.size())) {
985 << EVLInt <<
" greater than the number of elements "
986 << EnabledMask.size() <<
'.';
992 return callMaskedLoadStoreIntrinsic(CB, Ptr, std::move(EnabledMask),
1007 const unsigned IndexBW =
1011 std::vector<AnyValue> LanePtrs(Mask.asAggregate().size(), Ptr);
1014 LanePtr =
Ctx.computeScaledPtrAdd(
1016 APInt(IndexBW,
I,
false,
true),
1019 return callVPLoadStoreIntrinsic(CB, std::move(LanePtrs), Mask, EVL,
1020 std::move(
Data), MaskedAddrMode::PerLane,
1033 const unsigned Rows =
1035 const unsigned Cols =
1042 if (StrideInt.
ult(Rows)) {
1045 <<
" less than the number of rows " << Rows <<
'.';
1051 const unsigned IndexBW =
1054 const APInt ElemSize(IndexBW,
Ctx.getEffectiveTypeAllocSize(
ElemTy),
1057 for (
unsigned C = 0;
C != Cols; ++
C) {
1076 CallStack.emplace_back(
F,
nullptr,
nullptr, Args,
1077 RetVal,
Ctx.getTLIImpl());
1086 if (!
Handler.onInstructionExecuted(RI, None))
1107 auto &
Cond = getValue(
SI.getCondition());
1108 if (
Cond.isPoison()) {
1112 for (
auto &Case :
SI.cases()) {
1113 if (Case.getCaseValue()->getValue() ==
Cond.asInteger()) {
1114 jumpTo(
SI, Case.getCaseSuccessor());
1118 jumpTo(
SI,
SI.getDefaultDest());
1131 Handler.onUnrecognizedInstruction(CI);
1143 [DestBB](
BasicBlock *Succ) { return Succ == DestBB; }))
1144 jumpTo(IBI, DestBB);
1163 if (
Function *Oracle = getSpeculativeLoadOracle(CB)) {
1166 Oracle->getAttributes().getRetAttrs());
1168 callSpeculativeLoadIntrinsic(CB,
CurrentFrame->CalleeArgs[0], RetVal);
1178 CurrentFrame->ResolvedCallee->getAttributes().getRetAttrs();
1181 RetVal = handleFMFFlags(std::move(RetVal), FMF,
false);
1190 setResult(CB, std::move(RetVal));
1193 Ctx.free(*ByValArg);
1197 jumpTo(*
II,
II->getNormalDest());
1204 const bool IsSigned =
1205 Opcode == Instruction::SDiv || Opcode == Instruction::SRem;
1207 if (
RHS.isPoison()) {
1211 const APInt &RHSVal =
RHS.asInteger();
1216 if (
LHS.isPoison()) {
1219 <<
"Signed division overflow (refine LHS to INT_MIN).";
1222 const APInt &LHSVal =
LHS.asInteger();
1224 if (Opcode == Instruction::SRem)
1226 <<
", RHS: " << RHSVal;
1237 if (Opcode == Instruction::SRem || Opcode == Instruction::URem)
1239 if (IsExact && !R.isZero())
1247 case Intrinsic::vector_reduce_add:
1248 case Intrinsic::vector_reduce_mul:
1249 case Intrinsic::vector_reduce_and:
1250 case Intrinsic::vector_reduce_or:
1251 case Intrinsic::vector_reduce_xor:
1252 case Intrinsic::vector_reduce_smax:
1253 case Intrinsic::vector_reduce_smin:
1254 case Intrinsic::vector_reduce_umax:
1255 case Intrinsic::vector_reduce_umin: {
1256 std::optional<APInt> Res;
1257 for (
const auto &
V : Args[0].asAggregate()) {
1262 const auto &IntV =
V.asInteger();
1268 case Intrinsic::vector_reduce_add:
1271 case Intrinsic::vector_reduce_mul:
1274 case Intrinsic::vector_reduce_and:
1277 case Intrinsic::vector_reduce_or:
1280 case Intrinsic::vector_reduce_xor:
1283 case Intrinsic::vector_reduce_smax:
1286 case Intrinsic::vector_reduce_smin:
1289 case Intrinsic::vector_reduce_umax:
1292 case Intrinsic::vector_reduce_umin:
1301 case Intrinsic::vector_reduce_fadd:
1302 case Intrinsic::vector_reduce_fmul: {
1304 for (
const auto &
V : Args[1].asAggregate()) {
1305 Res = visitFPBinOpWithResult(
1308 return IID == Intrinsic::vector_reduce_fadd ?
LHS +
RHS
1316 case Intrinsic::vector_reduce_fmaximum:
1317 case Intrinsic::vector_reduce_fminimum:
1318 case Intrinsic::vector_reduce_fmaximumnum:
1319 case Intrinsic::vector_reduce_fminimumnum: {
1320 const auto DenormMode = getCurrentDenormalMode(RetTy);
1324 std::optional<APFloat> Res;
1325 for (
const auto &
V : Args[0].asAggregate()) {
1329 handleFMFFlags(
V, InputFMF,
true);
1335 Res = std::move(
Op);
1342 handleFMFFlags(*Res, FMF,
false);
1346 handleDenormal(ValidatedRes.
asFloat(), DenormMode.Output,
1351 Args[0].asAggregate(), std::back_inserter(InputVec),
1353 return applyNaNPropagation(FRes, InputVec);
1355 case Intrinsic::vector_reduce_fmax:
1356 case Intrinsic::vector_reduce_fmin: {
1357 const auto DenormMode = getCurrentDenormalMode(RetTy);
1360 const auto &
Vector = Args[0].asAggregate();
1365 for (
const auto &
V :
Vector) {
1369 handleFMFFlags(
V, InputFMF,
true);
1373 ValidatedOp.
asFloat(), DenormMode.Input,
true));
1378 const bool HasSNaN =
1380 while (Worklist.
size() > 1) {
1384 LHSIdx =
Ctx.getRandomUInt64() % Worklist.
size();
1385 RHSIdx =
Ctx.getRandomUInt64() % (Worklist.
size() - 1);
1386 if (RHSIdx >= LHSIdx)
1390 APFloat Res = applyFPMinMax(IID, Worklist[LHSIdx], Worklist[RHSIdx],
1392 if (LHSIdx < RHSIdx)
1400 handleFMFFlags(Worklist.
front(), FMF,
false);
1403 APFloat FRes = handleDenormal(ValidatedRes.
asFloat(), DenormMode.Output,
1406 return applyNaNPropagation(FRes, InputVec);
1414 bool IsZeroPoison,
size_t Length) {
1422 if (!Vec[
I].asInteger().
isZero())
1433 case Intrinsic::assume:
1434 switch (Args[0].asBoolean()) {
1444 Value *WasOnVal = GetBundleArg(0);
1445 const AnyValue &WasOn = getValue(WasOnVal);
1448 case BundleAttr::Ignore:
1450 case BundleAttr::NoUndef:
1453 <<
"The value " << WasOn <<
" violates noundef assumption.";
1455 case BundleAttr::Range: {
1462 <<
Lower <<
", " <<
Upper <<
") assumption.";
1483 case BundleAttr::Align: {
1485 APInt Alignment = getIntNonPoison(getValue(GetBundleArg(1)));
1487 if (OBU.
Inputs.size() == 3) {
1488 APInt Offset = getIntNonPoison(getValue(GetBundleArg(2)));
1491 if (!Alignment.isPowerOf2()) {
1492 if (!CheckedAddr.
isZero())
1494 <<
" with a nonzero adjusted address and a "
1495 "non-power-of-two alignment "
1496 << Alignment <<
'.';
1499 if (CheckedAddr.
countr_zero() < Alignment.logBase2())
1501 <<
"The pointer " << WasOn <<
" violates align(" << Alignment
1505 case BundleAttr::NonNull:
1508 <<
"The pointer " << WasOn <<
" violates nonnull assumption.";
1510 case BundleAttr::Dereferenceable:
1511 case BundleAttr::DereferenceableOrNull: {
1512 APInt DereferenceableBytes =
1513 getIntNonPoison(getValue(GetBundleArg(1)));
1515 if (DereferenceableBytes.
isZero())
1519 Kind == BundleAttr::DereferenceableOrNull, AS,
Ctx))
1521 << (Kind == BundleAttr::DereferenceableOrNull
1522 ?
"dereferenceable_or_null("
1523 :
"dereferenceable(")
1524 << DereferenceableBytes <<
") assumption.";
1539 case Intrinsic::lifetime_start:
1540 case Intrinsic::lifetime_end: {
1546 assert(MO &&
"Memory object accessed by lifetime intrinsic should be "
1548 if (MO->isInaccessible()) {
1553 if (IID == Intrinsic::lifetime_start) {
1562 case Intrinsic::ssa_copy:
1563 case Intrinsic::expect:
1564 case Intrinsic::expect_with_probability:
1566 case Intrinsic::donothing:
1568 case Intrinsic::vscale: {
1570 const APInt VScale(64,
Ctx.getVScale());
1575 case Intrinsic::abs: {
1576 const bool IsIntMinPoison = getBooleanNonPoison(Args[1].asBoolean());
1577 return visitIntUnOpWithResult(
1581 return Operand.
abs();
1584 case Intrinsic::smax: {
1585 return visitIntBinOpWithResult(
1586 RetTy, Args[0], Args[1],
1591 case Intrinsic::smin: {
1592 return visitIntBinOpWithResult(
1593 RetTy, Args[0], Args[1],
1598 case Intrinsic::umax: {
1599 return visitIntBinOpWithResult(
1600 RetTy, Args[0], Args[1],
1605 case Intrinsic::umin: {
1606 return visitIntBinOpWithResult(
1607 RetTy, Args[0], Args[1],
1612 case Intrinsic::scmp:
1613 case Intrinsic::ucmp: {
1615 return visitIntBinOpWithResult(
1616 RetTy, Args[0], Args[1],
1620 if (IID == Intrinsic::scmp)
1627 case Intrinsic::bitreverse: {
1628 return visitIntUnOpWithResult(RetTy, Args[0],
1633 case Intrinsic::bswap: {
1634 return visitIntUnOpWithResult(
1638 case Intrinsic::ctpop: {
1639 return visitIntUnOpWithResult(
1644 case Intrinsic::ctlz:
1645 case Intrinsic::cttz: {
1646 const bool IsZeroPoison = getBooleanNonPoison(Args[1].asBoolean());
1647 return visitIntUnOpWithResult(
1649 if (IsZeroPoison && Operand.
isZero())
1651 if (IID == Intrinsic::ctlz)
1656 case Intrinsic::fshl:
1657 case Intrinsic::fshr: {
1658 return visitIntTriOpWithResult(
1659 RetTy, Args[0], Args[1], Args[2],
1664 const bool IsFShr = IID == Intrinsic::fshr;
1665 if (ShiftAmount == 0)
1666 return IsFShr ? Op2 : Op1;
1668 IsFShr ? ShiftAmount :
BitWidth - ShiftAmount;
1670 !IsFShr ? ShiftAmount :
BitWidth - ShiftAmount;
1671 return Op1.
shl(ShlAmount) | Op2.
lshr(LShrAmount);
1674 case Intrinsic::clmul: {
1675 return visitIntBinOpWithResult(
1676 RetTy, Args[0], Args[1],
1681 case Intrinsic::sadd_with_overflow:
1682 case Intrinsic::uadd_with_overflow:
1683 case Intrinsic::ssub_with_overflow:
1684 case Intrinsic::usub_with_overflow:
1685 case Intrinsic::smul_with_overflow:
1686 case Intrinsic::umul_with_overflow: {
1687 return visitOverflowIntBinOpWithResult(
1688 RetTy, Args[0], Args[1],
1691 bool Overflow =
false;
1693 case Intrinsic::sadd_with_overflow:
1694 Res =
LHS.sadd_ov(
RHS, Overflow);
1696 case Intrinsic::uadd_with_overflow:
1697 Res =
LHS.uadd_ov(
RHS, Overflow);
1699 case Intrinsic::ssub_with_overflow:
1700 Res =
LHS.ssub_ov(
RHS, Overflow);
1702 case Intrinsic::usub_with_overflow:
1703 Res =
LHS.usub_ov(
RHS, Overflow);
1705 case Intrinsic::smul_with_overflow:
1706 Res =
LHS.smul_ov(
RHS, Overflow);
1708 case Intrinsic::umul_with_overflow:
1709 Res =
LHS.umul_ov(
RHS, Overflow);
1714 return {Res, Overflow};
1717 case Intrinsic::sadd_sat:
1718 case Intrinsic::uadd_sat:
1719 case Intrinsic::ssub_sat:
1720 case Intrinsic::usub_sat:
1721 case Intrinsic::sshl_sat:
1722 case Intrinsic::ushl_sat: {
1723 return visitIntBinOpWithResult(
1724 RetTy, Args[0], Args[1],
1727 case Intrinsic::sadd_sat:
1728 return LHS.sadd_sat(
RHS);
1729 case Intrinsic::uadd_sat:
1730 return LHS.uadd_sat(
RHS);
1731 case Intrinsic::ssub_sat:
1732 return LHS.ssub_sat(
RHS);
1733 case Intrinsic::usub_sat:
1734 return LHS.usub_sat(
RHS);
1735 case Intrinsic::sshl_sat: {
1736 if (
RHS.uge(
LHS.getBitWidth()))
1738 return LHS.sshl_sat(
RHS);
1740 case Intrinsic::ushl_sat: {
1741 if (
RHS.uge(
LHS.getBitWidth()))
1743 return LHS.ushl_sat(
RHS);
1750 case Intrinsic::smulh:
1751 case Intrinsic::umulh:
1752 return visitIntBinOpWithResult(
1753 RetTy, Args[0], Args[1],
1758 case Intrinsic::pdep:
1759 case Intrinsic::pext:
1760 return visitIntBinOpWithResult(
1761 RetTy, Args[0], Args[1],
1766 case Intrinsic::vector_reduce_add:
1767 case Intrinsic::vector_reduce_mul:
1768 case Intrinsic::vector_reduce_and:
1769 case Intrinsic::vector_reduce_or:
1770 case Intrinsic::vector_reduce_xor:
1771 case Intrinsic::vector_reduce_smax:
1772 case Intrinsic::vector_reduce_smin:
1773 case Intrinsic::vector_reduce_umax:
1774 case Intrinsic::vector_reduce_umin:
1776 case Intrinsic::vector_insert: {
1777 assert(!Args[2].isPoison() &&
1778 "Verifier should reject poison vector_insert immarg.");
1779 const auto &Vec = Args[0].asAggregate();
1780 const auto &SubVec = Args[1].asAggregate();
1781 const auto &Idx = Args[2].asInteger();
1784 const uint64_t RawOffset = Idx.getZExtValue();
1785 const uint32_t MinSize = EC.getKnownMinValue();
1786 assert(RawOffset % MinSize == 0 &&
1787 "Verifier should reject misaligned vector_insert index.");
1788 const uint64_t Chunk = RawOffset / MinSize;
1790 if (Chunk > std::numeric_limits<uint64_t>::max() / EVL)
1793 if (
Offset > Vec.size() || SubVec.size() > Vec.size() -
Offset)
1795 std::vector<AnyValue> Res;
1796 Res.reserve(Vec.size());
1797 for (
size_t I = 0;
I != Vec.size(); ++
I) {
1799 Res.push_back(SubVec[
I -
Offset]);
1801 Res.push_back(Vec[
I]);
1803 return std::move(Res);
1805 case Intrinsic::vector_extract: {
1806 assert(!Args[1].isPoison() &&
1807 "Verifier should reject poison vector_extract immarg.");
1808 const auto &Vec = Args[0].asAggregate();
1809 const auto &Idx = Args[1].asInteger();
1811 const uint64_t RawOffset = Idx.getZExtValue();
1812 const uint32_t MinSize = EC.getKnownMinValue();
1813 assert(RawOffset % MinSize == 0 &&
1814 "Verifier should reject misaligned vector_extract index.");
1815 const uint64_t Chunk = RawOffset / MinSize;
1817 if (Chunk > std::numeric_limits<uint64_t>::max() / EVL)
1822 return std::vector<AnyValue>(Vec.begin() +
Offset,
1823 Vec.begin() +
Offset + EVL);
1825 case Intrinsic::vector_reverse: {
1826 auto Vec = Args[0].asAggregate();
1827 std::reverse(Vec.begin(), Vec.end());
1828 return std::move(Vec);
1830 case Intrinsic::vector_deinterleave2:
1831 case Intrinsic::vector_deinterleave3:
1832 case Intrinsic::vector_deinterleave4:
1833 case Intrinsic::vector_deinterleave5:
1834 case Intrinsic::vector_deinterleave6:
1835 case Intrinsic::vector_deinterleave7:
1836 case Intrinsic::vector_deinterleave8: {
1840 const auto &Vec = Args[0].asAggregate();
1841 std::vector<std::vector<AnyValue>> Res(Factor);
1842 for (
auto &SubVec : Res)
1843 SubVec.reserve(Vec.size() / Factor);
1844 for (
size_t I = 0,
E = Vec.size();
I !=
E; ++
I)
1845 Res[
I % Factor].push_back(Vec[
I]);
1847 std::vector<AnyValue> AggRes;
1848 AggRes.reserve(Factor);
1849 for (
auto &SubVec : Res)
1850 AggRes.emplace_back(std::move(SubVec));
1851 return AnyValue(std::move(AggRes));
1853 case Intrinsic::vector_interleave2:
1854 case Intrinsic::vector_interleave3:
1855 case Intrinsic::vector_interleave4:
1856 case Intrinsic::vector_interleave5:
1857 case Intrinsic::vector_interleave6:
1858 case Intrinsic::vector_interleave7:
1859 case Intrinsic::vector_interleave8: {
1863 const auto &Vec = Args[0].asAggregate();
1864 std::vector<AnyValue> Res;
1865 Res.reserve(Vec.size() * Factor);
1866 for (
size_t I = 0,
E = Vec.size();
I !=
E; ++
I) {
1867 for (
unsigned J = 0; J != Factor; ++J)
1868 Res.push_back(Args[J].asAggregate()[
I]);
1870 return std::move(Res);
1872 case Intrinsic::vector_splice_left: {
1873 if (Args[2].isPoison())
1875 const auto &
LHS = Args[0].asAggregate();
1876 const auto &
RHS = Args[1].asAggregate();
1877 const auto &
Off = Args[2].asInteger();
1878 const size_t Len =
LHS.size();
1882 std::vector<AnyValue> Res;
1884 for (
size_t I = 0;
I != Len; ++
I) {
1886 Res.push_back(Pos < Len ?
LHS[Pos] :
RHS[Pos - Len]);
1888 return std::move(Res);
1890 case Intrinsic::vector_splice_right: {
1891 if (Args[2].isPoison())
1893 const auto &
LHS = Args[0].asAggregate();
1894 const auto &
RHS = Args[1].asAggregate();
1895 const auto &
Off = Args[2].asInteger();
1896 const size_t Len =
LHS.size();
1900 std::vector<AnyValue> Res;
1902 for (
size_t I = 0;
I != Len; ++
I) {
1904 Res.push_back(Pos < Len ?
LHS[Pos] :
RHS[Pos - Len]);
1906 return std::move(Res);
1908 case Intrinsic::stepvector: {
1909 std::vector<AnyValue> Res;
1918 return std::move(Res);
1920 case Intrinsic::get_active_lane_mask: {
1921 if (Args[0].isPoison() || Args[1].isPoison())
1925 const APInt &
Base = Args[0].asInteger();
1926 const APInt &
N = Args[1].asInteger();
1930 Base.uge(
N) ? 0 : (
N -
Base).getLimitedValue(Len);
1931 std::vector<AnyValue> Res;
1935 return std::move(Res);
1937 case Intrinsic::mask_beforefirst: {
1938 const auto &Mask = Args[0].asAggregate();
1939 std::vector<AnyValue> Res;
1940 Res.reserve(Mask.size());
1941 bool SeenActive =
false;
1942 for (
const AnyValue &Lane : Mask) {
1943 switch (Lane.asBoolean()) {
1954 return std::move(Res);
1956 case Intrinsic::vector_reduce_fadd:
1957 case Intrinsic::vector_reduce_fmul:
1958 case Intrinsic::vector_reduce_fmaximum:
1959 case Intrinsic::vector_reduce_fminimum:
1960 case Intrinsic::vector_reduce_fmaximumnum:
1961 case Intrinsic::vector_reduce_fminimumnum:
1962 case Intrinsic::vector_reduce_fmax:
1963 case Intrinsic::vector_reduce_fmin:
1965 case Intrinsic::fabs: {
1966 return visitBitwiseFPUnOpWithResult(
1967 RetTy, FMF, Args[0],
1970 case Intrinsic::fma: {
1971 return visitFPTriOpWithResult(
1972 RetTy, FMF, Args[0], Args[1], Args[2],
1980 case Intrinsic::fmuladd: {
1981 return visitFPTriOpWithResult(
1982 RetTy, FMF, Args[0], Args[1], Args[2],
1985 if (
Ctx.fuseMultiplyAdd()) {
1990 return Op1 * Op2 + Op3;
1993 case Intrinsic::is_fpclass: {
1995 static_cast<FPClassTest>(Args[1].asInteger().getZExtValue());
2000 static_cast<bool>(
Op.asFloat().classify() & Mask));
2003 case Intrinsic::copysign: {
2004 return computeBinOp(
2005 RetTy, Args[0], Args[1],
2007 if (
LHS.isPoison() ||
RHS.isPoison())
2010 handleFMFFlags(
LHS, FMF,
true);
2012 handleFMFFlags(
RHS, FMF,
true);
2021 case Intrinsic::maxnum:
2022 case Intrinsic::minnum:
2023 case Intrinsic::maximum:
2024 case Intrinsic::minimum:
2025 case Intrinsic::maximumnum:
2026 case Intrinsic::minimumnum: {
2029 return visitFPBinOpWithResult(
2030 RetTy, InputFMF, Args[0], Args[1],
2035 case Intrinsic::fptosi_sat:
2036 case Intrinsic::fptoui_sat: {
2043 [[maybe_unused]]
bool IsExact;
2048 case Intrinsic::memcpy:
2049 case Intrinsic::memcpy_inline:
2050 case Intrinsic::memmove:
2055 case Intrinsic::memset:
2056 case Intrinsic::memset_inline:
2059 case Intrinsic::speculative_load:
2060 assert(!getSpeculativeLoadOracle(CB) &&
2061 "oracle form must be handled earlier");
2062 return callSpeculativeLoadIntrinsic(CB, Args[0], Args[2]);
2063 case Intrinsic::masked_load:
2064 return callMaskedLoadStoreIntrinsic(CB, Args[0], Args[1], Args[2],
2065 MaskedAddrMode::Consecutive,
2067 case Intrinsic::masked_store:
2068 return callMaskedLoadStoreIntrinsic(CB, Args[1], Args[2], Args[0],
2069 MaskedAddrMode::Consecutive,
2071 case Intrinsic::masked_gather:
2072 return callMaskedLoadStoreIntrinsic(CB, Args[0], Args[1], Args[2],
2073 MaskedAddrMode::PerLane,
2075 case Intrinsic::masked_scatter:
2076 return callMaskedLoadStoreIntrinsic(CB, Args[1], Args[2], Args[0],
2077 MaskedAddrMode::PerLane,
2079 case Intrinsic::masked_expandload:
2080 return callMaskedLoadStoreIntrinsic(CB, Args[0], Args[1], Args[2],
2081 MaskedAddrMode::Compressed,
2083 case Intrinsic::masked_compressstore:
2084 return callMaskedLoadStoreIntrinsic(CB, Args[1], Args[2], Args[0],
2085 MaskedAddrMode::Compressed,
2087 case Intrinsic::vp_load:
2088 return callVPLoadStoreIntrinsic(
2089 CB, withVPDefaultAlign(CB, Args[0], RetTy), Args[1], Args[2],
2092 case Intrinsic::vp_store:
2093 return callVPLoadStoreIntrinsic(
2095 Args[2], Args[3], Args[0], MaskedAddrMode::Consecutive,
2097 case Intrinsic::vp_gather:
2098 return callVPLoadStoreIntrinsic(
2099 CB, withVPDefaultAlign(CB, Args[0], RetTy->
getScalarType()), Args[1],
2101 MaskedAddrMode::PerLane,
2103 case Intrinsic::vp_scatter:
2104 return callVPLoadStoreIntrinsic(
2106 withVPDefaultAlign(CB, Args[1],
2108 Args[2], Args[3], Args[0], MaskedAddrMode::PerLane,
2110 case Intrinsic::experimental_vp_strided_load:
2111 return callVPStridedLoadStoreIntrinsic(
2112 CB, withVPDefaultAlign(CB, Args[0], RetTy->
getScalarType()), Args[1],
2115 case Intrinsic::experimental_vp_strided_store:
2116 return callVPStridedLoadStoreIntrinsic(
2118 withVPDefaultAlign(CB, Args[1],
2120 Args[2], Args[3], Args[4], Args[0],
2122 case Intrinsic::vp_merge: {
2123 std::vector<AnyValue>
Cond(Args[0].asAggregate());
2131 case Intrinsic::matrix_transpose: {
2132 const auto &Vec = Args[0].asAggregate();
2133 const unsigned Rows =
2135 const unsigned Cols =
2138 std::vector<AnyValue> Res;
2139 Res.reserve(Vec.size());
2140 for (
unsigned I = 0;
I != Rows; ++
I)
2141 for (
unsigned J = 0; J != Cols; ++J)
2142 Res.push_back(Vec[J * Rows +
I]);
2143 return std::move(Res);
2145 case Intrinsic::matrix_column_major_store:
2146 return callMatrixColumnMajorStoreIntrinsic(CB, Args[1], Args[2], Args[0]);
2147 case Intrinsic::experimental_noalias_scope_decl:
2150 case Intrinsic::experimental_cttz_elts: {
2151 const auto &Vec = Args[0].asAggregate();
2155 case Intrinsic::experimental_get_vector_length: {
2159 if (Args[0].isPoison())
2162 const APInt &Cnt = Args[0].asInteger();
2163 uint64_t MaxLanes = VFC->getZExtValue();
2164 if (ScalableC->isOne())
2165 MaxLanes *=
Ctx.getVScale();
2184 return APInt(32, Res);
2188 case Intrinsic::experimental_vector_extract_last_active: {
2189 const auto &
Data = Args[0].asAggregate();
2192 for (
size_t I =
Data.size();
I != 0; --
I) {
2193 switch (getMaskLane(Mask,
I - 1)) {
2206 case Intrinsic::experimental_vector_compress: {
2207 const auto &Val = Args[0].asAggregate();
2209 const auto &Passthru = Args[2].asAggregate();
2211 std::vector<AnyValue> Res;
2212 Res.reserve(Val.size());
2214 for (
size_t I = 0,
E = Val.size();
I !=
E; ++
I) {
2215 switch (getMaskLane(Mask,
I)) {
2217 Res.push_back(Val[
I]);
2226 for (
size_t I = Res.size(),
E = Val.size();
I !=
E; ++
I)
2227 Res.push_back(Passthru[
I]);
2228 return std::move(Res);
2231 case Intrinsic::experimental_vector_match: {
2232 const auto &Search = Args[0].asAggregate();
2233 const auto &Needles = Args[1].asAggregate();
2234 const auto &Mask = Args[2].asAggregate();
2236 std::vector<AnyValue> Res;
2237 Res.reserve(Search.size());
2239 for (
size_t I = 0,
E = Search.size();
I !=
E; ++
I) {
2240 switch (Mask[
I].asBoolean()) {
2251 if (Search[
I].isPoison()) {
2257 bool SawPoison =
false;
2258 for (
const AnyValue &Needle : Needles) {
2259 if (Needle.isPoison()) {
2263 if (Search[
I].asInteger() == Needle.asInteger())
2273 return std::move(Res);
2275 case Intrinsic::experimental_vector_histogram_add:
2276 case Intrinsic::experimental_vector_histogram_uadd_sat:
2277 case Intrinsic::experimental_vector_histogram_umax:
2278 case Intrinsic::experimental_vector_histogram_umin:
2279 return callExperimentalVectorHistogramIntrinsic(CB, Args, IID);
2281 Handler.onUnrecognizedInstruction(CB);
2289 LibFunc LF =
CurrentFrame->TLI.getLibFunc(*ResolvedCallee);
2292 Handler.onUnrecognizedInstruction(CB);
2297 if (
auto LibCallRes = Lib.executeLibcall(LF, CB.
getName(),
2304 Handler.onUnrecognizedInstruction(CB);
2313 if (Ty->isIntOrIntVectorTy()) {
2314 if (
auto CRAttr = AttrsAtCallSite.
getAttribute(Attribute::Range);
2317 if (
auto CRAttr = AttrsAtCallee.
getAttribute(Attribute::Range);
2321 if (AttributeFuncs::isNoFPClassCompatibleType(Ty)) {
2322 if (
auto CRAttr = AttrsAtCallSite.
getAttribute(Attribute::NoFPClass);
2325 if (
auto CRAttr = AttrsAtCallee.
getAttribute(Attribute::NoFPClass);
2329 if (Ty->isPointerTy()) {
2330 if (AttrsAtCallSite.
hasAttribute(Attribute::NonNull) ||
2334 if (Ty->isPtrOrPtrVectorTy()) {
2340 if ((AttrsAtCallSite.
hasAttribute(Attribute::NoUndef) ||
2344 <<
" violates noundef attribute.";
2347 if (Ty->isPointerTy()) {
2348 unsigned AS = Ty->getPointerAddressSpace();
2349 if (
uint64_t DereferenceableBytes =
2355 <<
"The value " <<
V <<
" violates dereferenceable("
2356 << DereferenceableBytes <<
") attribute.";
2358 if (
uint64_t DereferenceableOrNullBytes =
2365 "dereferenceable_or_null("
2366 << DereferenceableOrNullBytes <<
") attribute.";
2373 auto ExtractFirstIntOperand = [](
const MDNode *
Node) {
2377 if (Ty->isIntOrIntVectorTy()) {
2378 if (
MDNode *Ranges =
I.getMetadata(LLVMContext::MD_range)) {
2380 for (
uint32_t I = 0;
I < Ranges->getNumOperands();
I += 2) {
2387 if (!Scalar.isInteger())
2389 for (
auto &CR : RangeList)
2390 if (CR.contains(Scalar.asInteger()))
2396 if (AttributeFuncs::isNoFPClassCompatibleType(Ty)) {
2397 if (
const MDNode *NoFPClass =
I.getMetadata(LLVMContext::MD_nofpclass)) {
2399 V,
static_cast<FPClassTest>(ExtractFirstIntOperand(NoFPClass)));
2402 if (Ty->isPointerTy()) {
2403 if (
I.hasMetadata(LLVMContext::MD_nonnull))
2406 if (
const MDNode *Alignment =
I.getMetadata(LLVMContext::MD_align))
2411 <<
" violates !noundef metadata.";
2414 if (Ty->isPointerTy()) {
2415 unsigned AS = Ty->getPointerAddressSpace();
2416 if (
const MDNode *DereferenceableBytes =
2417 I.getMetadata(LLVMContext::MD_dereferenceable)) {
2418 uint64_t Bytes = ExtractFirstIntOperand(DereferenceableBytes);
2422 <<
"The value " <<
V <<
" violates !dereferenceable !{i64 "
2423 << Bytes <<
"} metadata.";
2424 }
else if (
const MDNode *DereferenceableOrNullBytes =
2425 I.getMetadata(LLVMContext::MD_dereferenceable_or_null)) {
2426 uint64_t Bytes = ExtractFirstIntOperand(DereferenceableOrNullBytes);
2430 <<
"The value " <<
V <<
" violates !dereferenceable_or_null!{i64 "
2431 << Bytes <<
"} metadata.";
2437 for (
auto &Obj :
F.Allocas) {
2438 assert(Obj->isInaccessible() != Inaccessible &&
2439 "Unexpected stack object accessibility state.");
2440 Obj->setIsInaccessible(Inaccessible);
2443 for (
auto &Obj :
F.LastFrame->CalleeByValArgs) {
2444 assert(Obj->isInaccessible() != Inaccessible &&
2445 "Unexpected byval object accessibility state.");
2446 Obj->setIsInaccessible(Inaccessible);
2455 assert(CalleeArgs.empty() &&
2456 "Forgot to call returnFromCallee before entering a new call.");
2458 CalleeArgs.push_back(getValue(Arg));
2462 if (isNoopInlineAsm(CalledOperand, CB.
getType())) {
2470 Handler.onUnrecognizedInstruction(CB);
2475 auto &CalleeVal = getValue(CalledOperand);
2476 if (CalleeVal.isPoison()) {
2480 Callee =
Ctx.getTargetFunction(CalleeVal.asPointer());
2483 <<
"Indirect call through invalid function pointer.";
2488 "mismatched signature. Expected: "
2490 <<
", Actual: " << *Callee->getFunctionType();
2495 assert(Callee &&
"Expected a resolved callee function.");
2498 "Expected the callee function type to match the call site signature.");
2499 if (!Callee->isIntrinsic() &&
2502 <<
"Mismatched calling convention between callee and callsite.";
2509 Type *ArgTy = Arg->getType();
2515 AttributeSet AttrsAtCallee = Callee->getAttributes().getParamAttrs(
I);
2519 auto *ByValTyFromCallee = AttrsAtCallee.
getByValType();
2520 if (ByValTy != ByValTyFromCallee) {
2522 <<
"Mismatched byval attribute between callee and callsite.";
2535 AllocAlign = CalleeAlign;
2536 if (!AllocAlign.has_value()) {
2540 AllocAlign = DL.getABITypeAlign(ByValTy);
2543 "Byval pointers cannot be passed via variadic arguments.");
2546 <<
"Byval argument with size that exceeds the maximum object "
2551 auto Obj =
Ctx.allocate(
2552 Size, AllocAlign->value(), Callee->getArg(
I)->getName(),
2557 <<
"Insufficient stack space for byval pointer argument.";
2562 std::max(AllocAlign.value(),
2566 copy(MO->getBytes().slice(
Offset,
Size), Obj->getBytes().begin());
2570 ArgVal =
Ctx.deriveFromMemoryObject(std::move(Obj));
2583 Type *ArgTy = Arg->getType();
2586 AttributeSet AttrsAtCallee = Callee->getAttributes().getParamAttrs(
I);
2594 if (
Function *Oracle = getSpeculativeLoadOracle(CB)) {
2595 Args = Args.drop_front(3);
2596 for (
auto [Arg, ArgVal] :
2599 Arg.getAttributes());
2602 if (Callee->isIntrinsic()) {
2606 }
else if (Callee->isDeclaration()) {
2612 if (MaxStackDepth && CallStack.size() >= MaxStackDepth) {
2616 assert(!Callee->empty() &&
"Expected a defined function.");
2620 CallStack.emplace_back(*Callee, &CB,
CurrentFrame, Args, RetVal,
2721 unsigned DestBW =
Trunc.getType()->getScalarSizeInBits();
2726 return Operand.
trunc(DestBW);
2735 return Operand.
zext(DestBW);
2742 return Operand.
sext(DestBW);
2751 if (!
Ctx.isDefaultFPEnv())
2753 "default floating-point environment";
2756 I.getType()->getScalarType()->getFltSemantics();
2764 getCurrentDenormalMode(
I.getOperand(0)->getType());
2766 auto ValidatedOperand = handleFMFFlags(Operand, FMF,
true);
2767 if (ValidatedOperand.isPoison())
2768 return ValidatedOperand;
2770 APFloat FOperand = handleDenormal(ValidatedOperand.asFloat(),
2771 DenormMode.
Input,
true);
2775 FOperand.
convert(DstSem,
Ctx.getCurrentRoundingMode(), &LosesInfo);
2777 if (
auto ValidateRes = handleFMFFlags(FOperand, FMF,
false);
2778 ValidateRes.isPoison())
2781 FOperand = handleDenormal(std::move(FOperand), DenormMode.
Output,
true);
2783 return AnyValue(applyNaNPropagation(FOperand, {&SourceNaN}));
2802 APSInt Res(
I.getType()->getScalarSizeInBits(), IsUnsigned);
2824 I.getType()->getScalarType()->getFltSemantics();
2839 Ctx.getCurrentRoundingMode());
2842 return handleFMFFlags(Res, FMF,
true);
2868 if (
RHS.uge(
LHS.getBitWidth()))
2870 if (
I.hasNoSignedWrap() &&
RHS.uge(
LHS.getNumSignBits()))
2872 if (
I.hasNoUnsignedWrap() &&
RHS.ugt(
LHS.countl_zero()))
2880 if (
RHS.uge(
LHS.getBitWidth()) ||
2882 RHS.ugt(
LHS.countr_zero())))
2890 if (
RHS.uge(
LHS.getBitWidth()) ||
2892 RHS.ugt(
LHS.countr_zero())))
2899 Type *
OpTy =
I.getOperand(0)->getType();
2900 unsigned AddrWidth =
2901 OpTy->isPtrOrPtrVectorTy() ? DL.getAddressSizeInBits(
OpTy) : 0;
2903 if (
LHS.isPoison() ||
RHS.isPoison())
2905 const APInt &LHSVal =
LHS.isPointer()
2906 ?
LHS.asPointer().address().trunc(AddrWidth)
2908 const APInt &RHSVal =
RHS.isPointer()
2909 ?
RHS.asPointer().address().trunc(AddrWidth)
2920 getCurrentDenormalMode(
I.getOperand(0)->getType());
2924 if (
LHS.isPoison() ||
RHS.isPoison())
2927 if (
auto ValidateRes = handleFMFFlags(
LHS, FMF,
true);
2928 ValidateRes.isPoison())
2930 if (
auto ValidateRes = handleFMFFlags(
RHS, FMF,
true);
2931 ValidateRes.isPoison())
2935 handleDenormal(
LHS.asFloat(), DenormMode.
Input,
true);
2937 handleDenormal(
RHS.asFloat(), DenormMode.
Input,
true);
2965 std::vector<AnyValue> ResVec;
2966 size_t Len =
Cond.size();
2967 ResVec.reserve(Len);
2969 switch (
Cond[
I].asBoolean()) {
2971 ResVec.push_back(TV[
I]);
2974 ResVec.push_back(FV[
I]);
2986 Res = handleFMFFlags(std::move(Res), FMF,
true);
2992 getValue(
SI.getTrueValue()),
2993 getValue(
SI.getFalseValue()),
SI.getType(),
2994 SI.getFastMathFlagsOrNone()));
3001 if (
Size.isPoison()) {
3005 if (
Size.asInteger().getActiveBits() > 64) {
3007 <<
"Alloca with large array size that overflows uint64_t. Size: "
3008 <<
Size.asInteger();
3011 bool Overflowed =
false;
3016 <<
"Alloca with allocation size that overflows uint64_t. Size: "
3017 <<
Size.asInteger();
3023 <<
"Alloca with allocation size that exceeds the maximum object "
3030 return match(U, m_Intrinsic<Intrinsic::lifetime_start>());
3042 setResult(AI,
Ctx.deriveFromMemoryObject(Obj));
3053 unsigned BitWidth =
I.getType()->getScalarSizeInBits();
3057 Ctx.exposeProvenance(
V.asPointer().provenance());
3058 return V.asPointer().address().zextOrTrunc(
BitWidth);
3066 auto Prov =
Ctx.getWildcardProvenance();
3068 return Pointer(std::move(Prov),
3069 V.asInteger().zextOrTrunc(DL.getPointerSizeInBits(
3070 I.getType()->getPointerAddressSpace())));
3075 unsigned BitWidth =
I.getType()->getScalarSizeInBits();
3079 return V.asPointer().address().trunc(
BitWidth);
3088 setResult(LI, std::move(RetVal));
3092 auto &Ptr = getValue(
SI.getPointerOperand());
3093 auto &Val = getValue(
SI.getValueOperand());
3096 store(Ptr,
SI.getAlign(), Val,
SI.getValueOperand()->getType());
3102 Handler.onUnrecognizedInstruction(
I);
3109 for (
unsigned Idx : EVI.
indices())
3111 setResult(EVI, *Pos);
3117 for (
unsigned Idx : IVI.
indices())
3120 setResult(IVI, std::move(Res));
3125 auto &ResVec = Res.asAggregate();
3127 if (Idx.isPoison() || Idx.asInteger().uge(ResVec.size())) {
3131 ResVec[Idx.asInteger().getZExtValue()] = getValue(IEI.
getOperand(1));
3132 setResult(IEI, std::move(Res));
3136 auto &SrcVec = getValue(EEI.
getOperand(0)).asAggregate();
3138 if (Idx.isPoison() || Idx.asInteger().uge(SrcVec.size())) {
3142 setResult(EEI, SrcVec[Idx.asInteger().getZExtValue()]);
3146 auto &LHSVec = getValue(SVI.
getOperand(0)).asAggregate();
3147 auto &RHSVec = getValue(SVI.
getOperand(1)).asAggregate();
3150 .getKnownMinValue();
3151 std::vector<AnyValue> Res;
3153 Res.reserve(DstLen);
3162 else if (Idx <
static_cast<int>(
Size))
3163 Res.push_back(LHSVec[Idx]);
3165 Res.push_back(RHSVec[Idx -
Size]);
3168 setResult(SVI, std::move(Res));
3179 setResult(BCI,
Ctx.fromBytes(Bytes, BCI.
getType()));
3185 uint64_t NumBits = DL.getTypeSizeInBits(ValTy).getFixedValue();
3195 Ctx.insertBits(Res, OffsetInBits, Val, ValTy);
3202 uint64_t NumBits = DL.getTypeSizeInBits(Ty).getFixedValue();
3211 return Ctx.extractBits(Bytes, OffsetInBits, Ty);
3218 setResult(FI, std::move(Val));
3228 Frame &Top = CallStack.back();
3234 "Expected to return from a callee.");
3242 "Expected to be in running state.");
3243 if (MaxSteps != 0 && Steps >= MaxSteps) {
3244 reportError() <<
"Exceeded maximum number of execution steps.";
3251 Ctx.resetNoncacheableConstantBuffer();
3262 if (!
I.isTerminator())
3271 "Expected return value to be set on function exit.");
3276 CallStack.pop_back();
3279 "Expected to enter a callee.");
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Mark last scratch load
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool isZero(Value *V, const DataLayout &DL, DominatorTree *DT, AssumptionCache *AC)
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
uint64_t IntrinsicInst * II
SmallVector< MachineOperand, 4 > Cond
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
This file defines the SmallVector class.
static SymbolRef::Type getType(const Symbol *Sym)
static constexpr roundingMode rmTowardZero
static constexpr roundingMode rmNearestTiesToEven
opStatus
IEEE-754R 7: Default exception handling.
static APFloat getQNaN(const fltSemantics &Sem, bool Negative=false, const APInt *payload=nullptr)
Factory for QNaN values.
opStatus divide(const APFloat &RHS, roundingMode RM)
void copySign(const APFloat &RHS)
LLVM_ABI opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
opStatus subtract(const APFloat &RHS, roundingMode RM)
bool bitwiseIsEqual(const APFloat &RHS) const
opStatus add(const APFloat &RHS, roundingMode RM)
const fltSemantics & getSemantics() const
APFloat makeQuiet() const
Assuming this is an IEEE-754 NaN value, quiet its signaling bit.
opStatus convertFromAPInt(const APInt &Input, bool IsSigned, roundingMode RM)
opStatus multiply(const APFloat &RHS, roundingMode RM)
opStatus fusedMultiplyAdd(const APFloat &Multiplicand, const APFloat &Addend, roundingMode RM)
opStatus convertToInteger(MutableArrayRef< integerPart > Input, unsigned int Width, bool IsSigned, roundingMode RM, bool *IsExact) const
opStatus mod(const APFloat &RHS)
static APFloat getZero(const fltSemantics &Sem, bool Negative=false)
Factory for Positive and Negative Zero.
Class for arbitrary precision integers.
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
static LLVM_ABI void udivrem(const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder)
Dual division/remainder interface.
LLVM_ABI APInt zext(unsigned width) const
Zero extend to a new width.
bool isMinSignedValue() const
Determine if this is the smallest signed value.
uint64_t getZExtValue() const
Get zero extended value.
static LLVM_ABI void sdivrem(const APInt &LHS, const APInt &RHS, APInt &Quotient, APInt &Remainder)
unsigned popcount() const
Count the number of bits set.
LLVM_ABI APInt zextOrTrunc(unsigned width) const
Zero extend or truncate to width.
unsigned getActiveBits() const
Compute the number of active bits in the value.
LLVM_ABI APInt trunc(unsigned width) const
Truncate to new width.
APInt abs() const
Get the absolute value.
bool isAllOnes() const
Determine if all bits are set. This is true for zero-width values.
bool ugt(const APInt &RHS) const
Unsigned greater than comparison.
bool isZero() const
Determine if this value is zero, i.e. all bits are clear.
LLVM_ABI APInt urem(const APInt &RHS) const
Unsigned remainder operation.
unsigned getBitWidth() const
Return the number of bits in the APInt.
bool ult(const APInt &RHS) const
Unsigned less than comparison.
unsigned getNumWords() const
Get the number of words.
bool isNegative() const
Determine sign of this APInt.
LLVM_ABI APInt reverseBits() const
unsigned countr_zero() const
Count the number of trailing zero bits.
unsigned countl_zero() const
The APInt version of std::countl_zero.
unsigned getSignificantBits() const
Get the minimum bit size for this signed APInt.
uint64_t getLimitedValue(uint64_t Limit=UINT64_MAX) const
If this value is smaller than the specified limit, return it, otherwise return the limit value.
LLVM_ABI APInt uadd_sat(const APInt &RHS) const
bool isNonNegative() const
Determine if this APInt Value is non-negative (>= 0)
LLVM_ABI APInt sext(unsigned width) const
Sign extend to a new width.
APInt shl(unsigned shiftAmt) const
Left-shift function.
LLVM_ABI APInt byteSwap() const
static APInt getZero(unsigned numBits)
Get the '0' value for the specified bit-width.
bool isIntN(unsigned N) const
Check if this APInt has an N-bits unsigned integer value.
APInt lshr(unsigned shiftAmt) const
Logical right-shift function.
An arbitrary precision integer that knows its signedness.
an instruction to allocate memory on the stack
LLVM_ABI TypeSize getAllocationBaseSize(const DataLayout &DL) const
Get the size of the allocated type.
unsigned getAddressSpace() const
Return the address space for the allocation.
LLVM_ABI bool isArrayAllocation() const
Return true if there is an allocation size parameter to the allocation instruction that is not 1.
const Value * getArraySize() const
Get the number of elements allocated.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > take_front(size_t N=1) const
Return a copy of *this with only the first N elements.
size_t size() const
Get the array size.
bool empty() const
Check if the array is empty.
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
This class holds the attributes for a particular argument, parameter, function, or return value.
LLVM_ABI Type * getByValType() const
bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists in this set.
LLVM_ABI Attribute getAttribute(Attribute::AttrKind Kind) const
Return the attribute object.
LLVM_ABI uint64_t getDereferenceableBytes() const
LLVM_ABI MaybeAlign getAlignment() const
LLVM_ABI uint64_t getDereferenceableOrNullBytes() const
bool isValid() const
Return true if the attribute is any kind of attribute.
LLVM Basic Block Representation.
iterator begin()
Instruction iterator methods.
This class represents a no-op cast from one type to another.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
OperandBundleUse getOperandBundleAt(unsigned Index) const
Return the operand bundle at a specific index.
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
AttributeSet getParamAttributes(unsigned ArgNo) const
Return the param attributes for this call.
unsigned getNumOperandBundles() const
Return the number of operand bundles associated with this User.
CallingConv::ID getCallingConv() const
AttributeSet getRetAttributes() const
Return the return attributes for this call.
Value * getCalledOperand() const
Value * getArgOperand(unsigned i) const
FunctionType * getFunctionType() const
LLVM_ABI Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
bool doesNotReturn() const
Determine if the call cannot return.
LLVM_ABI bool isTailCall() const
Tests if this call site is marked as a tail call.
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
BasicBlock * getDefaultDest() const
This class represents a function call, abstracting a target machine's calling convention.
Type * getDestTy() const
Return the destination type, as a convenience.
Conditional Branch instruction.
Value * getCondition() const
BasicBlock * getSuccessor(unsigned i) const
This class represents a range of values.
LLVM_ABI bool contains(const APInt &Val) const
Return true if the specified value is in the set.
A parsed version of the target data layout string in and methods for querying it.
This instruction compares its operands according to the predicate given to the constructor.
static LLVM_ABI bool compare(const APFloat &LHS, const APFloat &RHS, FCmpInst::Predicate Pred)
Return result of LHS Pred RHS comparison.
This class represents an extension of floating point types.
This class represents a cast from floating point to signed integer.
This class represents a cast from floating point to unsigned integer.
This class represents a truncation of floating point types.
Convenience struct for specifying and reasoning about fast-math flags.
bool noSignedZeros() const
void setNoSignedZeros(bool B=true)
static LLVM_ABI FixedVectorType * get(Type *ElementType, unsigned NumElts)
This class represents a freeze function that returns random concrete value if an operand is either a ...
Type * getReturnType() const
Returns the type of the ret val.
Represents flags for the getelementptr instruction/expression.
static GEPNoWrapFlags inBounds()
static GEPNoWrapFlags all()
static GEPNoWrapFlags none()
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
This instruction compares its operands according to the predicate given to the constructor.
static LLVM_ABI bool compare(const APInt &LHS, const APInt &RHS, ICmpInst::Predicate Pred)
Return result of LHS Pred RHS comparison.
Indirect Branch Instruction.
iterator_range< succ_iterator > successors()
This instruction inserts a single (scalar) element into a VectorType value.
VectorType * getType() const
Overload to return most specific vector type.
This instruction inserts a struct field of array element value into an aggregate value.
Value * getInsertedValueOperand()
Value * getAggregateOperand()
iterator_range< idx_iterator > indices() const
Base class for instruction visitors.
void visit(Iterator Start, Iterator End)
LLVM_ABI FastMathFlags getFastMathFlagsOrNone() const LLVM_READONLY
Convenience function for getting fast-math flags, or default-constructed FastMathFlags when not a FPM...
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
LLVM_ABI bool hasNonNeg() const LLVM_READONLY
Determine whether the the nneg flag is set.
iterator_range< user_iterator > users()
This class represents a cast from an integer to a pointer.
An instruction for reading from memory.
Value * getPointerOperand()
Align getAlign() const
Return the alignment of the access that is being performed.
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
This class represents a cast from a pointer to an address (non-capturing ptrtoint).
This class represents a cast from a pointer to an integer.
Return a value (possibly void), from a function.
Value * getReturnValue() const
Convenience accessor. Returns null if there is no return value.
This class represents a sign extension of integer types.
This class represents a cast from signed integer to floating point.
This class represents the LLVM 'select' instruction.
This instruction constructs a fixed permutation of two input vectors.
VectorType * getType() const
Overload to return most specific vector type.
static LLVM_ABI void getShuffleMask(const Constant *Mask, SmallVectorImpl< int > &Result)
Convert the input shuffle mask operand to a vector of integers.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void reserve(size_type N)
iterator erase(const_iterator CI)
void push_back(const T &Elt)
LLVM_NO_SANITIZE_CFI_UNRELATED_CAST iterator begin()
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
Represent a constant reference to a string, i.e.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
This class represents a truncation of integer types.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM_ABI unsigned getIntegerBitWidth() const
bool isPointerTy() const
True if this is an instance of PointerType.
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
bool isVoidTy() const
Return true if this is 'void'.
This class represents a cast unsigned integer to floating point.
Unconditional Branch instruction.
BasicBlock * getSuccessor(unsigned i=0) const
This function has undefined behavior.
Value * getOperand(unsigned i) const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI Align getPointerAlignment(const DataLayout &DL) const
Returns an alignment of the pointer value.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
This class represents zero extension of integer types.
An efficient, type-erasing, non-owning reference to a callable.
static LLVM_ABI AnyValue getPoisonValue(Context &Ctx, Type *Ty)
static AnyValue poison()
Use getPoisonValue unless you know the scalar type is integer/fp/ptr!
static AnyValue boolean(bool Val)
const Pointer & asPointer() const
BooleanKind asBoolean() const
const APInt & asInteger() const
const APFloat & asFloat() const
const std::vector< AnyValue > & asAggregate() const
Represents a scalar byte value.
uint32_t getBitWidth() const
The global context for the interpreter.
LLVM_ABI ProgramExitInfo runFunction(Function &F, ArrayRef< AnyValue > Args, AnyValue &RetVal, EventHandler &Handler)
Execute the function F with arguments Args, and store the return value in RetVal if the function is n...
static LLVM_ABI AnyValue canonicalizeIndex(const AnyValue &Idx, unsigned IndexBitWidth, GEPNoWrapFlags Flags)
Sign extends or truncates the GEP index Idx to IndexBitWidth bits.
An interface for handling events and managing outputs during interpretation.
DiagnosticReporter reportError()
std::pair< MemoryObject *, uint64_t > verifyMemAccess(const Pointer &Ptr, uint64_t AccessSize, Align Alignment, bool IsStore)
Check if the upcoming memory access is valid.
void executeMemSet(const AnyValue &Dest, const AnyValue &Val, const AnyValue &Length)
Fill Length bytes at Dest with Val.
ExecutorBase(Context &C, EventHandler &H)
bool hasProgramExited() const
std::optional< ProgramExitInfo > ExitInfo
std::optional< ProgramExitInfo > getExitInfo() const
void requestProgramExit(ProgramExitInfo::ProgramExitKind Kind, uint64_t ExitCode=0)
DiagnosticReporter reportImmediateUB()
void store(const AnyValue &Ptr, Align Alignment, const AnyValue &Val, Type *ValTy)
void executeMemTransfer(const AnyValue &Dest, const AnyValue &Src, const AnyValue &Length, Intrinsic::ID IID, bool IsLibCall)
Copy Length bytes from Src to Dest according to the intrinsic IID.
Instruction executor using the visitor pattern.
void visitAShr(BinaryOperator &I)
void visitCallInst(CallInst &CI)
void visitLoadInst(LoadInst &LI)
void visitFAdd(BinaryOperator &I)
void visitZExtInst(ZExtInst &ZExt)
void visitReturnInst(ReturnInst &RI)
void visitFPToSIInst(FPToSIInst &FPToSI)
void visitSub(BinaryOperator &I)
void visitBitInsertInst(BitInsertInst &BII)
AnyValue callIntrinsic(CallBase &CB, ArrayRef< AnyValue > Args)
AnyValue computeSelect(const AnyValue &CondVal, const AnyValue &TVVal, const AnyValue &FVVal, Type *Ty, FastMathFlags FMF)
Computes select CondVal, TVVal, FVVal of type Ty with fast-math flags FMF.
void visitURem(BinaryOperator &I)
void visitSRem(BinaryOperator &I)
void visitFPToIntInst(Instruction &I, bool IsUnsigned)
void visitFPConvInst(Instruction &I)
AnyValue countTrailingZeroElements(Type *RetTy, ArrayRef< AnyValue > Vec, bool IsZeroPoison, size_t Length)
void visitIndirectBrInst(IndirectBrInst &IBI)
void visitOr(BinaryOperator &I)
void visitShuffleVectorInst(ShuffleVectorInst &SVI)
void visitPtrToInt(PtrToIntInst &I)
void visitUncondBrInst(UncondBrInst &BI)
void visitInsertValueInst(InsertValueInst &IVI)
void setFrameStackInaccessible(Frame &F, bool Inaccessible)
void visitSExtInst(SExtInst &SExt)
void visitStoreInst(StoreInst &SI)
void visitShl(BinaryOperator &I)
AnyValue computeDivRem(unsigned Opcode, const AnyValue &LHS, const AnyValue &RHS, bool IsExact=false)
void visitTruncInst(TruncInst &Trunc)
void visitUDiv(BinaryOperator &I)
void visitInvokeInst(InvokeInst &II)
void visitPtrToAddr(PtrToAddrInst &I)
void visitAllocaInst(AllocaInst &AI)
InstExecutor(Context &C, EventHandler &H, Function &F, ArrayRef< AnyValue > Args, AnyValue &RetVal)
void visitIntToPtr(IntToPtrInst &I)
void visitFDiv(BinaryOperator &I)
void visitXor(BinaryOperator &I)
void visitUIToFPInst(UIToFPInst &UIToFP)
void visitBitCastInst(BitCastInst &BCI)
AnyValue callLibFunc(CallBase &CB, Function *ResolvedCallee, ArrayRef< AnyValue > CalleeArgs)
void visitCondBrInst(CondBrInst &BI)
void visitGetElementPtrInst(GetElementPtrInst &GEP)
void handleMetadata(Type *Ty, AnyValue &V, Instruction &I)
Handle both poison-generating and UB-implying metadata on instructions.
void visitFreezeInst(FreezeInst &FI)
void visitBitExtractInst(BitExtractInst &BEI)
void visitSIToFPInst(SIToFPInst &SIToFP)
void visitSelect(SelectInst &SI)
void visitFCmpInst(FCmpInst &I)
void visitAnd(BinaryOperator &I)
void visitFPExtInst(FPExtInst &FPExt)
void visitLShr(BinaryOperator &I)
void visitAdd(BinaryOperator &I)
void visitExtractValueInst(ExtractValueInst &EVI)
void visitIntToFPInst(Instruction &I, bool IsSigned)
void visitFRem(BinaryOperator &I)
void visitCallBrInst(CallBrInst &CI)
void visitFSub(BinaryOperator &I)
void visitSDiv(BinaryOperator &I)
void handleAttributes(Type *Ty, AnyValue &V, AttributeSet AttrsAtCallSite, AttributeSet AttrsAtCallee)
Handle both poison-generating and UB-implying attributes for parameters and return values.
void visitFPTruncInst(FPTruncInst &FPTrunc)
void visitInstruction(Instruction &I)
void visitFPToUIInst(FPToUIInst &FPToUI)
void enterCall(CallBase &CB)
void visitInsertElementInst(InsertElementInst &IEI)
void visitMul(BinaryOperator &I)
void visitSwitchInst(SwitchInst &SI)
ProgramExitInfo runMainLoop()
This function implements the main interpreter loop.
void visitFMul(BinaryOperator &I)
AnyValue callVectorReduction(Type *RetTy, FastMathFlags FMF, Intrinsic::ID IID, ArrayRef< AnyValue > Args)
void visitICmpInst(ICmpInst &I)
void visitExtractElementInst(ExtractElementInst &EEI)
void visitUnreachableInst(UnreachableInst &)
void visitFNeg(UnaryOperator &I)
const APInt & address() const
Pointer getWithNewAddr(const APInt &NewAddr) const
LLVM_ABI bool isNullPtr(unsigned AS, const DataLayout &DL) const
Components of a pointer excluding address.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ABI APInt mulhu(const APInt &C1, const APInt &C2)
Performs (2*N)-bit multiplication on zero-extended operands.
LLVM_ABI APInt RoundingUDiv(const APInt &A, const APInt &B, APInt::Rounding RM)
Return A unsign-divided by B, rounded by the given rounding mode.
LLVM_ABI APInt pext(const APInt &Val, const APInt &Mask)
Perform a "compress" operation, also known as pext or bext.
LLVM_ABI APInt mulhs(const APInt &C1, const APInt &C2)
Performs (2*N)-bit multiplication on sign-extended operands.
const APInt & smin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be signed.
const APInt & smax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be signed.
LLVM_ABI APInt clmul(const APInt &LHS, const APInt &RHS)
Perform a carry-less multiply, also known as XOR multiplication, and return low-bits.
const APInt & umin(const APInt &A, const APInt &B)
Determine the smaller of two APInts considered to be unsigned.
LLVM_ABI APInt pdep(const APInt &Val, const APInt &Mask)
Perform an "expand" operation, also known as pdep or bdep.
const APInt & umax(const APInt &A, const APInt &B)
Determine the larger of two APInts considered to be unsigned.
LLVM_ABI StringRef getBaseName(ID id)
Return the LLVM name for an intrinsic, without encoded types for overloading, such as "llvm....
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
static void applyNoFPClassAttr(AnyValue &V, FPClassTest NoFPClass)
BooleanKind
Tri-state boolean value.
static void applyAlignAttr(AnyValue &V, Align Alignment)
static bool violatesDereferenceableBytesAttr(const AnyValue &V, uint64_t Bytes, bool OrNull, unsigned AS, Context &Ctx)
Assumes V is either a poison or a pointer.
static void applyNonNullAttr(AnyValue &V, unsigned AS, const DataLayout &DL)
AnyValue addNoWrap(const APInt &LHS, const APInt &RHS, bool HasNSW, bool HasNUW)
AnyValue subNoWrap(const APInt &LHS, const APInt &RHS, bool HasNSW, bool HasNUW)
static void forEachScalarValue(AnyValue &V, function_ref< void(AnyValue &)> Visit)
Visit the scalar values recursively.
static void applyRangeAttr(AnyValue &V, const ConstantRange &CR)
static bool violatesNoUndefAttr(const AnyValue &V)
AnyValue mulNoWrap(const APInt &LHS, const APInt &RHS, bool HasNSW, bool HasNUW)
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
detail::zippy< detail::zip_shortest, T, U, Args... > zip(T &&t, U &&u, Args &&...args)
zip iterator for two or more iteratable types.
void fill(R &&Range, T &&Value)
Provide wrappers to std::fill which take ranges instead of having to pass begin/end explicitly.
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
detail::zippy< detail::zip_first, T, U, Args... > zip_equal(T &&t, U &&u, Args &&...args)
zip iterator that assumes that all iteratees have the same length.
BundleAttr getBundleAttrFromOBU(OperandBundleUse OBU)
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
APFloat abs(APFloat X)
Returns the absolute value of the argument.
LLVM_READONLY APFloat maximum(const APFloat &A, const APFloat &B)
Implements IEEE 754-2019 maximum semantics.
constexpr bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
OutputIt transform(R &&Range, OutputIt d_first, UnaryFunction F)
Wrapper function around std::transform to apply a function to a range and store the result elsewhere.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
LLVM_READONLY APFloat maxnum(const APFloat &A, const APFloat &B)
Implements IEEE-754 2008 maxNum semantics.
LLVM_READONLY APFloat minimumnum(const APFloat &A, const APFloat &B)
Implements IEEE 754-2019 minimumNumber semantics.
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
LLVM_ABI unsigned getDeinterleaveIntrinsicFactor(Intrinsic::ID ID)
Returns the corresponding factor of llvm.vector.deinterleaveN intrinsics.
LLVM_ABI unsigned getInterleaveIntrinsicFactor(Intrinsic::ID ID)
Returns the corresponding factor of llvm.vector.interleaveN intrinsics.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
constexpr int PoisonMaskElem
LLVM_READONLY APFloat minnum(const APFloat &A, const APFloat &B)
Implements IEEE-754 2008 minNum semantics.
std::enable_if_t< std::is_unsigned_v< T >, T > SaturatingMultiply(T X, T Y, bool *ResultOverflowed=nullptr)
Multiply two unsigned integers, X and Y, of type T.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
DWARFExpression::Operation Op
@ NearestTiesToEven
roundTiesToEven.
OutputIt copy(R &&Range, OutputIt Out)
constexpr unsigned BitWidth
auto count_if(R &&Range, UnaryPredicate P)
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
constexpr bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
unsigned Log2(Align A)
Returns the log2 of the alignment.
LLVM_READONLY APFloat minimum(const APFloat &A, const APFloat &B)
Implements IEEE 754-2019 minimum semantics.
LLVM_READONLY APFloat maximumnum(const APFloat &A, const APFloat &B)
Implements IEEE 754-2019 maximumNumber semantics.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
This struct is a compact representation of a valid (non-zero power of two) alignment.
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
Represent subnormal handling kind for floating point instruction inputs and outputs.
DenormalModeKind Input
Denormal treatment kind for floating point instruction inputs in the default floating-point environme...
DenormalModeKind
Represent handled modes for denormal (aka subnormal) modes in the floating point environment.
@ PreserveSign
The sign of a flushed-to-zero number is preserved in the sign of 0.
@ PositiveZero
Denormals are flushed to positive zero.
DenormalModeKind Output
Denormal flushing mode for floating point instruction results in the default floating point environme...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Align valueOrOne() const
For convenience, returns a valid alignment or 1 if undefined.
A lightweight accessor for an operand bundle meant to be passed around by value.
Representation of a byte in memory.
static Byte concrete(uint8_t Val)
Context for a function call.
ArrayRef< AnyValue > Args
SmallVector< IntrusiveRefCntPtr< MemoryObject > > Allocas