Index: include/llvm/Analysis/ValueLattice.h =================================================================== --- include/llvm/Analysis/ValueLattice.h +++ include/llvm/Analysis/ValueLattice.h @@ -114,6 +114,10 @@ *this = Other; } + ValueLatticeElement(ValueLatticeElement &&Other) : Tag(unknown) { + *this = std::move(Other); + } + /// Custom assignment operator, to ensure Range gets initialized when /// assigning a constant range lattice element. ValueLatticeElement &operator=(const ValueLatticeElement &Other) { @@ -122,12 +126,6 @@ if (isConstantRange() && !Other.isConstantRange()) Range.~ConstantRange(); - // If we change the state of this from a valid ConstVal to another a state - // without a valid ConstVal, zero the pointer. - if ((isConstant() || isNotConstant()) && !Other.isConstant() && - !Other.isNotConstant()) - ConstVal = nullptr; - switch (Other.Tag) { case constantrange: case constantrange_including_undef: @@ -150,6 +148,30 @@ return *this; } + ValueLatticeElement &operator=(ValueLatticeElement &&Other) { + if (isConstantRange()) + Range.~ConstantRange(); + + switch (Other.Tag) { + case constantrange: + case constantrange_including_undef: + new (&Range) ConstantRange(std::move(Other.Range)); + NumRangeExtensions = Other.NumRangeExtensions; + break; + case constant: + case notconstant: + ConstVal = Other.ConstVal; + break; + case overdefined: + case unknown: + case undef: + break; + } + Tag = Other.Tag; + Other.Tag = unknown; + return *this; + } + static ValueLatticeElement get(Constant *C) { ValueLatticeElement Res; if (isa(C))