Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Unified Diff: src/IceOperand.h

Issue 1318553003: Compute the loop nest depth of each CfgNode and weight Variables by it. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/IceOperand.h
diff --git a/src/IceOperand.h b/src/IceOperand.h
index 946f47dc7a630a43ec3a20c52f52fe34eff96aeb..9638066ec89f157fde02511aa98edc716fc595e6 100644
--- a/src/IceOperand.h
+++ b/src/IceOperand.h
@@ -321,13 +321,15 @@ public:
explicit RegWeight(uint32_t Weight) : Weight(Weight) {}
RegWeight(const RegWeight &) = default;
RegWeight &operator=(const RegWeight &) = default;
- const static uint32_t Inf = ~0; /// Force regalloc to give a register
- const static uint32_t Zero = 0; /// Force regalloc NOT to give a register
+ const static uint32_t Inf = ~0; /// Force regalloc to give a register
+ const static uint32_t Zero = 0; /// Force regalloc NOT to give a register
+ const static uint32_t Max = Inf - 1; /// Max natural weight.
void addWeight(uint32_t Delta) {
if (Delta == Inf)
Weight = Inf;
else if (Weight != Inf)
- Weight += Delta;
+ if (Utils::add_overflow(Weight, Delta, &Weight) || Weight == Inf)
Jim Stichnoth 2015/09/03 23:23:30 This seems to have the interesting property that i
ascull 2015/09/04 00:23:51 In that case Max + 1 = Inf which does not overflow
Jim Stichnoth 2015/09/04 00:47:26 OK, thanks, I'm convinced now.
+ Weight = Max;
}
void addWeight(const RegWeight &Other) { addWeight(Other.Weight); }
void setWeight(uint32_t Val) { Weight = Val; }
@@ -579,7 +581,7 @@ public:
const Inst *getSingleDefinition() const;
const InstDefList &getLatterDefinitions() const { return Definitions; }
CfgNode *getNode() const { return SingleUseNode; }
- uint32_t getUseWeight() const { return UseWeight; }
+ RegWeight getUseWeight() const { return UseWeight; }
void markUse(MetadataKind TrackingKind, const Inst *Instr, CfgNode *Node,
bool IsImplicit);
void markDef(MetadataKind TrackingKind, const Inst *Instr, CfgNode *Node);
@@ -594,7 +596,7 @@ private:
InstDefList Definitions; /// Only used if Kind==VMK_All
const Inst *FirstOrSingleDefinition =
nullptr; /// Is a copy of Definitions[0] if Kind==VMK_All
- uint32_t UseWeight = 0;
+ RegWeight UseWeight;
};
/// VariablesMetadata analyzes and summarizes the metadata for the complete set
@@ -649,7 +651,7 @@ public:
/// Returns the total use weight computed as the sum of uses multiplied by a
/// loop nest depth factor for each use.
- uint32_t getUseWeight(const Variable *Var) const;
+ RegWeight getUseWeight(const Variable *Var) const;
private:
const Cfg *Func;
« src/IceCfgNode.cpp ('K') | « src/IceLoopAnalyzer.cpp ('k') | src/IceOperand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698