summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Andreenko <seandree@microsoft.com>2017-05-26 09:13:08 -0700
committerGitHub <noreply@github.com>2017-05-26 09:13:08 -0700
commitd85104ea4e8a6328323f31a06107e3579a098093 (patch)
tree85b2a3b1e488e587c41e6db31e7d7ea965958f78
parent6e3aaf4b40ac36f97dd73864851aaffad1280a7f (diff)
downloadcoreclr-d85104ea4e8a6328323f31a06107e3579a098093.tar.gz
coreclr-d85104ea4e8a6328323f31a06107e3579a098093.tar.bz2
coreclr-d85104ea4e8a6328323f31a06107e3579a098093.zip
Fix BitSetUint64, clean and improve the surrounding code. (#11721)
1. Add the functions that were not implemented in bitsetasuint64inclass/ 2. BitSetUint64: make copy_constructor public 3. delete VARSET_INIT_NOCOPY and ALLVARSET_INIT_NOCOPY 4. delete VARSET_INIT and ALLVARSET_INIT. 5. Use the correct const type for VARSET_TP.
-rw-r--r--src/jit/bitset.h8
-rw-r--r--src/jit/bitsetasshortlong.h4
-rw-r--r--src/jit/bitsetasuint64.h29
-rw-r--r--src/jit/bitsetasuint64inclass.h59
-rw-r--r--src/jit/block.h3
-rw-r--r--src/jit/codegenclassic.h3
-rw-r--r--src/jit/codegencommon.cpp26
-rw-r--r--src/jit/codegenlegacy.cpp24
-rw-r--r--src/jit/codegenlinear.cpp6
-rw-r--r--src/jit/compiler.cpp3
-rw-r--r--src/jit/compiler.h24
-rw-r--r--src/jit/compiler.hpp4
-rw-r--r--src/jit/emit.cpp6
-rw-r--r--src/jit/emitarm.cpp2
-rw-r--r--src/jit/emitarm64.cpp4
-rw-r--r--src/jit/emitxarch.cpp2
-rw-r--r--src/jit/flowgraph.cpp2
-rw-r--r--src/jit/gentree.cpp10
-rw-r--r--src/jit/lclvars.cpp2
-rw-r--r--src/jit/liveness.cpp121
-rw-r--r--src/jit/lsra.cpp53
-rw-r--r--src/jit/optimizer.cpp12
-rw-r--r--src/jit/rangecheck.cpp2
-rw-r--r--src/jit/rangecheck.h2
-rw-r--r--src/jit/regalloc.cpp47
-rw-r--r--src/jit/scopeinfo.cpp4
-rw-r--r--src/jit/varset.h22
27 files changed, 234 insertions, 250 deletions
diff --git a/src/jit/bitset.h b/src/jit/bitset.h
index 831906821c..4eae519558 100644
--- a/src/jit/bitset.h
+++ b/src/jit/bitset.h
@@ -224,6 +224,9 @@ class BitSetOps
// Returns the number of members in "bs".
static unsigned Count(Env env, BitSetValueArgType bs);
+ // Return true if the union of bs1 and bs2 is empty.
+ static bool IsEmptyUnion(Env env, BitSetValueArgType bs1, BitSetValueArgType bs2);
+
// Returns "true" iff "i" is a member of "bs".
static bool IsMember(Env env, const BitSetValueArgType bs, unsigned i);
@@ -252,9 +255,14 @@ class BitSetOps
// Destructively modify "bs1" to be the set difference of "bs1" and "bs2".
static void DiffD(Env env, BitSetType& bs1, BitSetValueArgType bs2);
+
// Returns a new BitSet that is the set difference of "bs1" and "bs2".
static BitSetValueRetType Diff(Env env, BitSetValueArgType bs1, BitSetValueArgType bs2);
+ // Compute the live_in set. Variable is alive if there is use or it is out set, but not in def.
+ // in = use | (out & ~def)
+ static void LivenessD(Env env, BitSetType& in, BitSetValueArgType def, BitSetValueArgType use, BitSetValueArgType out);
+
// Returns true iff "bs2" is a subset of "bs1."
static bool IsSubset(Env env, BitSetValueArgType bs1, BitSetValueArgType bs2);
diff --git a/src/jit/bitsetasshortlong.h b/src/jit/bitsetasshortlong.h
index fadca5d2ce..4f7a972095 100644
--- a/src/jit/bitsetasshortlong.h
+++ b/src/jit/bitsetasshortlong.h
@@ -539,8 +539,8 @@ public:
friend class Iter;
- typedef size_t* ValArgType;
- typedef size_t* RetValType;
+ typedef const BitSetShortLongRep& ValArgType;
+ typedef BitSetShortLongRep RetValType;
};
template <typename Env, typename BitSetTraits>
diff --git a/src/jit/bitsetasuint64.h b/src/jit/bitsetasuint64.h
index f88f6d63af..a1acaa5a80 100644
--- a/src/jit/bitsetasuint64.h
+++ b/src/jit/bitsetasuint64.h
@@ -75,6 +75,11 @@ public:
return BitSetSupport::CountBitsInIntegral(bs);
}
+ static bool IsEmptyUnion(Env env, UINT64 bs1, UINT64 bs2)
+ {
+ return (bs1 | bs2) == 0;
+ }
+
static void UnionD(Env env, UINT64& bs1, UINT64 bs2)
{
bs1 |= bs2;
@@ -139,6 +144,11 @@ public:
return (bs1 & bs2) == 0;
}
+ static void LivenessD(Env env, UINT64& in, const UINT64 def, const UINT64 use, const UINT64 out)
+ {
+ in = use | (out & ~def);
+ }
+
static bool IsSubset(Env env, UINT64 bs1, UINT64 bs2)
{
return ((bs1 & bs2) == bs1);
@@ -170,14 +180,13 @@ public:
#ifdef DEBUG
static const char* ToString(Env env, UINT64 bs)
{
- IAllocator* alloc = BitSetTraits::GetDebugOnlyAllocator(env);
- const int CharsForUINT64 = sizeof(UINT64) * 2;
- char* res = nullptr;
- const int AllocSize = CharsForUINT64 + 4;
- res = (char*)alloc->Alloc(AllocSize);
- UINT64 bits = bs;
- unsigned remaining = AllocSize;
- char* ptr = res;
+ const int CharsForUINT64 = sizeof(UINT64) * 2;
+ char* res = nullptr;
+ const int AllocSize = CharsForUINT64 + 4;
+ res = (char*)BitSetTraits::DebugAlloc(env, AllocSize);
+ UINT64 bits = bs;
+ unsigned remaining = AllocSize;
+ char* ptr = res;
for (unsigned bytesDone = 0; bytesDone < sizeof(UINT64); bytesDone += sizeof(unsigned))
{
unsigned bits0 = (unsigned)bits;
@@ -239,8 +248,8 @@ public:
}
};
- typedef UINT64 ValArgType;
- typedef UINT64 RetValType;
+ typedef const UINT64 ValArgType;
+ typedef UINT64 RetValType;
};
#endif // bitSetAsUint64_DEFINED
diff --git a/src/jit/bitsetasuint64inclass.h b/src/jit/bitsetasuint64inclass.h
index 4095290b89..372f9088fe 100644
--- a/src/jit/bitsetasuint64inclass.h
+++ b/src/jit/bitsetasuint64inclass.h
@@ -45,16 +45,6 @@ private:
#endif
}
-#ifdef DEBUG
- // In debug, make sure we don't have any public assignment, by making this private.
- BitSetUint64& operator=(const BitSetUint64& bs)
- {
- m_bits = bs.m_bits;
- m_epoch = bs.m_epoch;
- return (*this);
- }
-#endif // DEBUG
-
bool operator==(const BitSetUint64& bs) const
{
return m_bits == bs.m_bits
@@ -64,14 +54,16 @@ private:
;
}
-#ifndef DEBUG
- // In debug we also want the default copy constructor to be private, to make inadvertent
- // default initializations illegal. Debug builds therefore arrange to use the
- // non-default constructor defined below that takes an extra argument where one would
- // otherwise use a copy constructor. In non-debug builds, we don't pass the extra dummy
- // int argument, and just make copy constructor defined here visible.
public:
-#endif
+ BitSetUint64& operator=(const BitSetUint64& bs)
+ {
+ m_bits = bs.m_bits;
+#ifdef DEBUG
+ m_epoch = bs.m_epoch;
+#endif // DEBUG
+ return (*this);
+ }
+
BitSetUint64(const BitSetUint64& bs)
: m_bits(bs.m_bits)
#ifdef DEBUG
@@ -80,14 +72,6 @@ public:
{
}
-#ifdef DEBUG
-public:
- // But we add a public constructor that's *almost* the default constructor.
- BitSetUint64(const BitSetUint64& bs, int xxx) : m_bits(bs.m_bits), m_epoch(bs.m_epoch)
- {
- }
-#endif
-
private:
// Return the number of bits set in the BitSet.
inline unsigned Count(Env env) const
@@ -162,6 +146,13 @@ private:
return res;
}
+ inline bool IsEmptyUnion(Env env, const BitSetUint64& bs2) const
+ {
+ CheckEpoch(env);
+ bs2.CheckEpoch(env);
+ return Uint64BitSetOps::IsEmptyUnion(env, m_bits, bs2.m_bits);
+ }
+
inline void UnionD(Env env, const BitSetUint64& bs2)
{
CheckEpoch(env);
@@ -200,6 +191,15 @@ private:
return Uint64BitSetOps::IsEmpty(env, m_bits);
}
+ inline void LivenessD(Env env, const BitSetUint64& def, const BitSetUint64& use, const BitSetUint64& out)
+ {
+ CheckEpoch(env);
+ def.CheckEpoch(env);
+ use.CheckEpoch(env);
+ out.CheckEpoch(env);
+ return Uint64BitSetOps::LivenessD(env, m_bits, def.m_bits, use.m_bits, out.m_bits);
+ }
+
inline bool IsSubset(Env env, const BitSetUint64& bs2) const
{
CheckEpoch(env);
@@ -406,6 +406,11 @@ public:
return bs.Count(env);
}
+ static bool IsEmptyUnion(Env env, BSTValArg bs1, BSTValArg bs2)
+ {
+ return bs1.IsEmptyUnion(env, bs2);
+ }
+
static void UnionD(Env env, BST& bs1, BSTValArg bs2)
{
bs1.UnionD(env, bs2);
@@ -471,6 +476,10 @@ public:
return bs1.IsEmptyIntersection(env, bs2);
}
+ static void LivenessD(Env env, BST& in, BSTValArg def, BSTValArg use, BSTValArg out)
+ {
+ in.LivenessD(env, def, use, out);
+ }
static bool IsSubset(Env env, BSTValArg bs1, BSTValArg bs2)
{
return bs1.IsSubset(env, bs2);
diff --git a/src/jit/block.h b/src/jit/block.h
index d67891d4dd..461eadc5d7 100644
--- a/src/jit/block.h
+++ b/src/jit/block.h
@@ -1091,8 +1091,7 @@ struct BasicBlock : private LIR::Range
GenTreeStmt* FirstNonPhiDef();
GenTree* FirstNonPhiDefOrCatchArgAsg();
- BasicBlock()
- : VARSET_INIT_NOCOPY(bbLiveIn, VarSetOps::UninitVal()), VARSET_INIT_NOCOPY(bbLiveOut, VarSetOps::UninitVal())
+ BasicBlock() : bbLiveIn(VarSetOps::UninitVal()), bbLiveOut(VarSetOps::UninitVal())
{
}
diff --git a/src/jit/codegenclassic.h b/src/jit/codegenclassic.h
index eb4aeb7754..5794975b6c 100644
--- a/src/jit/codegenclassic.h
+++ b/src/jit/codegenclassic.h
@@ -566,8 +566,7 @@ struct genLivenessSet
regMaskSmall gcRefRegs;
regMaskSmall byRefRegs;
- genLivenessSet()
- : VARSET_INIT_NOCOPY(liveSet, VarSetOps::UninitVal()), VARSET_INIT_NOCOPY(varPtrSet, VarSetOps::UninitVal())
+ genLivenessSet() : liveSet(VarSetOps::UninitVal()), varPtrSet(VarSetOps::UninitVal())
{
}
};
diff --git a/src/jit/codegencommon.cpp b/src/jit/codegencommon.cpp
index 36b0d4fad3..1636889af7 100644
--- a/src/jit/codegencommon.cpp
+++ b/src/jit/codegencommon.cpp
@@ -476,7 +476,7 @@ void CodeGenInterface::genUpdateLife(VARSET_VALARG_TP newLife)
//
VARSET_VALRET_TP CodeGen::genUpdateLiveSetForward(GenTreePtr tree)
{
- VARSET_TP VARSET_INIT(compiler, startLiveSet, compiler->compCurLife);
+ VARSET_TP startLiveSet(VarSetOps::MakeCopy(compiler, compiler->compCurLife));
GenTreePtr startNode;
assert(tree != compiler->compCurLifeTree);
if (compiler->compCurLifeTree == nullptr)
@@ -775,7 +775,7 @@ void Compiler::compUpdateLifeVar(GenTreePtr tree, VARSET_TP* pLastUseVars)
#endif // DEBUG
compCurLifeTree = tree;
- VARSET_TP VARSET_INIT(this, newLife, compCurLife);
+ VARSET_TP newLife(VarSetOps::MakeCopy(this, compCurLife));
// By codegen, a struct may not be TYP_STRUCT, so we have to
// check lvPromoted, for the case where the fields are being
@@ -799,7 +799,7 @@ void Compiler::compUpdateLifeVar(GenTreePtr tree, VARSET_TP* pLastUseVars)
// For RyuJIT backend, since all tracked vars are register candidates, but not all are in registers at all times,
// we maintain two separate sets of variables - the total set of variables that are either
// born or dying here, and the subset of those that are on the stack
- VARSET_TP VARSET_INIT_NOCOPY(stackVarDeltaSet, VarSetOps::MakeEmpty(this));
+ VARSET_TP stackVarDeltaSet(VarSetOps::MakeEmpty(this));
#endif // !LEGACY_BACKEND
if (isBorn || isDying)
@@ -807,7 +807,7 @@ void Compiler::compUpdateLifeVar(GenTreePtr tree, VARSET_TP* pLastUseVars)
bool hasDeadTrackedFieldVars = false; // If this is true, then, for a LDOBJ(ADDR(<promoted struct local>)),
VARSET_TP* deadTrackedFieldVars =
nullptr; // *deadTrackedFieldVars indicates which tracked field vars are dying.
- VARSET_TP VARSET_INIT_NOCOPY(varDeltaSet, VarSetOps::MakeEmpty(this));
+ VARSET_TP varDeltaSet(VarSetOps::MakeEmpty(this));
if (varDsc->lvTracked)
{
@@ -953,9 +953,8 @@ void Compiler::compUpdateLifeVar(GenTreePtr tree, VARSET_TP* pLastUseVars)
// Only add vars to the gcInfo.gcVarPtrSetCur if they are currently on stack, since the
// gcInfo.gcTrkStkPtrLcls
// includes all TRACKED vars that EVER live on the stack (i.e. are not always in a register).
- VARSET_TP VARSET_INIT_NOCOPY(gcTrkStkDeltaSet,
- VarSetOps::Intersection(this, codeGen->gcInfo.gcTrkStkPtrLcls,
- stackVarDeltaSet));
+ VARSET_TP gcTrkStkDeltaSet(
+ VarSetOps::Intersection(this, codeGen->gcInfo.gcTrkStkPtrLcls, stackVarDeltaSet));
if (!VarSetOps::IsEmpty(this, gcTrkStkDeltaSet))
{
#ifdef DEBUG
@@ -990,8 +989,7 @@ void Compiler::compUpdateLifeVar(GenTreePtr tree, VARSET_TP* pLastUseVars)
#ifdef DEBUG
if (verbose)
{
- VARSET_TP VARSET_INIT_NOCOPY(gcVarPtrSetNew,
- VarSetOps::Intersection(this, newLife, codeGen->gcInfo.gcTrkStkPtrLcls));
+ VARSET_TP gcVarPtrSetNew(VarSetOps::Intersection(this, newLife, codeGen->gcInfo.gcTrkStkPtrLcls));
if (!VarSetOps::Equal(this, codeGen->gcInfo.gcVarPtrSetCur, gcVarPtrSetNew))
{
printf("\t\t\t\t\t\t\tGCvars: ");
@@ -1070,12 +1068,10 @@ void Compiler::compChangeLife(VARSET_VALARG_TP newLife DEBUGARG(GenTreePtr tree)
/* Figure out which variables are becoming live/dead at this point */
// deadSet = compCurLife - newLife
- VARSET_TP VARSET_INIT(this, deadSet, compCurLife);
- VarSetOps::DiffD(this, deadSet, newLife);
+ VARSET_TP deadSet(VarSetOps::Diff(this, compCurLife, newLife));
// bornSet = newLife - compCurLife
- VARSET_TP VARSET_INIT(this, bornSet, newLife);
- VarSetOps::DiffD(this, bornSet, compCurLife);
+ VARSET_TP bornSet(VarSetOps::Diff(this, newLife, compCurLife));
/* Can't simultaneously become live and dead at the same time */
@@ -8054,7 +8050,6 @@ void CodeGen::genReserveProlog(BasicBlock* block)
void CodeGen::genReserveEpilog(BasicBlock* block)
{
- VARSET_TP VARSET_INIT(compiler, gcrefVarsArg, getEmitter()->emitThisGCrefVars);
regMaskTP gcrefRegsArg = gcInfo.gcRegGCrefSetCur;
regMaskTP byrefRegsArg = gcInfo.gcRegByrefSetCur;
@@ -8087,7 +8082,8 @@ void CodeGen::genReserveEpilog(BasicBlock* block)
JITDUMP("Reserving epilog IG for block BB%02u\n", block->bbNum);
assert(block != nullptr);
- bool last = (block->bbNext == nullptr);
+ const VARSET_TP& gcrefVarsArg(getEmitter()->emitThisGCrefVars);
+ bool last = (block->bbNext == nullptr);
getEmitter()->emitCreatePlaceholderIG(IGPT_EPILOG, block, gcrefVarsArg, gcrefRegsArg, byrefRegsArg, last);
}
diff --git a/src/jit/codegenlegacy.cpp b/src/jit/codegenlegacy.cpp
index 147e0cee07..8f694b3683 100644
--- a/src/jit/codegenlegacy.cpp
+++ b/src/jit/codegenlegacy.cpp
@@ -45,7 +45,7 @@ void CodeGen::genDyingVars(VARSET_VALARG_TP beforeSet, VARSET_VALARG_TP afterSet
unsigned varNum;
LclVarDsc* varDsc;
regMaskTP regBit;
- VARSET_TP VARSET_INIT_NOCOPY(deadSet, VarSetOps::Diff(compiler, beforeSet, afterSet));
+ VARSET_TP deadSet(VarSetOps::Diff(compiler, beforeSet, afterSet));
if (VarSetOps::IsEmpty(compiler, deadSet))
return;
@@ -5626,12 +5626,10 @@ void CodeGen::genCodeForQmark(GenTreePtr tree, regMaskTP destReg, regMaskTP best
// If any candidates are not alive at the GT_QMARK node, then they
// need to be spilled
- VARSET_TP VARSET_INIT(compiler, rsLiveNow, compiler->compCurLife);
- VARSET_TP VARSET_INIT_NOCOPY(rsLiveAfter, compiler->fgUpdateLiveSet(compiler->compCurLife,
- compiler->compCurLifeTree, tree));
+ const VARSET_TP& rsLiveNow(compiler->compCurLife);
+ VARSET_TP rsLiveAfter(compiler->fgUpdateLiveSet(compiler->compCurLife, compiler->compCurLifeTree, tree));
- VARSET_TP VARSET_INIT_NOCOPY(regVarLiveNow,
- VarSetOps::Intersection(compiler, compiler->raRegVarsMask, rsLiveNow));
+ VARSET_TP regVarLiveNow(VarSetOps::Intersection(compiler, compiler->raRegVarsMask, rsLiveNow));
VARSET_ITER_INIT(compiler, iter, regVarLiveNow, varIndex);
while (iter.NextElem(&varIndex))
@@ -12515,7 +12513,7 @@ void CodeGen::genCodeForBBlist()
}
#endif // DEBUG
- VARSET_TP VARSET_INIT_NOCOPY(liveSet, VarSetOps::UninitVal());
+ VARSET_TP liveSet(VarSetOps::UninitVal());
regMaskTP gcrefRegs = 0;
regMaskTP byrefRegs = 0;
@@ -20616,16 +20614,18 @@ GenTreePtr Compiler::fgLegacyPerStatementLocalVarLiveness(GenTreePtr startNode,
{
GenTreePtr tree;
- VARSET_TP VARSET_INIT(this, defSet_BeforeSplit, fgCurDefSet); // Store the current fgCurDefSet and fgCurUseSet so
- VARSET_TP VARSET_INIT(this, useSet_BeforeSplit, fgCurUseSet); // we can restore then before entering the elseTree.
+ VARSET_TP defSet_BeforeSplit(VarSetOps::MakeCopy(this, fgCurDefSet)); // Store the current fgCurDefSet and
+ // fgCurUseSet so
+ VARSET_TP useSet_BeforeSplit(VarSetOps::MakeCopy(this, fgCurUseSet)); // we can restore then before entering the
+ // elseTree.
MemoryKindSet memoryUse_BeforeSplit = fgCurMemoryUse;
MemoryKindSet memoryDef_BeforeSplit = fgCurMemoryDef;
MemoryKindSet memoryHavoc_BeforeSplit = fgCurMemoryHavoc;
- VARSET_TP VARSET_INIT_NOCOPY(defSet_AfterThenTree, VarSetOps::MakeEmpty(this)); // These two variables will store
- // the USE and DEF sets after
- VARSET_TP VARSET_INIT_NOCOPY(useSet_AfterThenTree, VarSetOps::MakeEmpty(this)); // evaluating the thenTree.
+ VARSET_TP defSet_AfterThenTree(VarSetOps::MakeEmpty(this)); // These two variables will store
+ // the USE and DEF sets after
+ VARSET_TP useSet_AfterThenTree(VarSetOps::MakeEmpty(this)); // evaluating the thenTree.
MemoryKindSet memoryUse_AfterThenTree = fgCurMemoryUse;
MemoryKindSet memoryDef_AfterThenTree = fgCurMemoryDef;
diff --git a/src/jit/codegenlinear.cpp b/src/jit/codegenlinear.cpp
index beba467c17..af279a24fc 100644
--- a/src/jit/codegenlinear.cpp
+++ b/src/jit/codegenlinear.cpp
@@ -164,8 +164,8 @@ void CodeGen::genCodeForBBlist()
regMaskTP newRegGCrefSet = RBM_NONE;
regMaskTP newRegByrefSet = RBM_NONE;
#ifdef DEBUG
- VARSET_TP VARSET_INIT_NOCOPY(removedGCVars, VarSetOps::MakeEmpty(compiler));
- VARSET_TP VARSET_INIT_NOCOPY(addedGCVars, VarSetOps::MakeEmpty(compiler));
+ VARSET_TP removedGCVars(VarSetOps::MakeEmpty(compiler));
+ VARSET_TP addedGCVars(VarSetOps::MakeEmpty(compiler));
#endif
VARSET_ITER_INIT(compiler, iter, block->bbLiveIn, varIndex);
while (iter.NextElem(&varIndex))
@@ -497,7 +497,7 @@ void CodeGen::genCodeForBBlist()
// it up to date for vars that are not register candidates
// (it would be nice to have a xor set function)
- VARSET_TP VARSET_INIT_NOCOPY(extraLiveVars, VarSetOps::Diff(compiler, block->bbLiveOut, compiler->compCurLife));
+ VARSET_TP extraLiveVars(VarSetOps::Diff(compiler, block->bbLiveOut, compiler->compCurLife));
VarSetOps::UnionD(compiler, extraLiveVars, VarSetOps::Diff(compiler, compiler->compCurLife, block->bbLiveOut));
VARSET_ITER_INIT(compiler, extraLiveVarIter, extraLiveVars, extraLiveVarIndex);
while (extraLiveVarIter.NextElem(&extraLiveVarIndex))
diff --git a/src/jit/compiler.cpp b/src/jit/compiler.cpp
index 111fdcd0ed..3845292aeb 100644
--- a/src/jit/compiler.cpp
+++ b/src/jit/compiler.cpp
@@ -8273,7 +8273,7 @@ FILE* Compiler::compJitFuncInfoFile = nullptr;
#ifdef DEBUG
-// dumpConvertedVarSet() is just like dumpVarSet(), except we assume the varset bits are tracked
+// dumpConvertedVarSet() dumps the varset bits that are tracked
// variable indices, and we convert them to variable numbers, sort the variable numbers, and
// print them as variable numbers. To do this, we use a temporary set indexed by
// variable number. We can't use the "all varset" type because it is still size-limited, and might
@@ -8371,7 +8371,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*
*
* The following don't require a Compiler* to work:
- * dVarSet : Display a VARSET_TP (call dumpVarSet()).
* dRegMask : Display a regMaskTP (call dspRegMask(mask)).
*/
diff --git a/src/jit/compiler.h b/src/jit/compiler.h
index c8ead479b6..d4388628c6 100644
--- a/src/jit/compiler.h
+++ b/src/jit/compiler.h
@@ -3753,20 +3753,20 @@ public:
void fgComputeLifeCall(VARSET_TP& life, GenTreeCall* call);
- bool fgComputeLifeLocal(VARSET_TP& life, VARSET_TP& keepAliveVars, GenTree* lclVarNode, GenTree* node);
+ bool fgComputeLifeLocal(VARSET_TP& life, VARSET_VALARG_TP keepAliveVars, GenTree* lclVarNode, GenTree* node);
- VARSET_VALRET_TP fgComputeLife(VARSET_VALARG_TP life,
- GenTreePtr startNode,
- GenTreePtr endNode,
- VARSET_VALARG_TP volatileVars,
- bool* pStmtInfoDirty DEBUGARG(bool* treeModf));
+ void fgComputeLife(VARSET_TP& life,
+ GenTreePtr startNode,
+ GenTreePtr endNode,
+ VARSET_VALARG_TP volatileVars,
+ bool* pStmtInfoDirty DEBUGARG(bool* treeModf));
- VARSET_VALRET_TP fgComputeLifeLIR(VARSET_VALARG_TP life, BasicBlock* block, VARSET_VALARG_TP volatileVars);
+ void fgComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VARSET_VALARG_TP volatileVars);
- bool fgRemoveDeadStore(GenTree** pTree,
- LclVarDsc* varDsc,
- VARSET_TP life,
- bool* doAgain,
+ bool fgRemoveDeadStore(GenTree** pTree,
+ LclVarDsc* varDsc,
+ VARSET_VALARG_TP life,
+ bool* doAgain,
bool* pStmtInfoDirty DEBUGARG(bool* treeModf));
bool fgTryRemoveDeadLIRStore(LIR::Range& blockRange, GenTree* node, GenTree** next);
@@ -3782,7 +3782,7 @@ public:
VARSET_VALRET_TP fgUpdateLiveSet(VARSET_VALARG_TP liveSet, GenTreePtr tree, GenTreePtr endTree)
{
- VARSET_TP VARSET_INIT(this, newLiveSet, liveSet);
+ VARSET_TP newLiveSet(VarSetOps::MakeCopy(this, liveSet));
while (tree != nullptr && tree != endTree->gtNext)
{
VarSetOps::AssignNoCopy(this, newLiveSet, fgUpdateLiveSet(newLiveSet, tree));
diff --git a/src/jit/compiler.hpp b/src/jit/compiler.hpp
index c855600aa6..314c195120 100644
--- a/src/jit/compiler.hpp
+++ b/src/jit/compiler.hpp
@@ -2134,7 +2134,7 @@ inline VARSET_VALRET_TP Compiler::lvaStmtLclMask(GenTreePtr stmt)
GenTreePtr tree;
unsigned varNum;
LclVarDsc* varDsc;
- VARSET_TP VARSET_INIT_NOCOPY(lclMask, VarSetOps::MakeEmpty(this));
+ VARSET_TP lclMask(VarSetOps::MakeEmpty(this));
assert(stmt->gtOper == GT_STMT);
assert(fgStmtListThreaded);
@@ -3845,7 +3845,7 @@ inline bool Compiler::optIsVarAssgLoop(unsigned lnum, unsigned var)
assert(lnum < optLoopCount);
if (var < lclMAX_ALLSET_TRACKED)
{
- ALLVARSET_TP ALLVARSET_INIT_NOCOPY(vs, AllVarSetOps::MakeSingleton(this, var));
+ ALLVARSET_TP vs(AllVarSetOps::MakeSingleton(this, var));
return optIsSetAssgLoop(lnum, vs) != 0;
}
else
diff --git a/src/jit/emit.cpp b/src/jit/emit.cpp
index 29f79f0e6f..4684230601 100644
--- a/src/jit/emit.cpp
+++ b/src/jit/emit.cpp
@@ -3341,7 +3341,7 @@ void emitter::emitDispIGlist(bool verbose)
void emitter::emitDispGCinfo()
{
printf("Emitter GC tracking info:");
- printf("\n emitPrevGCrefVars(0x%p)=%016llX ", dspPtr(&emitPrevGCrefVars), emitPrevGCrefVars);
+ printf("\n emitPrevGCrefVars ");
dumpConvertedVarSet(emitComp, emitPrevGCrefVars);
printf("\n emitPrevGCrefRegs(0x%p)=", dspPtr(&emitPrevGCrefRegs));
printRegMaskInt(emitPrevGCrefRegs);
@@ -3349,7 +3349,7 @@ void emitter::emitDispGCinfo()
printf("\n emitPrevByrefRegs(0x%p)=", dspPtr(&emitPrevByrefRegs));
printRegMaskInt(emitPrevByrefRegs);
emitDispRegSet(emitPrevByrefRegs);
- printf("\n emitInitGCrefVars(0x%p)=%016llX ", dspPtr(&emitInitGCrefVars), emitInitGCrefVars);
+ printf("\n emitInitGCrefVars ");
dumpConvertedVarSet(emitComp, emitInitGCrefVars);
printf("\n emitInitGCrefRegs(0x%p)=", dspPtr(&emitInitGCrefRegs));
printRegMaskInt(emitInitGCrefRegs);
@@ -3357,7 +3357,7 @@ void emitter::emitDispGCinfo()
printf("\n emitInitByrefRegs(0x%p)=", dspPtr(&emitInitByrefRegs));
printRegMaskInt(emitInitByrefRegs);
emitDispRegSet(emitInitByrefRegs);
- printf("\n emitThisGCrefVars(0x%p)=%016llX ", dspPtr(&emitThisGCrefVars), emitThisGCrefVars);
+ printf("\n emitThisGCrefVars ");
dumpConvertedVarSet(emitComp, emitThisGCrefVars);
printf("\n emitThisGCrefRegs(0x%p)=", dspPtr(&emitThisGCrefRegs));
printRegMaskInt(emitThisGCrefRegs);
diff --git a/src/jit/emitarm.cpp b/src/jit/emitarm.cpp
index 4763beae52..4f3f5e629a 100644
--- a/src/jit/emitarm.cpp
+++ b/src/jit/emitarm.cpp
@@ -5540,7 +5540,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
assert(REG_NA == (int)REG_NA);
- VARSET_TP VARSET_INIT_NOCOPY(GCvars, VarSetOps::UninitVal());
+ VARSET_TP GCvars(VarSetOps::UninitVal());
/* What instruction format have we got? */
diff --git a/src/jit/emitarm64.cpp b/src/jit/emitarm64.cpp
index 4097b662f0..2a52f9228c 100644
--- a/src/jit/emitarm64.cpp
+++ b/src/jit/emitarm64.cpp
@@ -8482,7 +8482,7 @@ unsigned emitter::emitOutputCall(insGroup* ig, BYTE* dst, instrDesc* id, code_t
regMaskTP gcrefRegs;
regMaskTP byrefRegs;
- VARSET_TP VARSET_INIT_NOCOPY(GCvars, VarSetOps::UninitVal());
+ VARSET_TP GCvars(VarSetOps::UninitVal());
// Is this a "fat" call descriptor?
if (id->idIsLargeCall())
@@ -8617,7 +8617,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
assert(REG_NA == (int)REG_NA);
- VARSET_TP VARSET_INIT_NOCOPY(GCvars, VarSetOps::UninitVal());
+ VARSET_TP GCvars(VarSetOps::UninitVal());
/* What instruction format have we got? */
diff --git a/src/jit/emitxarch.cpp b/src/jit/emitxarch.cpp
index f6e569092c..e60366afaf 100644
--- a/src/jit/emitxarch.cpp
+++ b/src/jit/emitxarch.cpp
@@ -10368,7 +10368,7 @@ size_t emitter::emitOutputInstr(insGroup* ig, instrDesc* id, BYTE** dp)
assert(ins != INS_imul || size >= EA_4BYTE); // Has no 'w' bit
assert(instrIs3opImul(id->idIns()) == 0 || size >= EA_4BYTE); // Has no 'w' bit
- VARSET_TP VARSET_INIT_NOCOPY(GCvars, VarSetOps::UninitVal());
+ VARSET_TP GCvars(VarSetOps::UninitVal());
// What instruction format have we got?
switch (id->idInsFmt())
diff --git a/src/jit/flowgraph.cpp b/src/jit/flowgraph.cpp
index 840fa84cb5..359022d82b 100644
--- a/src/jit/flowgraph.cpp
+++ b/src/jit/flowgraph.cpp
@@ -9298,7 +9298,7 @@ void Compiler::fgUpdateRefCntForExtract(GenTreePtr wholeTree, GenTreePtr keptTre
VARSET_VALRET_TP Compiler::fgGetVarBits(GenTreePtr tree)
{
- VARSET_TP VARSET_INIT_NOCOPY(varBits, VarSetOps::MakeEmpty(this));
+ VARSET_TP varBits(VarSetOps::MakeEmpty(this));
assert(tree->gtOper == GT_LCL_VAR || tree->gtOper == GT_LCL_FLD || tree->gtOper == GT_REG_VAR);
diff --git a/src/jit/gentree.cpp b/src/jit/gentree.cpp
index 697d70c076..26c7efaaa8 100644
--- a/src/jit/gentree.cpp
+++ b/src/jit/gentree.cpp
@@ -3040,8 +3040,8 @@ bool Compiler::lvaLclVarRefs(GenTreePtr tree, GenTreePtr* findPtr, varRefKinds*
genTreeOps oper;
unsigned kind;
varRefKinds refs = VR_NONE;
- ALLVARSET_TP ALLVARSET_INIT_NOCOPY(allVars, AllVarSetOps::UninitVal());
- VARSET_TP VARSET_INIT_NOCOPY(trkdVars, VarSetOps::UninitVal());
+ ALLVARSET_TP allVars(AllVarSetOps::UninitVal());
+ VARSET_TP trkdVars(VarSetOps::UninitVal());
if (findPtr)
{
AllVarSetOps::AssignNoCopy(this, allVars, AllVarSetOps::MakeEmpty(this));
@@ -3219,7 +3219,7 @@ AGAIN:
unsigned dim;
for (dim = 0; dim < tree->gtArrElem.gtArrRank; dim++)
{
- VARSET_TP VARSET_INIT_NOCOPY(tmpVs, VarSetOps::UninitVal());
+ VARSET_TP tmpVs(VarSetOps::UninitVal());
if (!lvaLclVarRefsAccum(tree->gtArrElem.gtArrInds[dim], findPtr, refsPtr, &allVars, &trkdVars))
{
return false;
@@ -3309,7 +3309,7 @@ bool Compiler::lvaLclVarRefsAccum(
{
if (findPtr)
{
- ALLVARSET_TP ALLVARSET_INIT_NOCOPY(tmpVs, AllVarSetOps::UninitVal());
+ ALLVARSET_TP tmpVs(AllVarSetOps::UninitVal());
if (!lvaLclVarRefs(tree, findPtr, refsPtr, &tmpVs))
{
return false;
@@ -3319,7 +3319,7 @@ bool Compiler::lvaLclVarRefsAccum(
}
else
{
- VARSET_TP VARSET_INIT_NOCOPY(tmpVs, VarSetOps::UninitVal());
+ VARSET_TP tmpVs(VarSetOps::UninitVal());
if (!lvaLclVarRefs(tree, findPtr, refsPtr, &tmpVs))
{
return false;
diff --git a/src/jit/lclvars.cpp b/src/jit/lclvars.cpp
index 721162b377..2777ce9784 100644
--- a/src/jit/lclvars.cpp
+++ b/src/jit/lclvars.cpp
@@ -7242,7 +7242,7 @@ void Compiler::lvaStressLclFld()
#ifdef DEBUG
void Compiler::lvaDispVarSet(VARSET_VALARG_TP set)
{
- VARSET_TP VARSET_INIT_NOCOPY(allVars, VarSetOps::MakeEmpty(this));
+ VARSET_TP allVars(VarSetOps::MakeEmpty(this));
lvaDispVarSet(set, allVars);
}
diff --git a/src/jit/liveness.cpp b/src/jit/liveness.cpp
index fe40390cb3..94df0df554 100644
--- a/src/jit/liveness.cpp
+++ b/src/jit/liveness.cpp
@@ -88,7 +88,7 @@ void Compiler::fgMarkUseDef(GenTreeLclVarCommon* tree)
if (promotionType != PROMOTION_TYPE_NONE)
{
- VARSET_TP VARSET_INIT_NOCOPY(bitMask, VarSetOps::MakeEmpty(this));
+ VARSET_TP bitMask(VarSetOps::MakeEmpty(this));
for (unsigned i = varDsc->lvFieldLclStart; i < varDsc->lvFieldLclStart + varDsc->lvFieldCnt; ++i)
{
@@ -189,7 +189,7 @@ void Compiler::fgLocalVarLivenessInit()
/* If we're not optimizing at all, things are simple */
if (opts.MinOpts())
{
- VARSET_TP VARSET_INIT_NOCOPY(allOnes, VarSetOps::MakeFull(this));
+ VARSET_TP allOnes(VarSetOps::MakeFull(this));
for (unsigned i = 0; i < lvaTrackedCount; i++)
{
VarSetOps::Assign(this, lvaVarIntf[i], allOnes);
@@ -431,7 +431,7 @@ void Compiler::fgPerBlockLocalVarLiveness()
unsigned lclNum;
LclVarDsc* varDsc;
- VARSET_TP VARSET_INIT_NOCOPY(liveAll, VarSetOps::MakeEmpty(this));
+ VARSET_TP liveAll(VarSetOps::MakeEmpty(this));
/* We simply make everything live everywhere */
@@ -549,7 +549,7 @@ void Compiler::fgPerBlockLocalVarLiveness()
#ifdef DEBUG
if (verbose)
{
- VARSET_TP VARSET_INIT_NOCOPY(allVars, VarSetOps::Union(this, fgCurUseSet, fgCurDefSet));
+ VARSET_TP allVars(VarSetOps::Union(this, fgCurUseSet, fgCurDefSet));
printf("BB%02u", block->bbNum);
printf(" USE(%d)=", VarSetOps::Count(this, fgCurUseSet));
lvaDispVarSet(fgCurUseSet, allVars);
@@ -712,7 +712,7 @@ void Compiler::fgExtendDbgScopes()
}
#endif // DEBUG
- VARSET_TP VARSET_INIT_NOCOPY(inScope, VarSetOps::MakeEmpty(this));
+ VARSET_TP inScope(VarSetOps::MakeEmpty(this));
// Mark all tracked LocalVars live over their scope - walk the blocks
// keeping track of the current life, and assign it to the blocks.
@@ -762,7 +762,7 @@ void Compiler::fgExtendDbgScopes()
}
#endif // DEBUG
- VARSET_TP VARSET_INIT_NOCOPY(inScope, VarSetOps::MakeEmpty(this));
+ VARSET_TP inScope(VarSetOps::MakeEmpty(this));
compProcessScopesUntil(0, &inScope, &Compiler::fgBeginScopeLife, &Compiler::fgEndScopeLife);
IL_OFFSET lastEndOffs = 0;
@@ -865,7 +865,7 @@ void Compiler::fgExtendDbgLifetimes()
assert(fgFirstBBisScratch());
- VARSET_TP VARSET_INIT_NOCOPY(trackedArgs, VarSetOps::MakeEmpty(this));
+ VARSET_TP trackedArgs(VarSetOps::MakeEmpty(this));
for (unsigned argNum = 0; argNum < info.compArgsCount; argNum++)
{
@@ -892,7 +892,7 @@ void Compiler::fgExtendDbgLifetimes()
}
// Don't unmark struct locals, either.
- VARSET_TP VARSET_INIT_NOCOPY(noUnmarkVars, trackedArgs);
+ VARSET_TP noUnmarkVars(trackedArgs);
for (unsigned i = 0; i < lvaCount; i++)
{
@@ -911,7 +911,7 @@ void Compiler::fgExtendDbgLifetimes()
* garbage until they are initialized by the IL code.
*/
- VARSET_TP VARSET_INIT_NOCOPY(initVars, VarSetOps::MakeEmpty(this)); // Vars which are artificially made alive
+ VARSET_TP initVars(VarSetOps::MakeEmpty(this)); // Vars which are artificially made alive
for (BasicBlock* block = fgFirstBB; block; block = block->bbNext)
{
@@ -1086,7 +1086,7 @@ VARSET_VALRET_TP Compiler::fgGetHandlerLiveVars(BasicBlock* block)
noway_assert(block);
noway_assert(ehBlockHasExnFlowDsc(block));
- VARSET_TP VARSET_INIT_NOCOPY(liveVars, VarSetOps::MakeEmpty(this));
+ VARSET_TP liveVars(VarSetOps::MakeEmpty(this));
EHblkDsc* HBtab = ehGetBlockExnFlowDsc(block);
do
@@ -1200,7 +1200,7 @@ class LiveVarAnalysis
if (m_compiler->ehBlockHasExnFlowDsc(block))
{
- VARSET_TP VARSET_INIT_NOCOPY(liveVars, m_compiler->fgGetHandlerLiveVars(block));
+ const VARSET_TP& liveVars(m_compiler->fgGetHandlerLiveVars(block));
VarSetOps::UnionD(m_compiler, m_liveIn, liveVars);
VarSetOps::UnionD(m_compiler, m_liveOut, liveVars);
@@ -1365,7 +1365,7 @@ bool Compiler::fgMarkIntf(VARSET_VALARG_TP varSet1, VARSET_VALARG_TP varSet2)
if (VarSetOps::IsMember(this, varSet1, refIndex))
{
// Calculate the set of new interference to add
- VARSET_TP VARSET_INIT_NOCOPY(newIntf, VarSetOps::Diff(this, varSet2, lvaVarIntf[refIndex]));
+ VARSET_TP newIntf(VarSetOps::Diff(this, varSet2, lvaVarIntf[refIndex]));
if (!VarSetOps::IsEmpty(this, newIntf))
{
addedIntf = true;
@@ -1377,7 +1377,7 @@ bool Compiler::fgMarkIntf(VARSET_VALARG_TP varSet1, VARSET_VALARG_TP varSet2)
if (VarSetOps::IsMember(this, varSet2, refIndex))
{
// Calculate the set of new interference to add
- VARSET_TP VARSET_INIT_NOCOPY(newIntf, VarSetOps::Diff(this, varSet1, lvaVarIntf[refIndex]));
+ VARSET_TP newIntf(VarSetOps::Diff(this, varSet1, lvaVarIntf[refIndex]));
if (!VarSetOps::IsEmpty(this, newIntf))
{
addedIntf = true;
@@ -1415,7 +1415,7 @@ bool Compiler::fgMarkIntf(VARSET_VALARG_TP varSet)
while (iter.NextElem(&refIndex))
{
// Calculate the set of new interference to add
- VARSET_TP VARSET_INIT_NOCOPY(newIntf, VarSetOps::Diff(this, varSet, lvaVarIntf[refIndex]));
+ VARSET_TP newIntf(VarSetOps::Diff(this, varSet, lvaVarIntf[refIndex]));
if (!VarSetOps::IsEmpty(this, newIntf))
{
addedIntf = true;
@@ -1435,13 +1435,13 @@ bool Compiler::fgMarkIntf(VARSET_VALARG_TP varSet)
VARSET_VALRET_TP Compiler::fgUpdateLiveSet(VARSET_VALARG_TP liveSet, GenTreePtr tree)
{
- VARSET_TP VARSET_INIT(this, newLiveSet, liveSet);
+ VARSET_TP newLiveSet(VarSetOps::MakeCopy(this, liveSet));
assert(fgLocalVarLivenessDone == true);
GenTreePtr lclVarTree = tree; // After the tests below, "lclVarTree" will be the local variable.
if (tree->gtOper == GT_LCL_VAR || tree->gtOper == GT_LCL_FLD || tree->gtOper == GT_REG_VAR ||
(lclVarTree = fgIsIndirOfAddrOfLocal(tree)) != nullptr)
{
- VARSET_TP VARSET_INIT_NOCOPY(varBits, fgGetVarBits(lclVarTree));
+ const VARSET_TP& varBits(fgGetVarBits(lclVarTree));
if (!VarSetOps::IsEmpty(this, varBits))
{
@@ -1512,7 +1512,7 @@ void Compiler::fgComputeLifeCall(VARSET_TP& life, GenTreeCall* call)
if (frameVarDsc->lvTracked)
{
- VARSET_TP VARSET_INIT_NOCOPY(varBit, VarSetOps::MakeSingleton(this, frameVarDsc->lvVarIndex));
+ VARSET_TP varBit(VarSetOps::MakeSingleton(this, frameVarDsc->lvVarIndex));
VarSetOps::AddElemD(this, life, frameVarDsc->lvVarIndex);
@@ -1564,7 +1564,7 @@ void Compiler::fgComputeLifeCall(VARSET_TP& life, GenTreeCall* call)
// Record an interference with the other live variables
//
- VARSET_TP VARSET_INIT_NOCOPY(varBit, VarSetOps::MakeSingleton(this, varIndex));
+ VARSET_TP varBit(VarSetOps::MakeSingleton(this, varIndex));
fgMarkIntf(life, varBit);
}
}
@@ -1626,7 +1626,7 @@ void Compiler::fgComputeLifeCall(VARSET_TP& life, GenTreeCall* call)
// `true` if the local var node corresponds to a dead store; `false`
// otherwise.
//
-bool Compiler::fgComputeLifeLocal(VARSET_TP& life, VARSET_TP& keepAliveVars, GenTree* lclVarNode, GenTree* node)
+bool Compiler::fgComputeLifeLocal(VARSET_TP& life, VARSET_VALARG_TP keepAliveVars, GenTree* lclVarNode, GenTree* node)
{
unsigned lclNum = lclVarNode->gtLclVarCommon.gtLclNum;
@@ -1815,19 +1815,17 @@ bool Compiler::fgComputeLifeLocal(VARSET_TP& life, VARSET_TP& keepAliveVars, Gen
*/
#ifndef LEGACY_BACKEND
-VARSET_VALRET_TP Compiler::fgComputeLife(VARSET_VALARG_TP lifeArg,
- GenTreePtr startNode,
- GenTreePtr endNode,
- VARSET_VALARG_TP volatileVars,
- bool* pStmtInfoDirty DEBUGARG(bool* treeModf))
+void Compiler::fgComputeLife(VARSET_TP& life,
+ GenTreePtr startNode,
+ GenTreePtr endNode,
+ VARSET_VALARG_TP volatileVars,
+ bool* pStmtInfoDirty DEBUGARG(bool* treeModf))
{
GenTreePtr tree;
unsigned lclNum;
- VARSET_TP VARSET_INIT(this, life, lifeArg); // lifeArg is const ref; copy to allow modification.
-
- VARSET_TP VARSET_INIT(this, keepAliveVars, volatileVars);
- VarSetOps::UnionD(this, keepAliveVars, compCurBB->bbScope); // Don't kill vars in scope
+ // Don't kill vars in scope
+ VARSET_TP keepAliveVars(VarSetOps::Union(this, volatileVars, compCurBB->bbScope));
noway_assert(VarSetOps::IsSubset(this, keepAliveVars, life));
noway_assert(compCurStmt->gtOper == GT_STMT);
@@ -1865,17 +1863,12 @@ VARSET_VALRET_TP Compiler::fgComputeLife(VARSET_VALARG_TP lifeArg,
}
}
}
-
- // Return the set of live variables out of this statement
- return life;
}
-VARSET_VALRET_TP Compiler::fgComputeLifeLIR(VARSET_VALARG_TP lifeArg, BasicBlock* block, VARSET_VALARG_TP volatileVars)
+void Compiler::fgComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VARSET_VALARG_TP volatileVars)
{
- VARSET_TP VARSET_INIT(this, life, lifeArg); // lifeArg is const ref; copy to allow modification.
-
- VARSET_TP VARSET_INIT(this, keepAliveVars, volatileVars);
- VarSetOps::UnionD(this, keepAliveVars, block->bbScope); // Don't kill vars in scope
+ // Don't kill volatile vars and vars in scope.
+ VARSET_TP keepAliveVars(VarSetOps::Union(this, volatileVars, block->bbScope));
noway_assert(VarSetOps::IsSubset(this, keepAliveVars, life));
@@ -1883,9 +1876,8 @@ VARSET_VALRET_TP Compiler::fgComputeLifeLIR(VARSET_VALARG_TP lifeArg, BasicBlock
GenTree* firstNonPhiNode = blockRange.FirstNonPhiNode();
if (firstNonPhiNode == nullptr)
{
- return life;
+ return;
}
-
for (GenTree *node = blockRange.LastNode(), *next = nullptr, *end = firstNonPhiNode->gtPrev; node != end;
node = next)
{
@@ -1904,8 +1896,6 @@ VARSET_VALRET_TP Compiler::fgComputeLifeLIR(VARSET_VALARG_TP lifeArg, BasicBlock
}
}
}
-
- return life;
}
#else // LEGACY_BACKEND
@@ -1915,11 +1905,11 @@ VARSET_VALRET_TP Compiler::fgComputeLifeLIR(VARSET_VALARG_TP lifeArg, BasicBlock
#pragma warning(disable : 21000) // Suppress PREFast warning about overly large function
#endif
-VARSET_VALRET_TP Compiler::fgComputeLife(VARSET_VALARG_TP lifeArg,
- GenTreePtr startNode,
- GenTreePtr endNode,
- VARSET_VALARG_TP volatileVars,
- bool* pStmtInfoDirty DEBUGARG(bool* treeModf))
+void Compiler::fgComputeLife(VARSET_TP& life,
+ GenTreePtr startNode,
+ GenTreePtr endNode,
+ VARSET_VALARG_TP volatileVars,
+ bool* pStmtInfoDirty DEBUGARG(bool* treeModf))
{
GenTreePtr tree;
unsigned lclNum;
@@ -1928,15 +1918,12 @@ VARSET_VALRET_TP Compiler::fgComputeLife(VARSET_VALARG_TP lifeArg,
GenTreePtr nextColonExit = 0; // gtQMark->gtOp.gtOp2 while walking the 'else' branch.
// gtQMark->gtOp.gtOp1 while walking the 'then' branch
- VARSET_TP VARSET_INIT(this, life, lifeArg); // lifeArg is const ref; copy to allow modification.
-
// TBD: This used to be an initialization to VARSET_NOT_ACCEPTABLE. Try to figure out what's going on here.
- VARSET_TP VARSET_INIT_NOCOPY(entryLiveSet, VarSetOps::MakeFull(this)); // liveness when we see gtQMark
- VARSET_TP VARSET_INIT_NOCOPY(gtColonLiveSet, VarSetOps::MakeFull(this)); // liveness when we see gtColon
+ VARSET_TP entryLiveSet(VarSetOps::MakeFull(this)); // liveness when we see gtQMark
+ VARSET_TP gtColonLiveSet(VarSetOps::MakeFull(this)); // liveness when we see gtColon
GenTreePtr gtColon = NULL;
- VARSET_TP VARSET_INIT(this, keepAliveVars, volatileVars);
- VarSetOps::UnionD(this, keepAliveVars, compCurBB->bbScope); /* Dont kill vars in scope */
+ VARSET_TP keepAliveVars(VarSetOps::Union(this, volatileVars, compCurBB->bbScope)); /* Dont kill vars in scope */
noway_assert(VarSetOps::Equal(this, VarSetOps::Intersection(this, keepAliveVars, life), keepAliveVars));
noway_assert(compCurStmt->gtOper == GT_STMT);
@@ -2089,7 +2076,7 @@ VARSET_VALRET_TP Compiler::fgComputeLife(VARSET_VALARG_TP lifeArg,
gtReverseCond(tree);
// Remember to also swap the live sets of the two branches.
- VARSET_TP VARSET_INIT_NOCOPY(tmpVS, gtQMark->gtQmark.gtElseLiveSet);
+ const VARSET_TP& tmpVS(gtQMark->gtQmark.gtElseLiveSet);
VarSetOps::AssignNoCopy(this, gtQMark->gtQmark.gtElseLiveSet, gtQMark->gtQmark.gtThenLiveSet);
VarSetOps::AssignNoCopy(this, gtQMark->gtQmark.gtThenLiveSet, tmpVS);
@@ -2217,8 +2204,7 @@ VARSET_VALRET_TP Compiler::fgComputeLife(VARSET_VALARG_TP lifeArg,
noway_assert(nextColonExit &&
(nextColonExit == gtQMark->gtOp.gtOp1 || nextColonExit == gtQMark->gtOp.gtOp2));
- VarSetOps::AssignNoCopy(this, life, fgComputeLife(life, tree, nextColonExit, volatileVars,
- pStmtInfoDirty DEBUGARG(treeModf)));
+ fgComputeLife(life, tree, nextColonExit, volatileVars, pStmtInfoDirty DEBUGARG(treeModf));
/* Continue with exit node (the last node in the enclosing colon branch) */
@@ -2248,8 +2234,6 @@ VARSET_VALRET_TP Compiler::fgComputeLife(VARSET_VALARG_TP lifeArg,
}
/* Return the set of live variables out of this statement */
-
- return life;
}
#ifdef _PREFAST_
@@ -2346,8 +2330,11 @@ bool Compiler::fgTryRemoveDeadLIRStore(LIR::Range& blockRange, GenTree* node, Ge
//
// Returns: true if we should skip the rest of the statement, false if we should continue
-bool Compiler::fgRemoveDeadStore(
- GenTree** pTree, LclVarDsc* varDsc, VARSET_TP life, bool* doAgain, bool* pStmtInfoDirty DEBUGARG(bool* treeModf))
+bool Compiler::fgRemoveDeadStore(GenTree** pTree,
+ LclVarDsc* varDsc,
+ VARSET_VALARG_TP life,
+ bool* doAgain,
+ bool* pStmtInfoDirty DEBUGARG(bool* treeModf))
{
assert(!compRationalIRForm);
@@ -2786,9 +2773,9 @@ void Compiler::fgInterBlockLocalVarLiveness()
*/
BasicBlock* block;
- VARSET_TP VARSET_INIT_NOCOPY(exceptVars, VarSetOps::MakeEmpty(this)); // vars live on entry to a handler
- VARSET_TP VARSET_INIT_NOCOPY(finallyVars, VarSetOps::MakeEmpty(this)); // vars live on exit of a 'finally' block
- VARSET_TP VARSET_INIT_NOCOPY(filterVars, VarSetOps::MakeEmpty(this)); // vars live on exit from a 'filter'
+ VARSET_TP exceptVars(VarSetOps::MakeEmpty(this)); // vars live on entry to a handler
+ VARSET_TP finallyVars(VarSetOps::MakeEmpty(this)); // vars live on exit of a 'finally' block
+ VARSET_TP filterVars(VarSetOps::MakeEmpty(this)); // vars live on exit from a 'filter'
for (block = fgFirstBB; block; block = block->bbNext)
{
@@ -2904,7 +2891,7 @@ void Compiler::fgInterBlockLocalVarLiveness()
/* Remember those vars live on entry to exception handlers */
/* if we are part of a try block */
- VARSET_TP VARSET_INIT_NOCOPY(volatileVars, VarSetOps::MakeEmpty(this));
+ VARSET_TP volatileVars(VarSetOps::MakeEmpty(this));
if (ehBlockHasExnFlowDsc(block))
{
@@ -2916,7 +2903,7 @@ void Compiler::fgInterBlockLocalVarLiveness()
/* Start with the variables live on exit from the block */
- VARSET_TP VARSET_INIT(this, life, block->bbLiveOut);
+ VARSET_TP life(VarSetOps::MakeCopy(this, block->bbLiveOut));
/* Mark any interference we might have at the end of the block */
@@ -2951,8 +2938,8 @@ void Compiler::fgInterBlockLocalVarLiveness()
/* Compute the liveness for each tree node in the statement */
bool stmtInfoDirty = false;
- VarSetOps::AssignNoCopy(this, life, fgComputeLife(life, compCurStmt->gtStmt.gtStmtExpr, nullptr,
- volatileVars, &stmtInfoDirty DEBUGARG(&treeModf)));
+ fgComputeLife(life, compCurStmt->gtStmt.gtStmtExpr, nullptr, volatileVars,
+ &stmtInfoDirty DEBUGARG(&treeModf));
if (stmtInfoDirty)
{
@@ -2975,7 +2962,7 @@ void Compiler::fgInterBlockLocalVarLiveness()
#ifdef LEGACY_BACKEND
unreached();
#else // !LEGACY_BACKEND
- VarSetOps::AssignNoCopy(this, life, fgComputeLifeLIR(life, block, volatileVars));
+ fgComputeLifeLIR(life, block, volatileVars);
#endif // !LEGACY_BACKEND
}
@@ -3016,7 +3003,7 @@ void Compiler::fgInterBlockLocalVarLiveness()
void Compiler::fgDispBBLiveness(BasicBlock* block)
{
- VARSET_TP VARSET_INIT_NOCOPY(allVars, VarSetOps::Union(this, block->bbLiveIn, block->bbLiveOut));
+ VARSET_TP allVars(VarSetOps::Union(this, block->bbLiveIn, block->bbLiveOut));
printf("BB%02u", block->bbNum);
printf(" IN (%d)=", VarSetOps::Count(this, block->bbLiveIn));
lvaDispVarSet(block->bbLiveIn, allVars);
diff --git a/src/jit/lsra.cpp b/src/jit/lsra.cpp
index 03f383bda5..fbe00150c3 100644
--- a/src/jit/lsra.cpp
+++ b/src/jit/lsra.cpp
@@ -1863,9 +1863,9 @@ void Interval::setLocalNumber(Compiler* compiler, unsigned lclNum, LinearScan* l
// this logic cloned from fgInterBlockLocalVarLiveness
void LinearScan::identifyCandidatesExceptionDataflow()
{
- VARSET_TP VARSET_INIT_NOCOPY(exceptVars, VarSetOps::MakeEmpty(compiler));
- VARSET_TP VARSET_INIT_NOCOPY(filterVars, VarSetOps::MakeEmpty(compiler));
- VARSET_TP VARSET_INIT_NOCOPY(finallyVars, VarSetOps::MakeEmpty(compiler));
+ VARSET_TP exceptVars(VarSetOps::MakeEmpty(compiler));
+ VARSET_TP filterVars(VarSetOps::MakeEmpty(compiler));
+ VARSET_TP finallyVars(VarSetOps::MakeEmpty(compiler));
BasicBlock* block;
foreach_block(compiler, block)
@@ -2003,7 +2003,7 @@ void LinearScan::identifyCandidates()
// for vectors on Arm64, though the actual value may differ.
VarSetOps::AssignNoCopy(compiler, fpCalleeSaveCandidateVars, VarSetOps::MakeEmpty(compiler));
- VARSET_TP VARSET_INIT_NOCOPY(fpMaybeCandidateVars, VarSetOps::MakeEmpty(compiler));
+ VARSET_TP fpMaybeCandidateVars(VarSetOps::MakeEmpty(compiler));
unsigned int floatVarCount = 0;
unsigned int thresholdFPRefCntWtd = 4 * BB_UNITY_WEIGHT;
unsigned int maybeFPRefCntWtd = 2 * BB_UNITY_WEIGHT;
@@ -2549,7 +2549,7 @@ void LinearScan::checkLastUses(BasicBlock* block)
// block that we've already seen). When we encounter a use, if it's
// not in that set, then it's a last use.
- VARSET_TP VARSET_INIT(compiler, temp, block->bbLiveOut);
+ VARSET_TP temp(VarSetOps::MakeCopy(compiler, block->bbLiveOut));
bool foundDiff = false;
auto currentRefPosition = refPositions.rbegin();
@@ -2615,7 +2615,7 @@ void LinearScan::checkLastUses(BasicBlock* block)
++currentRefPosition;
}
- VARSET_TP VARSET_INIT(compiler, temp2, block->bbLiveIn);
+ VARSET_TP temp2(VarSetOps::MakeCopy(compiler, block->bbLiveIn));
VarSetOps::DiffD(compiler, temp2, temp);
VarSetOps::DiffD(compiler, temp, block->bbLiveIn);
@@ -3323,7 +3323,7 @@ public:
VARSET_VALRET_TP
LinearScan::buildUpperVectorSaveRefPositions(GenTree* tree, LsraLocation currentLoc)
{
- VARSET_TP VARSET_INIT_NOCOPY(liveLargeVectors, VarSetOps::MakeEmpty(compiler));
+ VARSET_TP liveLargeVectors(VarSetOps::MakeEmpty(compiler));
regMaskTP fpCalleeKillSet = RBM_NONE;
if (!VarSetOps::IsEmpty(compiler, largeVectorVars))
{
@@ -4035,7 +4035,7 @@ void LinearScan::buildRefPositionsForNode(GenTree* tree,
buildKillPositionsForNode(tree, currentLoc + 1);
#if FEATURE_PARTIAL_SIMD_CALLEE_SAVE
- VARSET_TP VARSET_INIT_NOCOPY(liveLargeVectors, VarSetOps::UninitVal());
+ VARSET_TP liveLargeVectors(VarSetOps::UninitVal());
if (RBM_FLT_CALLEE_SAVED != RBM_NONE)
{
// Build RefPositions for saving any live large vectors.
@@ -4624,7 +4624,7 @@ void LinearScan::buildIntervals()
// TODO-CQ: Consider how best to tune this. Currently, if we create DummyDefs for uninitialized
// variables (which may actually be initialized along the dynamically executed paths, but not
// on all static paths), we wind up with excessive liveranges for some of these variables.
- VARSET_TP VARSET_INIT(compiler, newLiveIn, block->bbLiveIn);
+ VARSET_TP newLiveIn(VarSetOps::MakeCopy(compiler, block->bbLiveIn));
if (predBlock)
{
JITDUMP("\n\nSetting BB%02u as the predecessor for determining incoming variable registers of BB%02u\n",
@@ -4713,7 +4713,7 @@ void LinearScan::buildIntervals()
// Note that a block ending with GT_JMP has no successors and hence the variables
// for which dummy use ref positions are added are arguments of the method.
- VARSET_TP VARSET_INIT(compiler, expUseSet, block->bbLiveOut);
+ VARSET_TP expUseSet(VarSetOps::MakeCopy(compiler, block->bbLiveOut));
BasicBlock* nextBlock = getNextBlock();
if (nextBlock != nullptr)
{
@@ -6668,18 +6668,18 @@ void LinearScan::processBlockStartLocations(BasicBlock* currentBlock, bool alloc
VarToRegMap inVarToRegMap = getInVarToRegMap(currentBlock->bbNum);
bool hasCriticalInEdge = blockInfo[currentBlock->bbNum].hasCriticalInEdge;
- VARSET_TP VARSET_INIT_NOCOPY(liveIn, currentBlock->bbLiveIn);
+ const VARSET_TP* liveIn = &currentBlock->bbLiveIn;
#ifdef DEBUG
if (getLsraExtendLifeTimes())
{
- VarSetOps::AssignNoCopy(compiler, liveIn, compiler->lvaTrackedVars);
+ liveIn = &compiler->lvaTrackedVars;
}
// If we are rotating register assignments at block boundaries, we want to make the
// inactive registers available for the rotation.
regMaskTP inactiveRegs = RBM_NONE;
#endif // DEBUG
regMaskTP liveRegs = RBM_NONE;
- VARSET_ITER_INIT(compiler, iter, liveIn, varIndex);
+ VARSET_ITER_INIT(compiler, iter, *liveIn, varIndex);
while (iter.NextElem(&varIndex))
{
unsigned varNum = compiler->lvaTrackedToVarNum[varIndex];
@@ -6893,15 +6893,15 @@ void LinearScan::processBlockEndLocations(BasicBlock* currentBlock)
assert(currentBlock != nullptr && currentBlock->bbNum == curBBNum);
VarToRegMap outVarToRegMap = getOutVarToRegMap(curBBNum);
- VARSET_TP VARSET_INIT_NOCOPY(liveOut, currentBlock->bbLiveOut);
+ const VARSET_TP* liveOut = &currentBlock->bbLiveOut;
#ifdef DEBUG
if (getLsraExtendLifeTimes())
{
- VarSetOps::AssignNoCopy(compiler, liveOut, compiler->lvaTrackedVars);
+ liveOut = &compiler->lvaTrackedVars;
}
#endif // DEBUG
regMaskTP liveRegs = RBM_NONE;
- VARSET_ITER_INIT(compiler, iter, liveOut, varIndex);
+ VARSET_ITER_INIT(compiler, iter, *liveOut, varIndex);
while (iter.NextElem(&varIndex))
{
Interval* interval = getIntervalForLocalVar(varIndex);
@@ -9325,16 +9325,15 @@ void LinearScan::addResolution(
void LinearScan::handleOutgoingCriticalEdges(BasicBlock* block)
{
- VARSET_TP VARSET_INIT_NOCOPY(outResolutionSet,
- VarSetOps::Intersection(compiler, block->bbLiveOut, resolutionCandidateVars));
+ VARSET_TP outResolutionSet(VarSetOps::Intersection(compiler, block->bbLiveOut, resolutionCandidateVars));
if (VarSetOps::IsEmpty(compiler, outResolutionSet))
{
return;
}
- VARSET_TP VARSET_INIT_NOCOPY(sameResolutionSet, VarSetOps::MakeEmpty(compiler));
- VARSET_TP VARSET_INIT_NOCOPY(sameLivePathsSet, VarSetOps::MakeEmpty(compiler));
- VARSET_TP VARSET_INIT_NOCOPY(singleTargetSet, VarSetOps::MakeEmpty(compiler));
- VARSET_TP VARSET_INIT_NOCOPY(diffResolutionSet, VarSetOps::MakeEmpty(compiler));
+ VARSET_TP sameResolutionSet(VarSetOps::MakeEmpty(compiler));
+ VARSET_TP sameLivePathsSet(VarSetOps::MakeEmpty(compiler));
+ VARSET_TP singleTargetSet(VarSetOps::MakeEmpty(compiler));
+ VARSET_TP diffResolutionSet(VarSetOps::MakeEmpty(compiler));
// Get the outVarToRegMap for this block
VarToRegMap outVarToRegMap = getOutVarToRegMap(block->bbNum);
@@ -9515,8 +9514,7 @@ void LinearScan::handleOutgoingCriticalEdges(BasicBlock* block)
// Check only the vars in diffResolutionSet that are live-in to this successor.
bool needsResolution = false;
VarToRegMap succInVarToRegMap = getInVarToRegMap(succBlock->bbNum);
- VARSET_TP VARSET_INIT_NOCOPY(edgeResolutionSet,
- VarSetOps::Intersection(compiler, diffResolutionSet, succBlock->bbLiveIn));
+ VARSET_TP edgeResolutionSet(VarSetOps::Intersection(compiler, diffResolutionSet, succBlock->bbLiveIn));
VARSET_ITER_INIT(compiler, iter, edgeResolutionSet, varIndex);
while (iter.NextElem(&varIndex))
{
@@ -9611,8 +9609,7 @@ void LinearScan::resolveEdges()
// we may need resolution at the beginning of this block.
// This may be true even if it's the block we used for starting locations,
// if a variable was spilled.
- VARSET_TP VARSET_INIT_NOCOPY(inResolutionSet,
- VarSetOps::Intersection(compiler, block->bbLiveIn, resolutionCandidateVars));
+ VARSET_TP inResolutionSet(VarSetOps::Intersection(compiler, block->bbLiveIn, resolutionCandidateVars));
if (!VarSetOps::IsEmpty(compiler, inResolutionSet))
{
if (uniquePredBlock != nullptr)
@@ -9641,8 +9638,8 @@ void LinearScan::resolveEdges()
BasicBlock* succBlock = block->GetSucc(0, compiler);
if (succBlock->GetUniquePred(compiler) == nullptr)
{
- VARSET_TP VARSET_INIT_NOCOPY(outResolutionSet, VarSetOps::Intersection(compiler, succBlock->bbLiveIn,
- resolutionCandidateVars));
+ VARSET_TP outResolutionSet(
+ VarSetOps::Intersection(compiler, succBlock->bbLiveIn, resolutionCandidateVars));
if (!VarSetOps::IsEmpty(compiler, outResolutionSet))
{
resolveEdge(block, succBlock, ResolveJoin, outResolutionSet);
diff --git a/src/jit/optimizer.cpp b/src/jit/optimizer.cpp
index 1e50e537e0..ea17831d39 100644
--- a/src/jit/optimizer.cpp
+++ b/src/jit/optimizer.cpp
@@ -5866,7 +5866,7 @@ void Compiler::optHoistThisLoop(unsigned lnum, LoopHoistContext* hoistCtxt)
}
#endif
- VARSET_TP VARSET_INIT_NOCOPY(loopVars, VarSetOps::Intersection(this, pLoopDsc->lpVarInOut, pLoopDsc->lpVarUseDef));
+ VARSET_TP loopVars(VarSetOps::Intersection(this, pLoopDsc->lpVarInOut, pLoopDsc->lpVarUseDef));
pLoopDsc->lpVarInOutCount = VarSetOps::Count(this, pLoopDsc->lpVarInOut);
pLoopDsc->lpLoopVarCount = VarSetOps::Count(this, loopVars);
@@ -5880,8 +5880,8 @@ void Compiler::optHoistThisLoop(unsigned lnum, LoopHoistContext* hoistCtxt)
// Since 64-bit variables take up two registers on 32-bit targets, we increase
// the Counts such that each TYP_LONG variable counts twice.
//
- VARSET_TP VARSET_INIT_NOCOPY(loopLongVars, VarSetOps::Intersection(this, loopVars, lvaLongVars));
- VARSET_TP VARSET_INIT_NOCOPY(inOutLongVars, VarSetOps::Intersection(this, pLoopDsc->lpVarInOut, lvaLongVars));
+ VARSET_TP loopLongVars(VarSetOps::Intersection(this, loopVars, lvaLongVars));
+ VARSET_TP inOutLongVars(VarSetOps::Intersection(this, pLoopDsc->lpVarInOut, lvaLongVars));
#ifdef DEBUG
if (verbose)
@@ -5914,8 +5914,8 @@ void Compiler::optHoistThisLoop(unsigned lnum, LoopHoistContext* hoistCtxt)
if (floatVarsCount > 0)
{
- VARSET_TP VARSET_INIT_NOCOPY(loopFPVars, VarSetOps::Intersection(this, loopVars, lvaFloatVars));
- VARSET_TP VARSET_INIT_NOCOPY(inOutFPVars, VarSetOps::Intersection(this, pLoopDsc->lpVarInOut, lvaFloatVars));
+ VARSET_TP loopFPVars(VarSetOps::Intersection(this, loopVars, lvaFloatVars));
+ VARSET_TP inOutFPVars(VarSetOps::Intersection(this, pLoopDsc->lpVarInOut, lvaFloatVars));
pLoopDsc->lpLoopVarFPCount = VarSetOps::Count(this, loopFPVars);
pLoopDsc->lpVarInOutFPCount = VarSetOps::Count(this, inOutFPVars);
@@ -7481,7 +7481,7 @@ GenTreePtr Compiler::optFindLocalInit(BasicBlock* block,
// If any local in the RHS is killed in intervening code, or RHS has an indirection, return NULL.
varRefKinds rhsRefs = VR_NONE;
- VARSET_TP VARSET_INIT_NOCOPY(rhsLocals, VarSetOps::UninitVal());
+ VARSET_TP rhsLocals(VarSetOps::UninitVal());
bool b = lvaLclVarRefs(rhs, nullptr, &rhsRefs, &rhsLocals);
if (!b || !VarSetOps::IsEmptyIntersection(this, rhsLocals, *pKilledInOut) || (rhsRefs != VR_NONE))
{
diff --git a/src/jit/rangecheck.cpp b/src/jit/rangecheck.cpp
index 5d09cb1f52..cbbac84a9b 100644
--- a/src/jit/rangecheck.cpp
+++ b/src/jit/rangecheck.cpp
@@ -479,7 +479,7 @@ void RangeCheck::SetDef(UINT64 hash, Location* loc)
}
// Merge assertions on the edge flowing into the block about a variable.
-void RangeCheck::MergeEdgeAssertions(GenTreePtr tree, const ASSERT_VALARG_TP assertions, Range* pRange)
+void RangeCheck::MergeEdgeAssertions(GenTreePtr tree, ASSERT_VALARG_TP assertions, Range* pRange)
{
if (BitVecOps::IsEmpty(m_pCompiler->apTraits, assertions))
{
diff --git a/src/jit/rangecheck.h b/src/jit/rangecheck.h
index b00bfb8a67..e9bdae1bdf 100644
--- a/src/jit/rangecheck.h
+++ b/src/jit/rangecheck.h
@@ -542,7 +542,7 @@ public:
// Inspect the "assertions" and extract assertions about the given "phiArg" and
// refine the "pRange" value.
- void MergeEdgeAssertions(GenTreePtr phiArg, const ASSERT_VALARG_TP assertions, Range* pRange);
+ void MergeEdgeAssertions(GenTreePtr phiArg, ASSERT_VALARG_TP assertions, Range* pRange);
// The maximum possible value of the given "limit." If such a value could not be determined
// return "false." For example: ARRLEN_MAX for array length.
diff --git a/src/jit/regalloc.cpp b/src/jit/regalloc.cpp
index 57651cae4a..2f2d40ab23 100644
--- a/src/jit/regalloc.cpp
+++ b/src/jit/regalloc.cpp
@@ -474,7 +474,7 @@ void Compiler::raDispFPlifeInfo()
dispLifeSet(this, optAllFloatVars, block->bbLiveIn);
printf("]\n\n");
- VARSET_TP VARSET_INIT(this, life, block->bbLiveIn);
+ VARSET_TP life(VarSetOps::MakeCopy(this, block->bbLiveIn));
for (stmt = block->bbTreeList; stmt; stmt = stmt->gtNext)
{
GenTreePtr tree;
@@ -979,7 +979,7 @@ bool Compiler::rpRecordRegIntf(regMaskTP regMask, VARSET_VALARG_TP life DEBUGARG
if (regMask & regBit)
{
- VARSET_TP VARSET_INIT_NOCOPY(newIntf, VarSetOps::Diff(this, life, raLclRegIntf[regNum]));
+ VARSET_TP newIntf(VarSetOps::Diff(this, life, raLclRegIntf[regNum]));
if (!VarSetOps::IsEmpty(this, newIntf))
{
#ifdef DEBUG
@@ -1026,7 +1026,7 @@ bool Compiler::rpRecordVarIntf(unsigned varNum, VARSET_VALARG_TP intfVar DEBUGAR
noway_assert((varNum >= 0) && (varNum < lvaTrackedCount));
noway_assert(!VarSetOps::IsEmpty(this, intfVar));
- VARSET_TP VARSET_INIT_NOCOPY(oneVar, VarSetOps::MakeEmpty(this));
+ VARSET_TP oneVar(VarSetOps::MakeEmpty(this));
VarSetOps::AddElemD(this, oneVar, varNum);
bool newIntf = fgMarkIntf(intfVar, oneVar);
@@ -1328,14 +1328,14 @@ RET:
// Add a register interference to each of the last use variables
if (!VarSetOps::IsEmpty(this, rpLastUseVars) || !VarSetOps::IsEmpty(this, rpUseInPlace))
{
- VARSET_TP VARSET_INIT_NOCOPY(lastUse, VarSetOps::MakeEmpty(this));
+ VARSET_TP lastUse(VarSetOps::MakeEmpty(this));
VarSetOps::Assign(this, lastUse, rpLastUseVars);
- VARSET_TP VARSET_INIT_NOCOPY(inPlaceUse, VarSetOps::MakeEmpty(this));
+ VARSET_TP inPlaceUse(VarSetOps::MakeEmpty(this));
VarSetOps::Assign(this, inPlaceUse, rpUseInPlace);
// While we still have any lastUse or inPlaceUse bits
- VARSET_TP VARSET_INIT_NOCOPY(useUnion, VarSetOps::Union(this, lastUse, inPlaceUse));
+ VARSET_TP useUnion(VarSetOps::Union(this, lastUse, inPlaceUse));
- VARSET_TP VARSET_INIT_NOCOPY(varAsSet, VarSetOps::MakeEmpty(this));
+ VARSET_TP varAsSet(VarSetOps::MakeEmpty(this));
VARSET_ITER_INIT(this, iter, useUnion, varNum);
while (iter.NextElem(&varNum))
{
@@ -1398,7 +1398,7 @@ regMaskTP Compiler::rpPredictAddressMode(
bool rev;
bool hasTwoAddConst = false;
bool restoreLastUseVars = false;
- VARSET_TP VARSET_INIT_NOCOPY(oldLastUseVars, VarSetOps::MakeEmpty(this));
+ VARSET_TP oldLastUseVars(VarSetOps::MakeEmpty(this));
/* do we need to save and restore the rpLastUseVars set ? */
if ((rsvdRegs & RBM_LASTUSE) && (lenCSE == NULL))
@@ -1947,10 +1947,10 @@ regMaskTP Compiler::rpPredictTreeRegUse(GenTreePtr tree,
rpPredictReg op1PredictReg;
rpPredictReg op2PredictReg;
LclVarDsc* varDsc = NULL;
- VARSET_TP VARSET_INIT_NOCOPY(oldLastUseVars, VarSetOps::UninitVal());
+ VARSET_TP oldLastUseVars(VarSetOps::UninitVal());
- VARSET_TP VARSET_INIT_NOCOPY(varBits, VarSetOps::UninitVal());
- VARSET_TP VARSET_INIT_NOCOPY(lastUseVarBits, VarSetOps::MakeEmpty(this));
+ VARSET_TP varBits(VarSetOps::UninitVal());
+ VARSET_TP lastUseVarBits(VarSetOps::MakeEmpty(this));
bool restoreLastUseVars = false;
regMaskTP interferingRegs = RBM_NONE;
@@ -2431,7 +2431,7 @@ regMaskTP Compiler::rpPredictTreeRegUse(GenTreePtr tree,
LclVarDsc* fldVar = lvaTable + varNum;
if (fldVar->lvTracked)
{
- VARSET_TP VARSET_INIT_NOCOPY(fldBit, VarSetOps::MakeSingleton(this, fldVar->lvVarIndex));
+ VARSET_TP fldBit(VarSetOps::MakeSingleton(this, fldVar->lvVarIndex));
rpRecordRegIntf(regMask, fldBit DEBUGARG(
"need scratch register when pushing a small field of a struct"));
}
@@ -2443,7 +2443,7 @@ regMaskTP Compiler::rpPredictTreeRegUse(GenTreePtr tree,
if (lastUse)
{
VarSetOps::UnionD(this, rpLastUseVars, lastUseVarBits);
- VARSET_TP VARSET_INIT(this, varAsSet, lastUseVarBits);
+ VARSET_TP varAsSet(VarSetOps::MakeCopy(this, lastUseVarBits));
/*
* Add interference from any previously locked temps into this last use variable.
@@ -2483,7 +2483,7 @@ regMaskTP Compiler::rpPredictTreeRegUse(GenTreePtr tree,
GenTreePtr opsPtr[3];
regMaskTP regsPtr[3];
- VARSET_TP VARSET_INIT_NOCOPY(startAsgUseInPlaceVars, VarSetOps::UninitVal());
+ VARSET_TP startAsgUseInPlaceVars(VarSetOps::UninitVal());
switch (oper)
{
@@ -3216,7 +3216,7 @@ regMaskTP Compiler::rpPredictTreeRegUse(GenTreePtr tree,
case GT_NULLCHECK: // At this point, nullcheck is just like an IND...
{
bool intoReg = true;
- VARSET_TP VARSET_INIT(this, startIndUseInPlaceVars, rpUseInPlace);
+ VARSET_TP startIndUseInPlaceVars(VarSetOps::MakeCopy(this, rpUseInPlace));
if (fgIsIndirOfAddrOfLocal(tree) != NULL)
{
@@ -3961,7 +3961,7 @@ regMaskTP Compiler::rpPredictTreeRegUse(GenTreePtr tree,
// we add an interference with REG_SHIFT for any other LclVars alive at op2
if (REG_SHIFT != REG_NA)
{
- VARSET_TP VARSET_INIT(this, liveSet, compCurLife);
+ VARSET_TP liveSet(VarSetOps::MakeCopy(this, compCurLife));
while (op2->gtOper == GT_COMMA)
{
@@ -4006,8 +4006,7 @@ regMaskTP Compiler::rpPredictTreeRegUse(GenTreePtr tree,
varDsc = lvaTable + op1->gtLclVar.gtLclNum;
if (varDsc->lvTracked)
{
- VARSET_TP VARSET_INIT_NOCOPY(op1VarBit,
- VarSetOps::MakeSingleton(this, varDsc->lvVarIndex));
+ VARSET_TP op1VarBit(VarSetOps::MakeSingleton(this, varDsc->lvVarIndex));
// Ensure that we don't assign a Non-Byteable register for op1's LCL_VAR
rpRecordRegIntf(RBM_NON_BYTE_REGS, op1VarBit DEBUGARG("Non Byte Register"));
@@ -4070,7 +4069,7 @@ regMaskTP Compiler::rpPredictTreeRegUse(GenTreePtr tree,
if (op2VarDsc->lvTracked)
{
- VARSET_TP VARSET_INIT_NOCOPY(op2VarBit, VarSetOps::MakeSingleton(this, op2VarDsc->lvVarIndex));
+ VARSET_TP op2VarBit(VarSetOps::MakeSingleton(this, op2VarDsc->lvVarIndex));
rpRecordRegIntf(rsvdRegs, op2VarBit DEBUGARG("comma use"));
}
}
@@ -4112,7 +4111,7 @@ regMaskTP Compiler::rpPredictTreeRegUse(GenTreePtr tree,
lockedRegs &= ~tmpMask;
}
{
- VARSET_TP VARSET_INIT(this, startQmarkCondUseInPlaceVars, rpUseInPlace);
+ VARSET_TP startQmarkCondUseInPlaceVars(VarSetOps::MakeCopy(this, rpUseInPlace));
/* Evaluate the <cond> subtree */
rpPredictTreeRegUse(op1, PREDICT_NONE, lockedRegs, RBM_LASTUSE);
@@ -4172,7 +4171,7 @@ regMaskTP Compiler::rpPredictTreeRegUse(GenTreePtr tree,
CLANG_FORMAT_COMMENT_ANCHOR;
#ifdef DEBUG
- VARSET_TP VARSET_INIT(this, postThenLive, compCurLife);
+ VARSET_TP postThenLive(VarSetOps::MakeCopy(this, compCurLife));
#endif
VarSetOps::Assign(this, compCurLife, tree->gtQmark.gtElseLiveSet);
@@ -4544,7 +4543,7 @@ regMaskTP Compiler::rpPredictTreeRegUse(GenTreePtr tree,
rpPredictTreeRegUse(args, PREDICT_NONE, lockedRegs, RBM_LASTUSE);
}
}
- VARSET_TP VARSET_INIT_NOCOPY(startArgUseInPlaceVars, VarSetOps::UninitVal());
+ VARSET_TP startArgUseInPlaceVars(VarSetOps::UninitVal());
VarSetOps::Assign(this, startArgUseInPlaceVars, rpUseInPlace);
/* process argument list */
@@ -5425,7 +5424,7 @@ regMaskTP Compiler::rpPredictAssignRegVars(regMaskTP regAvail)
*
*/
- VARSET_TP VARSET_INIT_NOCOPY(unprocessedVars, VarSetOps::MakeFull(this));
+ VARSET_TP unprocessedVars(VarSetOps::MakeFull(this));
unsigned FPRegVarLiveInCnt;
FPRegVarLiveInCnt = 0; // How many enregistered doubles are live on entry to the method
@@ -5653,7 +5652,7 @@ regMaskTP Compiler::rpPredictAssignRegVars(regMaskTP regAvail)
unsigned int totalRefCntWtd = varDsc->lvRefCntWtd;
// psc is abbeviation for possibleSameColor
- VARSET_TP VARSET_INIT_NOCOPY(pscVarSet, VarSetOps::Diff(this, unprocessedVars, lvaVarIntf[varIndex]));
+ VARSET_TP pscVarSet(VarSetOps::Diff(this, unprocessedVars, lvaVarIntf[varIndex]));
VARSET_ITER_INIT(this, pscIndexIter, pscVarSet, pscIndex);
while (pscIndexIter.NextElem(&pscIndex))
diff --git a/src/jit/scopeinfo.cpp b/src/jit/scopeinfo.cpp
index 1d1a634825..2fd08f0e24 100644
--- a/src/jit/scopeinfo.cpp
+++ b/src/jit/scopeinfo.cpp
@@ -656,7 +656,7 @@ void CodeGen::siUpdate()
}
#endif // FEATURE_EH_FUNCLETS
- VARSET_TP VARSET_INIT_NOCOPY(killed, VarSetOps::Diff(compiler, siLastLife, compiler->compCurLife));
+ VARSET_TP killed(VarSetOps::Diff(compiler, siLastLife, compiler->compCurLife));
assert(VarSetOps::IsSubset(compiler, killed, compiler->lvaTrackedVars));
VARSET_ITER_INIT(compiler, iter, killed, i);
@@ -1252,4 +1252,4 @@ void CodeGen::psiEndProlog()
{
psiEndPrologScope(scope);
}
-} \ No newline at end of file
+}
diff --git a/src/jit/varset.h b/src/jit/varset.h
index 6a2c37ed40..d8a9a41591 100644
--- a/src/jit/varset.h
+++ b/src/jit/varset.h
@@ -106,6 +106,7 @@ const unsigned lclMAX_TRACKED = UInt64Bits;
#endif
// These types should be used as the types for VARSET_TP arguments and return values, respectively.
+// Arg type represent the read only argument type, that can't be modified.
typedef VarSetOpsRaw::ValArgType VARSET_VALARG_TP;
typedef VarSetOpsRaw::RetValType VARSET_VALRET_TP;
@@ -177,29 +178,10 @@ const unsigned lclMAX_ALLSET_TRACKED = UInt64Bits;
#error "Unrecognized BitSet implemention for AllVarSet."
#endif
-// These types should be used as the types for VARSET_TP arguments and return values, respectively.
+// These types should be used as the types for ALLVARSET_TP arguments and return values, respectively.
typedef AllVarSetOps::ValArgType ALLVARSET_VALARG_TP;
typedef AllVarSetOps::RetValType ALLVARSET_VALRET_TP;
-// Initialize "varName" to "initVal." Copies contents, not references; if "varName" is uninitialized, allocates a var
-// set for it (using "comp" for any necessary allocation), and copies the contents of "initVal" into it.
-#define VARSET_INIT(comp, varName, initVal) varName(VarSetOps::MakeCopy(comp, initVal))
-#define ALLVARSET_INIT(comp, varName, initVal) varName(AllVarSetOps::MakeCopy(comp, initVal))
-
-// Initializes "varName" to "initVal", without copying: if "initVal" is an indirect representation, copies its
-// pointer into "varName".
-#if defined(DEBUG) && VARSET_REP_IS_CLASS
-#define VARSET_INIT_NOCOPY(varName, initVal) varName(initVal, 0)
-#else
-#define VARSET_INIT_NOCOPY(varName, initVal) varName(initVal)
-#endif
-
-#if defined(DEBUG) && ALLVARSET_REP_IS_CLASS
-#define ALLVARSET_INIT_NOCOPY(varName, initVal) varName(initVal, 0)
-#else
-#define ALLVARSET_INIT_NOCOPY(varName, initVal) varName(initVal)
-#endif
-
// The iterator pattern.
// Use this to initialize an iterator "iterName" to iterate over a VARSET_TP "vs".