@@ -492,6 +492,14 @@ class Verifier : public InstVisitor<Verifier>, VerifierSupport {
492
492
// / Whether a metadata node is allowed to be, or contain, a DILocation.
493
493
enum class AreDebugLocsAllowed { No, Yes };
494
494
495
+ // / Metadata that should be treated as a range, with slightly different
496
+ // / requirements.
497
+ enum class RangeLikeMetadataKind {
498
+ Range, // MD_range
499
+ AbsoluteSymbol, // MD_absolute_symbol
500
+ NoaliasAddrspace // MD_noalias_addrspace
501
+ };
502
+
495
503
// Verification methods...
496
504
void visitGlobalValue (const GlobalValue &GV);
497
505
void visitGlobalVariable (const GlobalVariable &GV);
@@ -515,8 +523,8 @@ class Verifier : public InstVisitor<Verifier>, VerifierSupport {
515
523
void visitModuleFlagCGProfileEntry (const MDOperand &MDO);
516
524
void visitFunction (const Function &F);
517
525
void visitBasicBlock (BasicBlock &BB);
518
- void verifyRangeMetadata (const Value &V, const MDNode *Range, Type *Ty,
519
- bool IsAbsoluteSymbol, bool IsAddrSpaceRange );
526
+ void verifyRangeLikeMetadata (const Value &V, const MDNode *Range, Type *Ty,
527
+ RangeLikeMetadataKind Kind );
520
528
void visitRangeMetadata (Instruction &I, MDNode *Range, Type *Ty);
521
529
void visitNoaliasAddrspaceMetadata (Instruction &I, MDNode *Range, Type *Ty);
522
530
void visitDereferenceableMetadata (Instruction &I, MDNode *MD);
@@ -761,8 +769,9 @@ void Verifier::visitGlobalValue(const GlobalValue &GV) {
761
769
// FIXME: Why is getMetadata on GlobalValue protected?
762
770
if (const MDNode *AbsoluteSymbol =
763
771
GO->getMetadata (LLVMContext::MD_absolute_symbol)) {
764
- verifyRangeMetadata (*GO, AbsoluteSymbol, DL.getIntPtrType (GO->getType ()),
765
- true , false );
772
+ verifyRangeLikeMetadata (*GO, AbsoluteSymbol,
773
+ DL.getIntPtrType (GO->getType ()),
774
+ RangeLikeMetadataKind::AbsoluteSymbol);
766
775
}
767
776
}
768
777
@@ -4137,9 +4146,8 @@ static bool isContiguous(const ConstantRange &A, const ConstantRange &B) {
4137
4146
4138
4147
// / Verify !range and !absolute_symbol metadata. These have the same
4139
4148
// / restrictions, except !absolute_symbol allows the full set.
4140
- void Verifier::verifyRangeMetadata (const Value &I, const MDNode *Range,
4141
- Type *Ty, bool IsAbsoluteSymbol,
4142
- bool IsAddrSpaceRange) {
4149
+ void Verifier::verifyRangeLikeMetadata (const Value &I, const MDNode *Range,
4150
+ Type *Ty, RangeLikeMetadataKind Kind) {
4143
4151
unsigned NumOperands = Range->getNumOperands ();
4144
4152
Check (NumOperands % 2 == 0 , " Unfinished range!" , Range);
4145
4153
unsigned NumRanges = NumOperands / 2 ;
@@ -4157,7 +4165,7 @@ void Verifier::verifyRangeMetadata(const Value &I, const MDNode *Range,
4157
4165
Check (High->getType () == Low->getType (), " Range pair types must match!" ,
4158
4166
&I);
4159
4167
4160
- if (IsAddrSpaceRange ) {
4168
+ if (Kind == RangeLikeMetadataKind::NoaliasAddrspace ) {
4161
4169
Check (High->getType ()->isIntegerTy (32 ),
4162
4170
" noalias.addrspace type must be i32!" , &I);
4163
4171
} else {
@@ -4174,7 +4182,9 @@ void Verifier::verifyRangeMetadata(const Value &I, const MDNode *Range,
4174
4182
" The upper and lower limits cannot be the same value" , &I);
4175
4183
4176
4184
ConstantRange CurRange (LowV, HighV);
4177
- Check (!CurRange.isEmptySet () && (IsAbsoluteSymbol || !CurRange.isFullSet ()),
4185
+ Check (!CurRange.isEmptySet () &&
4186
+ (Kind == RangeLikeMetadataKind::AbsoluteSymbol ||
4187
+ !CurRange.isFullSet ()),
4178
4188
" Range must not be empty!" , Range);
4179
4189
if (i != 0 ) {
4180
4190
Check (CurRange.intersectWith (LastRange).isEmptySet (),
@@ -4202,14 +4212,15 @@ void Verifier::verifyRangeMetadata(const Value &I, const MDNode *Range,
4202
4212
void Verifier::visitRangeMetadata (Instruction &I, MDNode *Range, Type *Ty) {
4203
4213
assert (Range && Range == I.getMetadata (LLVMContext::MD_range) &&
4204
4214
" precondition violation" );
4205
- verifyRangeMetadata (I, Range, Ty, false , false );
4215
+ verifyRangeLikeMetadata (I, Range, Ty, RangeLikeMetadataKind::Range );
4206
4216
}
4207
4217
4208
4218
void Verifier::visitNoaliasAddrspaceMetadata (Instruction &I, MDNode *Range,
4209
4219
Type *Ty) {
4210
4220
assert (Range && Range == I.getMetadata (LLVMContext::MD_noalias_addrspace) &&
4211
4221
" precondition violation" );
4212
- verifyRangeMetadata (I, Range, Ty, false , true );
4222
+ verifyRangeLikeMetadata (I, Range, Ty,
4223
+ RangeLikeMetadataKind::NoaliasAddrspace);
4213
4224
}
4214
4225
4215
4226
void Verifier::checkAtomicMemAccessSize (Type *Ty, const Instruction *I) {
0 commit comments