Chromium Code Reviews| 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. |