@@ -829,8 +829,10 @@ void Verifier::visitGlobalValue(const GlobalValue &GV) {
829829}
830830
831831void Verifier::visitGlobalVariable (const GlobalVariable &GV) {
832+ Type *GVType = GV.getValueType ();
833+
832834 if (GV.hasInitializer ()) {
833- Check (GV.getInitializer ()->getType () == GV. getValueType () ,
835+ Check (GV.getInitializer ()->getType () == GVType ,
834836 " Global variable initializer type does not match global "
835837 " variable type!" ,
836838 &GV);
@@ -854,7 +856,7 @@ void Verifier::visitGlobalVariable(const GlobalVariable &GV) {
854856
855857 // Don't worry about emitting an error for it not being an array,
856858 // visitGlobalValue will complain on appending non-array.
857- if (ArrayType *ATy = dyn_cast<ArrayType>(GV. getValueType () )) {
859+ if (ArrayType *ATy = dyn_cast<ArrayType>(GVType )) {
858860 StructType *STy = dyn_cast<StructType>(ATy->getElementType ());
859861 PointerType *FuncPtrTy =
860862 PointerType::get (Context, DL.getProgramAddressSpace ());
@@ -878,7 +880,6 @@ void Verifier::visitGlobalVariable(const GlobalVariable &GV) {
878880 Check (GV.materialized_use_empty (),
879881 " invalid uses of intrinsic global variable" , &GV);
880882
881- Type *GVType = GV.getValueType ();
882883 if (ArrayType *ATy = dyn_cast<ArrayType>(GVType)) {
883884 PointerType *PTy = dyn_cast<PointerType>(ATy->getElementType ());
884885 Check (PTy, " wrong type for intrinsic global variable" , &GV);
@@ -912,15 +913,13 @@ void Verifier::visitGlobalVariable(const GlobalVariable &GV) {
912913
913914 // Scalable vectors cannot be global variables, since we don't know
914915 // the runtime size.
915- Check (!GV.getValueType ()->isScalableTy (),
916- " Globals cannot contain scalable types" , &GV);
917-
918- // Check if it's a target extension type that disallows being used as a
919- // global.
920- if (auto *TTy = dyn_cast<TargetExtType>(GV.getValueType ()))
921- Check (TTy->hasProperty (TargetExtType::CanBeGlobal),
922- " Global @" + GV.getName () + " has illegal target extension type" ,
923- TTy);
916+ Check (!GVType->isScalableTy (), " Globals cannot contain scalable types" , &GV);
917+
918+ // Check if it is or contains a target extension type that disallows being
919+ // used as a global.
920+ Check (!GVType->containsNonGlobalTargetExtType (),
921+ " Global @" + GV.getName () + " has illegal target extension type" ,
922+ GVType);
924923
925924 if (!GV.hasInitializer ()) {
926925 visitGlobalValue (GV);
0 commit comments