Lines Matching refs:Value
37 #include "llvm/IR/Value.h"
60 // Cost threshold measuring when it is profitable to rematerialize value instead
143 DenseMap<BasicBlock *, DenseSet<Value *>> KillSet;
146 DenseMap<BasicBlock *, DenseSet<Value *>> LiveSet;
150 DenseMap<BasicBlock *, DenseSet<Value *>> LiveIn;
154 DenseMap<BasicBlock *, DenseSet<Value *>> LiveOut;
163 // - The base defining value relation (i.e. before base_phi insertion)
167 typedef DenseMap<Value *, Value *> DefiningValueMapTy;
168 typedef DenseSet<Value *> StatepointLiveSetTy;
169 typedef DenseMap<AssertingVH<Instruction>, AssertingVH<Value>>
176 /// Mapping from live pointers to a base-defining-value
177 DenseMap<Value *, Value *> PointerToBase;
189 /// Maps rematerialized copy to it's original value.
218 // Optional<bool> isGCManagedPointer(const Value *V) const override {
230 // pointer and b) is of a type this code expects to encounter as a live value.
269 static bool order_by_name(Value *a, Value *b) {
282 // Return the name of the value suffixed with the provided value, or if the
283 // value didn't have a name, the default value specified.
284 static std::string suffixed_name_or(Value *V, StringRef Suffix,
305 SmallVector<Value *, 64> Temp;
309 for (Value *V : Temp)
319 static bool isKnownBaseResult(Value *V);
321 /// A single base defining value - An immediate base defining value for an
325 /// defining value. The 'base defining value' for 'Def' is the transitive
327 /// immediate base defining value. The b.d.v. might itself be a base pointer,
330 /// Contains the value which is the base defining value.
331 Value * const BDV;
332 /// True if the base defining value is also known to be an actual base
335 BaseDefiningValueResult(Value *BDV, bool IsKnownBase)
347 static BaseDefiningValueResult findBaseDefiningValue(Value *I);
349 /// Return a base defining value for the 'Index' element of the given vector
353 /// the second value in the returned pair will be true. Note that either a
354 /// vector or a pointer typed value can be returned. For the former, the
359 findBaseDefiningValueOfVector(Value *I) {
371 // We shouldn't see the address of a global as a vector value?
408 value. The outer findBasePointer
409 // algorithm is responsible for constructing a base value for this BDV.
415 /// Helper function for findBasePointer - Will return a value which either a)
419 static BaseDefiningValueResult findBaseDefiningValue(Value *I) {
428 // We should have never reached here if this argument isn't an gc value
456 Value *Def = CI->stripPointerCasts();
470 // The value loaded is an gc base itself
528 // tracing back a struct value not a pointer value.
543 // return a value which dynamically selects from among several base
551 /// Returns the base defining value for this value.
552 static Value *findBaseDefiningValueCached(Value *I, DefiningValueMapTy &Cache) {
553 Value *&Cached = Cache[I];
563 /// Return a base pointer for this value if known. Otherwise, return it's
564 /// base defining value.
565 static Value *findBaseOrBDV(Value *I, DefiningValueMapTy &Cache) {
566 Value *Def = findBaseDefiningValueCached(I, Cache);
578 static bool isKnownBaseResult(Value *V) {
588 // that this is a base value.
597 /// Models the state of a single base defining value in the findBasePointer
604 BDVState(Status s, Value *b = nullptr) : status(s), base(b) {
607 explicit BDVState(Value *b) : status(Base), base(b) {}
611 Value *getBase() const { return base; }
644 AssertingVH<Value> base; // non null only if status == base
714 /// For a given value or instruction, figure out what base ptr it's derived
715 /// from. For gc objects, this is simply itself. On success, returns a value
718 static Value *findBasePointer(Value *I, DefiningValueMapTy &cache) {
719 Value *def = findBaseOrBDV(I, cache);
726 // - For every SSA value, construct a mapping to either an actual base
748 auto isExpectedBDVType = [](Value *BDV) {
755 // to a lattice value (described above) which corresponds to that BDV.
759 MapVector<Value *, BDVState> States;
762 // one for which we don't already know a definite base value for
764 SmallVector<Value*, 16> Worklist;
768 Value *Current = Worklist.pop_back_val();
771 auto visitIncomingValue = [&](Value *InVal) {
772 Value *Base = findBaseOrBDV(InVal, cache);
783 for (Value *InVal : Phi->incoming_values())
808 // Return a phi state for a base defining value. We'll generate a new
810 auto getStateForBDV = [&](Value *baseValue) {
829 Value *BDV = Pair.first;
832 // Given an input value for the current instruction, return a BDVState
833 // instance which represents the BDV of that value.
834 auto getStateForInput = [&](Value *V) mutable {
835 Value
844 for (Value *Val : Phi->incoming_values())
943 // Add metadata marking this as a base value
951 // know it's base defining value is a base, or have inserted a new
956 auto getBaseForInput = [&](Value *Input, Instruction *InsertPt) {
957 Value *BDV = findBaseOrBDV(Input, cache);
958 Value *Base = nullptr;
992 Value *InVal = phi->getIncomingValue(i);
995 // If we've already seen InBB, add the same incoming value
998 // to have the same incoming value for each of those
1006 Value *oldBase = basephi->getIncomingValue(blockIndex);
1010 Value *Base = getBaseForInput(InVal, nullptr);
1014 // value. A cleanup that remains TODO is changing
1015 // findBaseOrBDV to return an llvm::Value of the correct
1027 Value *Base = getBaseForInput(InVal, InBB->getTerminator());
1036 Value *InVal = Sel->getOperand(i);
1039 Value *Base = getBaseForInput(InVal, BaseSel);
1043 Value *InVal = cast<ExtractElementInst>(BDV)->getVectorOperand();
1046 Value *Base = getBaseForInput(InVal, BaseEE);
1052 Value *InVal = BdvIE->getOperand(OperandIdx);
1053 Value *Base = getBaseForInput(InVal, BaseIE);
1066 DenseMap<Value *, Value *> ReverseMap;
1076 Value *Base = State.getBase();
1090 auto ReplaceBaseInstWith = [&](Value *BDV, Instruction *BaseI,
1091 Value *Replacement) {
1110 Value *Bdv = ReverseMap[BaseI];
1117 if (Value *V = SimplifyInstruction(BaseI, DL)) {
1125 // NOTE: This is actually two caches: one of the base defining value
1129 Value *base = Pair.second.getBase();
1133 DEBUG(dbgs() << "Updating base value cache"
1167 DenseMap<Value *, Value *> &PointerToBase,
1172 SmallVector<Value *, 64> Temp;
1175 for (Value *ptr : Temp) {
1176 Value *base = findBasePointer(ptr, DVCache);
1199 DenseMap<Value *, Value *> PointerToBase;
1206 SmallVector<Value *, 64> Temp;
1212 for (Value *Ptr : Temp) {
1213 Value *Base = PointerToBase[Ptr];
1243 // no uses of the original value / return value between the gc.statepoint and
1313 static void CreateGCRelocates(ArrayRef<Value *> LiveVariables,
1315 ArrayRef<Value *> BasePtrs,
1321 auto FindIndex = [](ArrayRef<Value *> LiveVec, Value *Val) {
1334 // later to convert gc_relocate to the actual value's type.
1338 Value *GCRelocateDecl =
1343 Value *BaseIdx =
1345 Value *LiveIdx = Builder.getInt32(LiveStart + i);
1390 const SmallVectorImpl<Value *> &BasePtrs,
1391 const SmallVectorImpl<Value *> &LiveVariables,
1405 ArrayRef<Value *> GCArgs(LiveVariables);
1414 Value *CallTarget = nullptr;
1508 // Extract second element from landingpad return value. We will attach
1575 Value *Base;
1576 Value *Derived;
1584 static void StabilizeOrder(SmallVectorImpl<Value *> &BaseVec,
1585 SmallVectorImpl<Value *> &LiveVec) {
1616 SmallVector<Value *, 64> BaseVec, LiveVec;
1619 for (Value *L : LiveSet) {
1622 Value *Base = PointerToBase.find(L)->second;
1628 // fixed order of the values in the safepoint (by sorting the value name).
1643 insertRelocationStores(iterator_range<Value::user_iterator> GCRelocs,
1644 DenseMap<Value *, Value *> &AllocaMap,
1645 DenseSet<Value *> &VisitedLiveValues) {
1660 Value *OriginalValue =
1661 const_cast<Value *>(RelocateOperands.getDerivedPtr());
1663 Value *Alloca = AllocaMap[OriginalValue];
1671 Value *CastedRelocatedValue =
1690 DenseMap<Value *, Value *> &AllocaMap,
1691 DenseSet<Value *> &VisitedLiveValues) {
1695 Value *OriginalValue = RematerializedValuePair.second;
1698 "Can not find alloca for rematerialized value");
1699 Value *Alloca = AllocaMap[OriginalValue];
1712 Function &F, DominatorTree &DT, ArrayRef<Value *> Live,
1725 DenseMap<Value *, Value *> AllocaMap;
1733 auto emitAllocaFor = [&](Value *LiveValue) {
1741 for (Value *V : Live)
1747 Value *OriginalValue = RematerializedValuePair.second;
1760 // Update gc pointer after each statepoint: either store a relocated value or
1761 // null (if no relocated value was found for this gc pointer and it is not a
1765 Value *Statepoint = Info.StatepointToken;
1768 DenseSet<Value *> VisitedLiveValues;
1792 Value *Def = Pair.first;
1795 // This value was relocated
1825 Value *Def = Pair.first;
1826 Value *Alloca = Pair.second;
1865 // Emit store for the initial gc value. Store must be inserted after load,
1877 "The only TerminatorInst that can produce a value is "
1912 /// Insert holders so that each Value is obviously live through the entire
1914 static void insertUseHolderAfter(CallSite &CS, const ArrayRef<Value *> Values,
1959 DenseMap<Value *, Value *>& PointerToBase,
1961 SmallVector<Value *, 16> ToSplit;
1962 for (Value *V : LiveSet)
1969 DenseMap<Value *, SmallVector<Value *, 16>> ElementMapping;
1973 DenseMap<Value *, AllocaInst *> AllocaMap;
1975 DenseMap<Value *, std::pair<Value *, Value *>> Replacements;
1976 for (Value *V : ToSplit) {
1983 SmallVector<Value *, 16> Elements;
1991 Value *ResultVec = UndefValue::get(VT);
2020 for (Value *V : ToSplit) {
2042 // Store the original value and the replacement value into the alloca
2060 for (Value *V : ToSplit)
2066 for (Value *V : ToSplit) {
2073 Value *OldBase = PointerToBase[V];
2078 Value *Elem = Elements[i];
2092 Value *CurrentValue, Value *BaseValue) {
2094 // We have found a base value
2107 Value *Def = CI->stripPointerCasts();
2168 SmallVector<Value *, 32> LiveValuesToBeDeleted;
2170 for (Value *LiveValue: Info.LiveSet) {
2200 // Remove value from the live set
2209 // and inserts them before "InsertBefore". Returns rematerialized value
2226 // cloned value. We should update it to use cloned value.
2316 SmallVector<Value *, 64> DeoptValues;
2323 for (Value *Arg : DeoptStateRange) {
2341 // Cache the 'defining value' relation used in the computation and
2369 SmallVector<Value *, 128> Bases;
2435 // These live sets may contain state Value pointers, since we replaced calls
2448 SmallVector<Value *, 128> Live;
2454 // That Value* no longer exists and we need to use the new gc_result.
2467 for (Value *V : Statepoint.gc_args()) {
2693 DenseSet<Value *> &LiveTmp) {
2707 for (Value *V : I->operands()) {
2727 static void computeLiveOutSeed(BasicBlock *BB, DenseSet<Value *> &LiveTmp) {
2733 Value *V = Phi->getIncomingValueForBlock(BB);
2743 static DenseSet<Value *> computeKillSet(BasicBlock *BB) {
2744 DenseSet<Value *> KillSet;
2754 static void checkBasicSSA(DominatorTree &DT, DenseSet<Value *> &Live,
2756 for (Value *V : Live) {
2801 for (Value *Kill : Data.KillSet[&BB])
2805 Data.LiveOut[&BB] = DenseSet<Value *>();
2820 DenseSet<Value *> LiveOut = Data.LiveOut[BB];
2836 DenseSet<Value *> LiveTmp = LiveOut;
2841 const DenseSet<Value *> &OldLiveIn = Data.LiveIn[BB];
2865 DenseSet<Value *> LiveOut = Data.LiveOut[BB];
2885 DenseSet<Value *> Bases;
2894 assert(Bases.count(V) && "can't find base for unexpected live value");
2902 "must be able to find base for live value");
2908 DenseSet<Value *> ToErase;
2917 assert(Updated.count(KVPair.first) && "record for non-live value");