llvm/llvm/unittests/Analysis/ValueTrackingTest.cpp

//===- ValueTrackingTest.cpp - ValueTracking tests ------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "llvm/Analysis/ValueTracking.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/AsmParser/Parser.h"
#include "llvm/IR/ConstantRange.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/KnownBits.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Transforms/Utils/Local.h"
#include "gtest/gtest.h"

usingnamespacellvm;

namespace {

static Instruction *findInstructionByNameOrNull(Function *F, StringRef Name) {}

static Instruction &findInstructionByName(Function *F, StringRef Name) {}

class ValueTrackingTest : public testing::Test {};

class MatchSelectPatternTest : public ValueTrackingTest {};

class ComputeKnownBitsTest : public ValueTrackingTest {};

class ComputeKnownFPClassTest : public ValueTrackingTest {};
}

TEST_F(MatchSelectPatternTest, SimpleFMin) {}

TEST_F(MatchSelectPatternTest, SimpleFMax) {}

TEST_F(MatchSelectPatternTest, SwappedFMax) {}

TEST_F(MatchSelectPatternTest, SwappedFMax2) {}

TEST_F(MatchSelectPatternTest, SwappedFMax3) {}

TEST_F(MatchSelectPatternTest, FastFMin) {}

TEST_F(MatchSelectPatternTest, FMinConstantZero) {}

TEST_F(MatchSelectPatternTest, FMinConstantZeroNsz) {}

TEST_F(MatchSelectPatternTest, FMinMismatchConstantZero1) {}

TEST_F(MatchSelectPatternTest, FMinMismatchConstantZero2) {}

TEST_F(MatchSelectPatternTest, FMinMismatchConstantZero3) {}

TEST_F(MatchSelectPatternTest, FMinMismatchConstantZero4) {}

TEST_F(MatchSelectPatternTest, FMinMismatchConstantZero5) {}

TEST_F(MatchSelectPatternTest, FMinMismatchConstantZero6) {}

TEST_F(MatchSelectPatternTest, FMinMismatchConstantZero7) {}

TEST_F(MatchSelectPatternTest, FMinMismatchConstantZero8) {}

TEST_F(MatchSelectPatternTest, FMaxMismatchConstantZero1) {}

TEST_F(MatchSelectPatternTest, FMaxMismatchConstantZero2) {}

TEST_F(MatchSelectPatternTest, FMaxMismatchConstantZero3) {}

TEST_F(MatchSelectPatternTest, FMaxMismatchConstantZero4) {}

TEST_F(MatchSelectPatternTest, FMaxMismatchConstantZero5) {}

TEST_F(MatchSelectPatternTest, FMaxMismatchConstantZero6) {}

TEST_F(MatchSelectPatternTest, FMaxMismatchConstantZero7) {}

TEST_F(MatchSelectPatternTest, FMaxMismatchConstantZero8) {}

TEST_F(MatchSelectPatternTest, FMinMismatchConstantZeroVecUndef) {}

TEST_F(MatchSelectPatternTest, FMaxMismatchConstantZeroVecUndef) {}

TEST_F(MatchSelectPatternTest, VectorFMinimum) {}

TEST_F(MatchSelectPatternTest, VectorFMinOtherOrdered) {}

TEST_F(MatchSelectPatternTest, VectorNotFMinimum) {}

TEST_F(MatchSelectPatternTest, VectorNotFMinZero) {}

TEST_F(MatchSelectPatternTest, DoubleCastU) {}

TEST_F(MatchSelectPatternTest, DoubleCastS) {}

TEST_F(MatchSelectPatternTest, DoubleCastBad) {}

TEST_F(MatchSelectPatternTest, NotNotSMin) {}

TEST_F(MatchSelectPatternTest, NotNotSMinSwap) {}

TEST_F(MatchSelectPatternTest, NotNotSMax) {}

TEST_F(MatchSelectPatternTest, NotNotSMaxSwap) {}

TEST_F(MatchSelectPatternTest, NotNotUMin) {}

TEST_F(MatchSelectPatternTest, NotNotUMinSwap) {}

TEST_F(MatchSelectPatternTest, NotNotUMax) {}

TEST_F(MatchSelectPatternTest, NotNotUMaxSwap) {}

TEST_F(MatchSelectPatternTest, NotNotEq) {}

TEST_F(MatchSelectPatternTest, NotNotNe) {}

TEST(ValueTracking, GuaranteedToTransferExecutionToSuccessor) {}

TEST_F(ValueTrackingTest, ComputeNumSignBits_PR32045) {}

// No guarantees for canonical IR in this analysis, so this just bails out.
TEST_F(ValueTrackingTest, ComputeNumSignBits_Shuffle) {}

// No guarantees for canonical IR in this analysis, so a shuffle element that
// references an undef value means this can't return any extra information.
TEST_F(ValueTrackingTest, ComputeNumSignBits_Shuffle2) {}

TEST_F(ValueTrackingTest, impliesPoisonTest_Identity) {}

TEST_F(ValueTrackingTest, impliesPoisonTest_ICmp) {}

TEST_F(ValueTrackingTest, impliesPoisonTest_ICmpUnknown) {}

TEST_F(ValueTrackingTest, impliesPoisonTest_AddNswOkay) {}

TEST_F(ValueTrackingTest, impliesPoisonTest_AddNswOkay2) {}

TEST_F(ValueTrackingTest, impliesPoisonTest_AddNsw) {}

TEST_F(ValueTrackingTest, impliesPoisonTest_Cmp) {}

TEST_F(ValueTrackingTest, impliesPoisonTest_FCmpFMF) {}

TEST_F(ValueTrackingTest, impliesPoisonTest_AddSubSameOps) {}

TEST_F(ValueTrackingTest, impliesPoisonTest_MaskCmp) {}

TEST_F(ValueTrackingTest, ComputeNumSignBits_Shuffle_Pointers) {}

TEST(ValueTracking, propagatesPoison) {}

TEST_F(ValueTrackingTest, programUndefinedIfPoison) {}

TEST_F(ValueTrackingTest, programUndefinedIfPoisonSelect) {}

TEST_F(ValueTrackingTest, programUndefinedIfUndefOrPoison) {}

TEST_F(ValueTrackingTest, isGuaranteedNotToBePoison_exploitBranchCond) {}

TEST_F(ValueTrackingTest, isGuaranteedNotToBePoison_phi) {}

TEST_F(ValueTrackingTest, isGuaranteedNotToBeUndefOrPoison) {}

TEST_F(ValueTrackingTest, isGuaranteedNotToBeUndefOrPoison_assume) {}

TEST(ValueTracking, canCreatePoisonOrUndef) {}

TEST_F(ValueTrackingTest, computePtrAlignment) {}

TEST_F(ComputeKnownBitsTest, ComputeKnownBits) {}

TEST_F(ComputeKnownBitsTest, ComputeKnownMulBits) {}

TEST_F(ComputeKnownFPClassTest, SelectPos0) {}

TEST_F(ComputeKnownFPClassTest, SelectNeg0) {}

TEST_F(ComputeKnownFPClassTest, SelectPosOrNeg0) {}

TEST_F(ComputeKnownFPClassTest, SelectPosInf) {}

TEST_F(ComputeKnownFPClassTest, SelectNegInf) {}

TEST_F(ComputeKnownFPClassTest, SelectPosOrNegInf) {}

TEST_F(ComputeKnownFPClassTest, SelectNNaN) {}

TEST_F(ComputeKnownFPClassTest, SelectNInf) {}

TEST_F(ComputeKnownFPClassTest, SelectNNaNNInf) {}

TEST_F(ComputeKnownFPClassTest, SelectNoFPClassArgUnionAll) {}

TEST_F(ComputeKnownFPClassTest, SelectNoFPClassArgNoNan) {}

TEST_F(ComputeKnownFPClassTest, SelectNoFPClassArgNoPInf) {}

TEST_F(ComputeKnownFPClassTest, SelectNoFPClassArgNoNInf) {}

TEST_F(ComputeKnownFPClassTest, SelectNoFPClassCallSiteNoNan) {}

TEST_F(ComputeKnownFPClassTest, SelectNoFPClassCallSiteNoZeros) {}

TEST_F(ComputeKnownFPClassTest, SelectNoFPClassDeclarationNoNan) {}

// Check nofpclass + ninf works on a callsite
TEST_F(ComputeKnownFPClassTest, SelectNoFPClassCallSiteNoZerosNInfFlags) {}

TEST_F(ComputeKnownFPClassTest, FNegNInf) {}

TEST_F(ComputeKnownFPClassTest, FabsUnknown) {}

TEST_F(ComputeKnownFPClassTest, FNegFabsUnknown) {}

TEST_F(ComputeKnownFPClassTest, NegFabsNInf) {}

TEST_F(ComputeKnownFPClassTest, FNegFabsNNaN) {}

TEST_F(ComputeKnownFPClassTest, CopySignNNanSrc0) {}

TEST_F(ComputeKnownFPClassTest, CopySignNInfSrc0_NegSign) {}

TEST_F(ComputeKnownFPClassTest, CopySignNInfSrc0_PosSign) {}

TEST_F(ComputeKnownFPClassTest, UIToFP) {}

TEST_F(ComputeKnownFPClassTest, SIToFP) {}

TEST_F(ComputeKnownFPClassTest, FAdd) {}

TEST_F(ComputeKnownFPClassTest, FSub) {}

TEST_F(ComputeKnownFPClassTest, FMul) {}

TEST_F(ComputeKnownFPClassTest, FMulNoZero) {}

TEST_F(ComputeKnownFPClassTest, Phi) {}

TEST_F(ComputeKnownFPClassTest, PhiKnownSignFalse) {}

TEST_F(ComputeKnownFPClassTest, PhiKnownSignTrue) {}

TEST_F(ComputeKnownFPClassTest, UnreachablePhi) {}

TEST_F(ComputeKnownFPClassTest, SelfPhiOnly) {}

TEST_F(ComputeKnownFPClassTest, SelfPhiFirstArg) {}

TEST_F(ComputeKnownFPClassTest, SelfPhiSecondArg) {}

TEST_F(ComputeKnownFPClassTest, CannotBeOrderedLessThanZero) {}

TEST_F(ComputeKnownFPClassTest, FCmpToClassTest_OrdNan) {}

TEST_F(ComputeKnownFPClassTest, FCmpToClassTest_NInf) {}

TEST_F(ComputeKnownFPClassTest, FCmpToClassTest_FabsNInf) {}

TEST_F(ComputeKnownFPClassTest, FCmpToClassTest_PInf) {}

TEST_F(ComputeKnownFPClassTest, SqrtNszSignBit) {}

TEST_F(ComputeKnownFPClassTest, Constants) {}

TEST_F(ValueTrackingTest, isNonZeroRecurrence) {}

TEST_F(ValueTrackingTest, KnownNonZeroFromDomCond) {}

TEST_F(ValueTrackingTest, KnownNonZeroFromDomCond2) {}

TEST_F(ValueTrackingTest, IsImpliedConditionAnd) {}

TEST_F(ValueTrackingTest, IsImpliedConditionAnd2) {}

TEST_F(ValueTrackingTest, IsImpliedConditionAndVec) {}

TEST_F(ValueTrackingTest, IsImpliedConditionOr) {}

TEST_F(ValueTrackingTest, IsImpliedConditionOr2) {}

TEST_F(ComputeKnownBitsTest, KnownNonZeroShift) {}

TEST_F(ComputeKnownBitsTest, ComputeKnownFshl) {}

TEST_F(ComputeKnownBitsTest, ComputeKnownFshr) {}

TEST_F(ComputeKnownBitsTest, ComputeKnownFshlZero) {}

TEST_F(ComputeKnownBitsTest, ComputeKnownUAddSatLeadingOnes) {}

TEST_F(ComputeKnownBitsTest, ComputeKnownUAddSatOnesPreserved) {}

TEST_F(ComputeKnownBitsTest, ComputeKnownUSubSatLHSLeadingZeros) {}

TEST_F(ComputeKnownBitsTest, ComputeKnownUSubSatRHSLeadingOnes) {}

TEST_F(ComputeKnownBitsTest, ComputeKnownUSubSatZerosPreserved) {}

TEST_F(ComputeKnownBitsTest, ComputeKnownBitsPtrToIntTrunc) {}

TEST_F(ComputeKnownBitsTest, ComputeKnownBitsPtrToIntZext) {}

TEST_F(ComputeKnownBitsTest, ComputeKnownBitsFreeze) {}

TEST_F(ComputeKnownBitsTest, ComputeKnownBitsReturnedRangeConflict) {}

TEST_F(ComputeKnownBitsTest, ComputeKnownBitsAddWithRange) {}

TEST_F(ComputeKnownBitsTest, ComputeKnownBitsUnknownVScale) {}

// 512 + [32, 64) doesn't produce overlapping bits.
// Make sure we get all the individual bits properly.
TEST_F(ComputeKnownBitsTest, ComputeKnownBitsAddWithRangeNoOverlap) {}

TEST_F(ComputeKnownBitsTest, ComputeKnownBitsGEPWithRange) {}

// 4*128 + [32, 64) doesn't produce overlapping bits.
// Make sure we get all the individual bits properly.
// This test is useful to check that we account for the scaling factor
// in the gep. Indeed, gep float, [32,64), 128 is not 128 + [32,64).
TEST_F(ComputeKnownBitsTest, ComputeKnownBitsGEPWithRangeNoOverlap) {}

TEST_F(ComputeKnownBitsTest, ComputeKnownBitsAbsoluteSymbol) {}

TEST_F(ValueTrackingTest, HaveNoCommonBitsSet) {}

class IsBytewiseValueTest : public ValueTrackingTest,
                            public ::testing::WithParamInterface<
                                std::pair<const char *, const char *>> {};

const std::pair<const char *, const char *> IsBytewiseValueTests[] =;

INSTANTIATE_TEST_SUITE_P();

TEST_P(IsBytewiseValueTest, IsBytewiseValue) {}

TEST_F(ValueTrackingTest, ComputeConstantRange) {}

struct FindAllocaForValueTestParams {};

class FindAllocaForValueTest
    : public ValueTrackingTest,
      public ::testing::WithParamInterface<FindAllocaForValueTestParams> {};

const FindAllocaForValueTestParams FindAllocaForValueTests[] =;

TEST_P(FindAllocaForValueTest, findAllocaForValue) {}

TEST_P(FindAllocaForValueTest, findAllocaForValueZeroOffset) {}

INSTANTIATE_TEST_SUITE_P();