From 2337c1fe1320d61121f68820a3356f0c7392f720 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 20 Feb 2016 10:40:34 +0000 Subject: [PATCH] [LVI] Move ConstantRanges instead of copying. No functional change intended. Copying small (<= 64 bits) APInts isn't expensive but bloats code by generating the slow path everywhere. Moving doesn't care about the size of the value. llvm-svn: 261426 --- llvm/lib/Analysis/LazyValueInfo.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp index 8f1211100514..6a7fe1154be5 100644 --- a/llvm/lib/Analysis/LazyValueInfo.cpp +++ b/llvm/lib/Analysis/LazyValueInfo.cpp @@ -102,7 +102,7 @@ public: } static LVILatticeVal getRange(ConstantRange CR) { LVILatticeVal Res; - Res.markConstantRange(CR); + Res.markConstantRange(std::move(CR)); return Res; } static LVILatticeVal getOverdefined() { @@ -176,13 +176,13 @@ public: } /// Return true if this is a change in status. - bool markConstantRange(const ConstantRange NewR) { + bool markConstantRange(ConstantRange NewR) { if (isConstantRange()) { if (NewR.isEmptySet()) return markOverdefined(); bool changed = Range != NewR; - Range = NewR; + Range = std::move(NewR); return changed; } @@ -191,7 +191,7 @@ public: return markOverdefined(); Tag = constantrange; - Range = NewR; + Range = std::move(NewR); return true; } @@ -354,7 +354,7 @@ static LVILatticeVal intersect(LVILatticeVal A, LVILatticeVal B) { // Note: An empty range is implicitly converted to overdefined internally. // TODO: We could instead use Undefined here since we've proven a conflict // and thus know this path must be unreachable. - return LVILatticeVal::getRange(Range); + return LVILatticeVal::getRange(std::move(Range)); } //===----------------------------------------------------------------------===// @@ -612,8 +612,7 @@ static LVILatticeVal getFromRangeMetadata(Instruction *BBI) { case Instruction::Invoke: if (MDNode *Ranges = BBI->getMetadata(LLVMContext::MD_range)) if (isa(BBI->getType())) { - ConstantRange Result = getConstantRangeFromMetadata(*Ranges); - return LVILatticeVal::getRange(Result); + return LVILatticeVal::getRange(getConstantRangeFromMetadata(*Ranges)); } break; }; @@ -1054,7 +1053,7 @@ bool getValueFromFromCondition(Value *Val, ICmpInst *ICI, // If we're interested in the false dest, invert the condition. if (!isTrueDest) TrueValues = TrueValues.inverse(); - Result = LVILatticeVal::getRange(TrueValues); + Result = LVILatticeVal::getRange(std::move(TrueValues)); return true; } } @@ -1114,7 +1113,7 @@ static bool getEdgeValueLocal(Value *Val, BasicBlock *BBFrom, } else if (i.getCaseSuccessor() == BBTo) EdgesVals = EdgesVals.unionWith(EdgeVal); } - Result = LVILatticeVal::getRange(EdgesVals); + Result = LVILatticeVal::getRange(std::move(EdgesVals)); return true; } return false;