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

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: 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
« src/IceGlobalContext.cpp ('K') | « 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..810fb65aa2296de1c9046b9b59a7a20986dd8445 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;
John 2016/03/07 15:50:26 What about void instead? Then you could use enable
Jim Stichnoth 2016/03/07 16:11:10 You also need to conditionally declare the field a
void emit(const Cfg *Func) const override { emit(Func->getTarget()); }
virtual void emit(TargetLowering *Target) const = 0;
@@ -142,18 +146,26 @@ public:
}
void setShouldBePooled(bool R) { shouldBePooled = R; }
-
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;
+ CounterType LookupCount = 0;
};
/// ConstantPrimitive<> wraps a primitive type.
« src/IceGlobalContext.cpp ('K') | « src/IceGlobalContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698