diff options
| author | Serge Guelton <sguelton@quarkslab.com> | 2017-11-13 20:57:40 +0000 |
|---|---|---|
| committer | Serge Guelton <sguelton@quarkslab.com> | 2017-11-13 20:57:40 +0000 |
| commit | 25cbe525ef1b18855d1ec67a1724f965c62b3e9c (patch) | |
| tree | 5651c764faf81da2b77e2cfacc4e1fbce644bd34 | |
| parent | c691d4eef25bfa9815366dad64fbefb06ba6ffb7 (diff) | |
| download | bcm5719-llvm-25cbe525ef1b18855d1ec67a1724f965c62b3e9c.tar.gz bcm5719-llvm-25cbe525ef1b18855d1ec67a1724f965c62b3e9c.zip | |
Reorder Value.def to optimize code size
If the first values in Value.def is the range of constant, then the code
generated by `isa<Constant>` is smaller by one operation (basically, an add is
removed). It turns out this small optimization reduces the size of the
statically linked clang binary by 400ko on my laptop. The theoritical
performance gain is non visible from my benchmarks, but the size dropdown is.
Differential Revision: https://reviews.llvm.org/D39373
llvm-svn: 318083
| -rw-r--r-- | llvm/include/llvm/IR/Value.def | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/llvm/include/llvm/IR/Value.def b/llvm/include/llvm/IR/Value.def index cebd7f7297e..e2ddba0aa15 100644 --- a/llvm/include/llvm/IR/Value.def +++ b/llvm/include/llvm/IR/Value.def @@ -56,16 +56,10 @@ #define HANDLE_CONSTANT_MARKER(MarkerName, ValueName) #endif -HANDLE_VALUE(Argument) -HANDLE_VALUE(BasicBlock) - -// FIXME: It's awkward that Value.def knows about classes in Analysis. While -// this doesn't introduce a strict link or include dependency, we should remove -// the circular dependency eventually. -HANDLE_MEMORY_VALUE(MemoryUse) -HANDLE_MEMORY_VALUE(MemoryDef) -HANDLE_MEMORY_VALUE(MemoryPhi) +// Having constant first makes the range check for isa<Constant> faster +// and smaller by one operation. +// Constant HANDLE_GLOBAL_VALUE(Function) HANDLE_GLOBAL_VALUE(GlobalAlias) HANDLE_GLOBAL_VALUE(GlobalIFunc) @@ -88,13 +82,6 @@ HANDLE_CONSTANT(ConstantFP) HANDLE_CONSTANT(ConstantPointerNull) HANDLE_CONSTANT(ConstantTokenNone) -HANDLE_METADATA_VALUE(MetadataAsValue) -HANDLE_INLINE_ASM_VALUE(InlineAsm) - -HANDLE_INSTRUCTION(Instruction) -// Enum values starting at InstructionVal are used for Instructions; -// don't add new values here! - HANDLE_CONSTANT_MARKER(ConstantFirstVal, Function) HANDLE_CONSTANT_MARKER(ConstantLastVal, ConstantTokenNone) HANDLE_CONSTANT_MARKER(ConstantDataFirstVal, UndefValue) @@ -102,6 +89,24 @@ HANDLE_CONSTANT_MARKER(ConstantDataLastVal, ConstantTokenNone) HANDLE_CONSTANT_MARKER(ConstantAggregateFirstVal, ConstantArray) HANDLE_CONSTANT_MARKER(ConstantAggregateLastVal, ConstantVector) +HANDLE_VALUE(Argument) +HANDLE_VALUE(BasicBlock) + + +HANDLE_METADATA_VALUE(MetadataAsValue) +HANDLE_INLINE_ASM_VALUE(InlineAsm) + +// FIXME: It's awkward that Value.def knows about classes in Analysis. While +// this doesn't introduce a strict link or include dependency, we should remove +// the circular dependency eventually. +HANDLE_MEMORY_VALUE(MemoryUse) +HANDLE_MEMORY_VALUE(MemoryDef) +HANDLE_MEMORY_VALUE(MemoryPhi) + +HANDLE_INSTRUCTION(Instruction) +// Enum values starting at InstructionVal are used for Instructions; +// don't add new values here! + #undef HANDLE_MEMORY_VALUE #undef HANDLE_GLOBAL_VALUE #undef HANDLE_CONSTANT |

