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