Skip to content

Commit 010c0ad

Browse files
committed
IR: Reorder ConstantData enum values
This sorts ConstantData to the low values, so we can perform a hasUseList check in a single compare instead of requiring 2 compares plus an and for the range check.
1 parent b0bf48d commit 010c0ad

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

llvm/include/llvm/IR/Value.def

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,11 @@
6969
#define HANDLE_CONSTANT_EXCLUDE_LLVM_C_API(ValueName)
7070
#endif
7171

72-
// Having constant first makes the range check for isa<Constant> faster
73-
// and smaller by one operation.
72+
// Having constant first makes the range check for isa<Constant> faster and
73+
// smaller by one operation. Further, keep ConstantData as the first subset so
74+
// it's also as fast.
7475

7576
// Constant
76-
HANDLE_GLOBAL_VALUE(Function)
77-
HANDLE_GLOBAL_VALUE(GlobalAlias)
78-
HANDLE_GLOBAL_VALUE(GlobalIFunc)
79-
HANDLE_GLOBAL_VALUE(GlobalVariable)
80-
HANDLE_CONSTANT(BlockAddress)
81-
HANDLE_CONSTANT(ConstantExpr)
82-
HANDLE_CONSTANT_EXCLUDE_LLVM_C_API(DSOLocalEquivalent)
83-
HANDLE_CONSTANT_EXCLUDE_LLVM_C_API(NoCFIValue)
84-
HANDLE_CONSTANT(ConstantPtrAuth)
85-
86-
// ConstantAggregate.
87-
HANDLE_CONSTANT(ConstantArray)
88-
HANDLE_CONSTANT(ConstantStruct)
89-
HANDLE_CONSTANT(ConstantVector)
9077

9178
// ConstantData.
9279
HANDLE_CONSTANT(UndefValue)
@@ -100,8 +87,23 @@ HANDLE_CONSTANT(ConstantTargetNone)
10087
HANDLE_CONSTANT(ConstantPointerNull)
10188
HANDLE_CONSTANT(ConstantTokenNone)
10289

103-
HANDLE_CONSTANT_MARKER(ConstantFirstVal, Function)
104-
HANDLE_CONSTANT_MARKER(ConstantLastVal, ConstantTokenNone)
90+
// ConstantAggregate.
91+
HANDLE_CONSTANT(ConstantArray)
92+
HANDLE_CONSTANT(ConstantStruct)
93+
HANDLE_CONSTANT(ConstantVector)
94+
95+
HANDLE_GLOBAL_VALUE(Function)
96+
HANDLE_GLOBAL_VALUE(GlobalAlias)
97+
HANDLE_GLOBAL_VALUE(GlobalIFunc)
98+
HANDLE_GLOBAL_VALUE(GlobalVariable)
99+
HANDLE_CONSTANT(BlockAddress)
100+
HANDLE_CONSTANT(ConstantExpr)
101+
HANDLE_CONSTANT_EXCLUDE_LLVM_C_API(DSOLocalEquivalent)
102+
HANDLE_CONSTANT_EXCLUDE_LLVM_C_API(NoCFIValue)
103+
HANDLE_CONSTANT(ConstantPtrAuth)
104+
105+
HANDLE_CONSTANT_MARKER(ConstantFirstVal, UndefValue)
106+
HANDLE_CONSTANT_MARKER(ConstantLastVal, ConstantPtrAuth)
105107
HANDLE_CONSTANT_MARKER(ConstantDataFirstVal, UndefValue)
106108
HANDLE_CONSTANT_MARKER(ConstantDataLastVal, ConstantTokenNone)
107109
HANDLE_CONSTANT_MARKER(ConstantAggregateFirstVal, ConstantArray)

0 commit comments

Comments
 (0)