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

Unified Diff: src/IceOperand.h

Issue 1768173002: Subzero: Count lookups of each constant value in the constant pool. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 9 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
« no previous file with comments | « src/IceGlobalContext.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceOperand.h
diff --git a/src/IceOperand.h b/src/IceOperand.h
index f3a66fcba0c0ee488a802c6cb4258a97a7ef800d..32397362c657a08abd30c122d68d2cb1132083da 100644
--- a/src/IceOperand.h
+++ b/src/IceOperand.h
@@ -27,6 +27,7 @@
#include "llvm/Support/Format.h"
#include <limits>
+#include <type_traits>
namespace Ice {
@@ -125,6 +126,9 @@ public:
(void)Ctx;
llvm::report_fatal_error("emitPoolLabel not defined for type");
};
+ // Declare the lookup counter to take minimal space in a non-DUMP build.
+ using CounterType =
+ std::conditional<BuildDefs::dump(), uint64_t, uint8_t>::type;
void emit(const Cfg *Func) const override { emit(Func->getTarget()); }
virtual void emit(TargetLowering *Target) const = 0;
@@ -141,19 +145,29 @@ public:
return false;
}
- void setShouldBePooled(bool R) { shouldBePooled = R; }
+ void setShouldBePooled(bool R) { ShouldBePooled = R; }
+ bool getShouldBePooled() const { return ShouldBePooled; }
- bool getShouldBePooled() const { return shouldBePooled; }
+ // This should be thread-safe because the constant pool lock is acquired
+ // before the method is invoked.
+ void updateLookupCount() {
+ if (!BuildDefs::dump())
+ return;
+ ++LookupCount;
+ }
+ CounterType getLookupCount() const { return LookupCount; }
protected:
- Constant(OperandKind Kind, Type Ty)
- : Operand(Kind, Ty), shouldBePooled(false) {
+ Constant(OperandKind Kind, Type Ty) : Operand(Kind, Ty) {
Vars = nullptr;
NumVars = 0;
}
/// Whether we should pool this constant. Usually Float/Double and pooled
/// Integers should be flagged true.
- bool shouldBePooled;
+ bool ShouldBePooled = false;
+ /// Note: If ShouldBePooled is ever removed from the base class, we will want
+ /// to completely disable LookupCount in a non-DUMP build to save space.
+ CounterType LookupCount = 0;
};
/// ConstantPrimitive<> wraps a primitive type.
« no previous file with comments | « src/IceGlobalContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698