Index: lib/Analysis/GlobalsModRef.cpp =================================================================== --- lib/Analysis/GlobalsModRef.cpp +++ lib/Analysis/GlobalsModRef.cpp @@ -310,7 +310,7 @@ ++NumNonAddrTakenGlobalVars; // If this global holds a pointer type, see if it is an indirect global. - if (GV.getType()->getElementType()->isPointerTy() && + if (GV.getValueType()->isPointerTy() && AnalyzeIndirectGlobalMemory(&GV)) ++NumIndirectGlobalVars; } Index: lib/Analysis/Lint.cpp =================================================================== --- lib/Analysis/Lint.cpp +++ lib/Analysis/Lint.cpp @@ -435,7 +435,7 @@ // If the global may be defined differently in another compilation unit // then don't warn about funky memory accesses. if (GV->hasDefinitiveInitializer()) { - Type *GTy = GV->getType()->getElementType(); + Type *GTy = GV->getValueType(); if (GTy->isSized()) BaseSize = DL->getTypeAllocSize(GTy); BaseAlign = GV->getAlignment(); Index: lib/Analysis/ValueTracking.cpp =================================================================== --- lib/Analysis/ValueTracking.cpp +++ lib/Analysis/ValueTracking.cpp @@ -1560,7 +1560,7 @@ Align = GO->getAlignment(); if (Align == 0) { if (auto *GVar = dyn_cast(GO)) { - Type *ObjectType = GVar->getType()->getElementType(); + Type *ObjectType = GVar->getValueType(); if (ObjectType->isSized()) { // If the object is defined in the current Module, we'll be giving // it the preferred alignment. Otherwise, we have to assume that it Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -83,8 +83,8 @@ // First operand points to a global struct. Value *Ptr = CE->getOperand(0); - if (!isa(Ptr) || - !isa(cast(Ptr->getType())->getElementType())) + GlobalValue *GV = dyn_cast(Ptr); + if (!GV || !isa(GV->getValueType())) return nullptr; // Second operand is zero. Index: lib/CodeGen/CodeGenPrepare.cpp =================================================================== --- lib/CodeGen/CodeGenPrepare.cpp +++ lib/CodeGen/CodeGenPrepare.cpp @@ -1744,7 +1744,7 @@ GlobalVariable *GV; if ((GV = dyn_cast(Val)) && GV->canIncreaseAlignment() && GV->getAlignment() < PrefAlign && - DL->getTypeAllocSize(GV->getType()->getElementType()) >= + DL->getTypeAllocSize(GV->getValueType()) >= MinSize + Offset2) GV->setAlignment(PrefAlign); } Index: lib/ExecutionEngine/ExecutionEngine.cpp =================================================================== --- lib/ExecutionEngine/ExecutionEngine.cpp +++ lib/ExecutionEngine/ExecutionEngine.cpp @@ -103,7 +103,7 @@ /// \brief Returns the address the GlobalVariable should be written into. The /// GVMemoryBlock object prefixes that. static char *Create(const GlobalVariable *GV, const DataLayout& TD) { - Type *ElTy = GV->getType()->getElementType(); + Type *ElTy = GV->getValueType(); size_t GVSize = (size_t)TD.getTypeAllocSize(ElTy); void *RawMemory = ::operator new( alignTo(sizeof(GVMemoryBlock), TD.getPreferredAlignment(GV)) + GVSize); @@ -1353,7 +1353,7 @@ if (!GV->isThreadLocal()) InitializeMemory(GV->getInitializer(), GA); - Type *ElTy = GV->getType()->getElementType(); + Type *ElTy = GV->getValueType(); size_t GVSize = (size_t)getDataLayout().getTypeAllocSize(ElTy); NumInitBytes += (unsigned)GVSize; ++NumGlobals; Index: lib/ExecutionEngine/Orc/IndirectionUtils.cpp =================================================================== --- lib/ExecutionEngine/Orc/IndirectionUtils.cpp +++ lib/ExecutionEngine/Orc/IndirectionUtils.cpp @@ -116,7 +116,7 @@ ValueToValueMapTy *VMap) { assert(F.getParent() != &Dst && "Can't copy decl over existing function."); Function *NewF = - Function::Create(cast(F.getType()->getElementType()), + Function::Create(cast(F.getValueType()), F.getLinkage(), F.getName(), &Dst); NewF->copyAttributesFrom(&F); @@ -154,7 +154,7 @@ ValueToValueMapTy *VMap) { assert(GV.getParent() != &Dst && "Can't copy decl over existing global var."); GlobalVariable *NewGV = new GlobalVariable( - Dst, GV.getType()->getElementType(), GV.isConstant(), + Dst, GV.getValueType(), GV.isConstant(), GV.getLinkage(), nullptr, GV.getName(), nullptr, GV.getThreadLocalMode(), GV.getType()->getAddressSpace()); NewGV->copyAttributesFrom(&GV); Index: lib/IR/AsmWriter.cpp =================================================================== --- lib/IR/AsmWriter.cpp +++ lib/IR/AsmWriter.cpp @@ -2416,7 +2416,7 @@ Out << "addrspace(" << AddressSpace << ") "; if (GV->isExternallyInitialized()) Out << "externally_initialized "; Out << (GV->isConstant() ? "constant " : "global "); - TypePrinter.print(GV->getType()->getElementType(), Out); + TypePrinter.print(GV->getValueType(), Out); if (GV->hasInitializer()) { Out << ' '; Index: lib/IR/DataLayout.cpp =================================================================== --- lib/IR/DataLayout.cpp +++ lib/IR/DataLayout.cpp @@ -764,7 +764,7 @@ /// global. This includes an explicitly requested alignment (if the global /// has one). unsigned DataLayout::getPreferredAlignment(const GlobalVariable *GV) const { - Type *ElemType = GV->getType()->getElementType(); + Type *ElemType = GV->getValueType(); unsigned Alignment = getPrefTypeAlignment(ElemType); unsigned GVAlignment = GV->getAlignment(); if (GVAlignment >= Alignment) { Index: lib/IR/Globals.cpp =================================================================== --- lib/IR/Globals.cpp +++ lib/IR/Globals.cpp @@ -242,7 +242,7 @@ setGlobalVariableNumOperands(0); } } else { - assert(InitVal->getType() == getType()->getElementType() && + assert(InitVal->getType() == getValueType() && "Initializer type must match GlobalVariable type"); // Note, the num operands is used to compute the offset of the operand, so // the order here matters. We need to set num operands to 1 first so that Index: lib/IR/Verifier.cpp =================================================================== --- lib/IR/Verifier.cpp +++ lib/IR/Verifier.cpp @@ -521,7 +521,7 @@ void Verifier::visitGlobalVariable(const GlobalVariable &GV) { if (GV.hasInitializer()) { - Assert(GV.getInitializer()->getType() == GV.getType()->getElementType(), + Assert(GV.getInitializer()->getType() == GV.getValueType(), "Global variable initializer type does not match global " "variable type!", &GV); Index: lib/Linker/IRMover.cpp =================================================================== --- lib/Linker/IRMover.cpp +++ lib/Linker/IRMover.cpp @@ -719,7 +719,7 @@ // identical version of the symbol over in the dest module... the // initializer will be filled in later by LinkGlobalInits. GlobalVariable *NewDGV = - new GlobalVariable(DstM, TypeMap.get(SGVar->getType()->getElementType()), + new GlobalVariable(DstM, TypeMap.get(SGVar->getValueType()), SGVar->isConstant(), GlobalValue::ExternalLinkage, /*init*/ nullptr, SGVar->getName(), /*insertbefore*/ nullptr, SGVar->getThreadLocalMode(), @@ -759,7 +759,7 @@ NewGV = copyGlobalAliasProto(cast(SGV)); else NewGV = new GlobalVariable( - DstM, TypeMap.get(SGV->getType()->getElementType()), + DstM, TypeMap.get(SGV->getValueType()), /*isConstant*/ false, GlobalValue::ExternalLinkage, /*init*/ nullptr, SGV->getName(), /*insertbefore*/ nullptr, SGV->getThreadLocalMode(), @@ -802,8 +802,8 @@ } // Unify the element type of appending arrays. - ArrayType *DAT = cast(DGV->getType()->getElementType()); - ArrayType *SAT = cast(SGV.getType()->getElementType()); + ArrayType *DAT = cast(DGV->getValueType()); + ArrayType *SAT = cast(SGV.getValueType()); TypeMap.addTypeMapping(DAT->getElementType(), SAT->getElementType()); } @@ -874,7 +874,7 @@ /// Return true on error. Constant *IRLinker::linkAppendingVarProto(GlobalVariable *DstGV, const GlobalVariable *SrcGV) { - Type *EltTy = cast(TypeMap.get(SrcGV->getType()->getElementType())) + Type *EltTy = cast(TypeMap.get(SrcGV->getValueType())) ->getElementType(); StringRef Name = SrcGV->getName(); @@ -895,7 +895,7 @@ } if (DstGV) { - ArrayType *DstTy = cast(DstGV->getType()->getElementType()); + ArrayType *DstTy = cast(DstGV->getValueType()); if (!SrcGV->hasAppendingLinkage() || !DstGV->hasAppendingLinkage()) { emitError( Index: lib/Linker/LinkModules.cpp =================================================================== --- lib/Linker/LinkModules.cpp +++ lib/Linker/LinkModules.cpp @@ -471,10 +471,8 @@ const DataLayout &DstDL = DstM.getDataLayout(); const DataLayout &SrcDL = SrcM.getDataLayout(); - uint64_t DstSize = - DstDL.getTypeAllocSize(DstGV->getType()->getPointerElementType()); - uint64_t SrcSize = - SrcDL.getTypeAllocSize(SrcGV->getType()->getPointerElementType()); + uint64_t DstSize = DstDL.getTypeAllocSize(DstGV->getValueType()); + uint64_t SrcSize = SrcDL.getTypeAllocSize(SrcGV->getValueType()); if (Result == Comdat::SelectionKind::ExactMatch) { if (SrcGV->getInitializer() != DstGV->getInitializer()) return emitError("Linking COMDATs named '" + ComdatName + @@ -598,8 +596,8 @@ } const DataLayout &DL = Dest.getParent()->getDataLayout(); - uint64_t DestSize = DL.getTypeAllocSize(Dest.getType()->getElementType()); - uint64_t SrcSize = DL.getTypeAllocSize(Src.getType()->getElementType()); + uint64_t DestSize = DL.getTypeAllocSize(Dest.getValueType()); + uint64_t SrcSize = DL.getTypeAllocSize(Src.getValueType()); LinkFromSrc = SrcSize > DestSize; return false; } Index: lib/Target/AArch64/AArch64ISelDAGToDAG.cpp =================================================================== --- lib/Target/AArch64/AArch64ISelDAGToDAG.cpp +++ lib/Target/AArch64/AArch64ISelDAGToDAG.cpp @@ -687,7 +687,7 @@ const GlobalValue *GV = GAN->getGlobal(); unsigned Alignment = GV->getAlignment(); - Type *Ty = GV->getType()->getElementType(); + Type *Ty = GV->getValueType(); if (Alignment == 0 && Ty->isSized()) Alignment = DL.getABITypeAlignment(Ty); Index: lib/Target/AMDGPU/AMDGPUISelLowering.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUISelLowering.cpp +++ lib/Target/AMDGPU/AMDGPUISelLowering.cpp @@ -808,7 +808,7 @@ unsigned Offset; if (MFI->LocalMemoryObjects.count(GV) == 0) { - uint64_t Size = DL.getTypeAllocSize(GV->getType()->getElementType()); + uint64_t Size = DL.getTypeAllocSize(GV->getValueType()); Offset = MFI->LDSSize; MFI->LocalMemoryObjects[GV] = Offset; // XXX: Account for alignment? @@ -822,7 +822,7 @@ } case AMDGPUAS::CONSTANT_ADDRESS: { MachineFrameInfo *FrameInfo = DAG.getMachineFunction().getFrameInfo(); - Type *EltType = GV->getType()->getElementType(); + Type *EltType = GV->getValueType(); unsigned Size = DL.getTypeAllocSize(EltType); unsigned Alignment = DL.getPrefTypeAlignment(EltType); Index: lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp +++ lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp @@ -78,8 +78,7 @@ for (Module::global_iterator I = Mod->global_begin(), E = Mod->global_end(); I != E; ++I) { GlobalVariable *GV = &*I; - PointerType *GVTy = GV->getType(); - if (GVTy->getAddressSpace() != AMDGPUAS::LOCAL_ADDRESS) + if (GV->getType()->getAddressSpace() != AMDGPUAS::LOCAL_ADDRESS) continue; for (Value::use_iterator U = GV->use_begin(), UE = GV->use_end(); U != UE; ++U) { @@ -88,7 +87,7 @@ continue; if (Use->getParent()->getParent() == &F) LocalMemAvailable -= - Mod->getDataLayout().getTypeAllocSize(GVTy->getElementType()); + Mod->getDataLayout().getTypeAllocSize(GV->getValueType()); } } } Index: lib/Target/CppBackend/CPPBackend.cpp =================================================================== --- lib/Target/CppBackend/CPPBackend.cpp +++ lib/Target/CppBackend/CPPBackend.cpp @@ -437,7 +437,7 @@ if (const GlobalVariable* GV = dyn_cast(val)) { name = std::string("gvar_") + - getTypePrefix(GV->getType()->getElementType()); + getTypePrefix(GV->getValueType()); } else if (isa(val)) { name = std::string("func_"); } else if (const Constant* C = dyn_cast(val)) { @@ -997,13 +997,13 @@ if (is_inline) { Out << " = mod->getGlobalVariable(mod->getContext(), "; printEscapedString(GV->getName()); - Out << ", " << getCppName(GV->getType()->getElementType()) << ",true)"; + Out << ", " << getCppName(GV->getValueType()) << ",true)"; nl(Out) << "if (!" << getCppName(GV) << ") {"; in(); nl(Out) << getCppName(GV); } Out << " = new GlobalVariable(/*Module=*/*mod, "; nl(Out) << "/*Type=*/"; - printCppName(GV->getType()->getElementType()); + printCppName(GV->getValueType()); Out << ","; nl(Out) << "/*isConstant=*/" << (GV->isConstant()?"true":"false"); Out << ","; Index: lib/Target/Hexagon/HexagonTargetObjectFile.cpp =================================================================== --- lib/Target/Hexagon/HexagonTargetObjectFile.cpp +++ lib/Target/Hexagon/HexagonTargetObjectFile.cpp @@ -74,7 +74,7 @@ return false; if (Kind.isBSS() || Kind.isData() || Kind.isCommon()) { - Type *Ty = GV->getType()->getElementType(); + Type *Ty = GV->getValueType(); return IsInSmallSection( GV->getParent()->getDataLayout().getTypeAllocSize(Ty)); } Index: lib/Target/Mips/MipsTargetObjectFile.cpp =================================================================== --- lib/Target/Mips/MipsTargetObjectFile.cpp +++ lib/Target/Mips/MipsTargetObjectFile.cpp @@ -106,7 +106,7 @@ GV->hasCommonLinkage())) return false; - Type *Ty = GV->getType()->getElementType(); + Type *Ty = GV->getValueType(); return IsInSmallSection( GV->getParent()->getDataLayout().getTypeAllocSize(Ty)); } Index: lib/Target/NVPTX/NVPTXAsmPrinter.cpp =================================================================== --- lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -1030,7 +1030,7 @@ // GlobalVariables are always constant pointers themselves. PointerType *PTy = GVar->getType(); - Type *ETy = PTy->getElementType(); + Type *ETy = GVar->getValueType(); if (GVar->hasExternalLinkage()) { if (GVar->hasInitializer()) @@ -1341,11 +1341,10 @@ const DataLayout &DL = getDataLayout(); // GlobalVariables are always constant pointers themselves. - PointerType *PTy = GVar->getType(); - Type *ETy = PTy->getElementType(); + Type *ETy = GVar->getValueType(); O << "."; - emitPTXAddressSpace(PTy->getAddressSpace(), O); + emitPTXAddressSpace(GVar->getType()->getAddressSpace(), O); if (GVar->getAlignment() == 0) O << " .align " << (int)DL.getPrefTypeAlignment(ETy); else @@ -1715,9 +1714,8 @@ return; } if (const GlobalValue *GVar = dyn_cast(CPV)) { - PointerType *PTy = dyn_cast(GVar->getType()); bool IsNonGenericPointer = false; - if (PTy && PTy->getAddressSpace() != 0) { + if (GVar->getType()->getAddressSpace() != 0) { IsNonGenericPointer = true; } if (EmitGeneric && !isa(CPV) && !IsNonGenericPointer) { Index: lib/Target/NVPTX/NVPTXGenericToNVVM.cpp =================================================================== --- lib/Target/NVPTX/NVPTXGenericToNVVM.cpp +++ lib/Target/NVPTX/NVPTXGenericToNVVM.cpp @@ -86,7 +86,7 @@ !llvm::isTexture(*GV) && !llvm::isSurface(*GV) && !llvm::isSampler(*GV) && !GV->getName().startswith("llvm.")) { GlobalVariable *NewGV = new GlobalVariable( - M, GV->getType()->getElementType(), GV->isConstant(), + M, GV->getValueType(), GV->isConstant(), GV->getLinkage(), GV->hasInitializer() ? GV->getInitializer() : nullptr, "", GV, GV->getThreadLocalMode(), llvm::ADDRESS_SPACE_GLOBAL); @@ -172,7 +172,7 @@ // See if the address space conversion requires the operand to be bitcast // to i8 addrspace(n)* first. - EVT ExtendedGVType = EVT::getEVT(GVType->getElementType(), true); + EVT ExtendedGVType = EVT::getEVT(GV->getValueType(), true); if (!ExtendedGVType.isInteger() && !ExtendedGVType.isFloatingPoint()) { // A bitcast to i8 addrspace(n)* on the operand is needed. LLVMContext &Context = M->getContext(); @@ -191,12 +191,12 @@ // Another bitcast from i8 * to * is // required. DestTy = - PointerType::get(GVType->getElementType(), llvm::ADDRESS_SPACE_GENERIC); + PointerType::get(GV->getValueType(), llvm::ADDRESS_SPACE_GENERIC); CVTA = Builder.CreateBitCast(CVTA, DestTy, "cvta"); } else { // A simple CVTA is enough. SmallVector ParamTypes; - ParamTypes.push_back(PointerType::get(GVType->getElementType(), + ParamTypes.push_back(PointerType::get(GV->getValueType(), llvm::ADDRESS_SPACE_GENERIC)); ParamTypes.push_back(GVType); Function *CVTAFunction = Intrinsic::getDeclaration( Index: lib/Target/PowerPC/PPCISelLowering.cpp =================================================================== --- lib/Target/PowerPC/PPCISelLowering.cpp +++ lib/Target/PowerPC/PPCISelLowering.cpp @@ -4091,7 +4091,7 @@ Callee.getOpcode() == ISD::TargetGlobalTLSAddress) return false; - return G->getGlobal()->getType()->getElementType()->isFunctionTy(); + return G->getGlobal()->getValueType()->isFunctionTy(); } return false; Index: lib/Target/XCore/XCoreAsmPrinter.cpp =================================================================== --- lib/Target/XCore/XCoreAsmPrinter.cpp +++ lib/Target/XCore/XCoreAsmPrinter.cpp @@ -93,8 +93,7 @@ assert( ( GV->hasExternalLinkage() || GV->hasWeakLinkage() || GV->hasLinkOnceLinkage() || GV->hasCommonLinkage() ) && "Unexpected linkage"); - if (ArrayType *ATy = dyn_cast( - cast(GV->getType())->getElementType())) { + if (ArrayType *ATy = dyn_cast(GV->getValueType())) { MCSymbol *SymGlob = OutContext.getOrCreateSymbol( Twine(Sym->getName() + StringRef(".globound"))); Index: lib/Target/XCore/XCoreISelLowering.cpp =================================================================== --- lib/Target/XCore/XCoreISelLowering.cpp +++ lib/Target/XCore/XCoreISelLowering.cpp @@ -257,7 +257,7 @@ // FIXME there is no actual debug info here SDLoc dl(GA); - if (GV->getType()->getElementType()->isFunctionTy()) + if (GV->getValueType()->isFunctionTy()) return DAG.getNode(XCoreISD::PCRelativeWrapper, dl, MVT::i32, GA); const auto *GVar = dyn_cast(GV); @@ -272,7 +272,7 @@ if (XTL.getTargetMachine().getCodeModel() == CodeModel::Small) return true; - Type *ObjType = GV->getType()->getPointerElementType(); + Type *ObjType = GV->getValueType(); if (!ObjType->isSized()) return false; Index: lib/Target/XCore/XCoreLowerThreadLocal.cpp =================================================================== --- lib/Target/XCore/XCoreLowerThreadLocal.cpp +++ lib/Target/XCore/XCoreLowerThreadLocal.cpp @@ -189,7 +189,7 @@ return false; // Create replacement global. - ArrayType *NewType = createLoweredType(GV->getType()->getElementType()); + ArrayType *NewType = createLoweredType(GV->getValueType()); Constant *NewInitializer = nullptr; if (GV->hasInitializer()) NewInitializer = createLoweredInitializer(NewType, Index: lib/Target/XCore/XCoreTargetObjectFile.cpp =================================================================== --- lib/Target/XCore/XCoreTargetObjectFile.cpp +++ lib/Target/XCore/XCoreTargetObjectFile.cpp @@ -122,7 +122,7 @@ if (Kind.isMergeableConst8()) return MergeableConst8Section; if (Kind.isMergeableConst16()) return MergeableConst16Section; } - Type *ObjType = GV->getType()->getPointerElementType(); + Type *ObjType = GV->getValueType(); auto &DL = GV->getParent()->getDataLayout(); if (TM.getCodeModel() == CodeModel::Small || !ObjType->isSized() || DL.getTypeAllocSize(ObjType) < CodeModelLargeSize) { Index: lib/Transforms/IPO/ExtractGV.cpp =================================================================== --- lib/Transforms/IPO/ExtractGV.cpp +++ lib/Transforms/IPO/ExtractGV.cpp @@ -128,7 +128,7 @@ makeVisible(*CurI, Delete); if (Delete) { - Type *Ty = CurI->getType()->getElementType(); + Type *Ty = CurI->getValueType(); CurI->removeFromParent(); llvm::Value *Declaration; Index: lib/Transforms/IPO/GlobalOpt.cpp =================================================================== --- lib/Transforms/IPO/GlobalOpt.cpp +++ lib/Transforms/IPO/GlobalOpt.cpp @@ -120,7 +120,7 @@ return false; SmallVector Types; - Types.push_back(cast(GV->getType())->getElementType()); + Types.push_back(GV->getValueType()); unsigned Limit = 20; do { @@ -867,9 +867,8 @@ } Constant *RepValue = NewGV; - if (NewGV->getType() != GV->getType()->getElementType()) - RepValue = ConstantExpr::getBitCast(RepValue, - GV->getType()->getElementType()); + if (NewGV->getType() != GV->getValueType()) + RepValue = ConstantExpr::getBitCast(RepValue, GV->getValueType()); // If there is a comparison against null, we will insert a global bool to // keep track of whether the global was initialized yet or not. @@ -1397,8 +1396,8 @@ // Insert a store of null into each global. for (unsigned i = 0, e = FieldGlobals.size(); i != e; ++i) { - PointerType *PT = cast(FieldGlobals[i]->getType()); - Constant *Null = Constant::getNullValue(PT->getElementType()); + Type *ValTy = cast(FieldGlobals[i])->getValueType(); + Constant *Null = Constant::getNullValue(ValTy); new StoreInst(Null, FieldGlobals[i], SI); } // Erase the original store. @@ -1583,7 +1582,7 @@ /// boolean and select between the two values whenever it is used. This exposes /// the values to other scalar optimizations. static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) { - Type *GVElType = GV->getType()->getElementType(); + Type *GVElType = GV->getValueType(); // If GVElType is already i1, it is already shrunk. If the type of the GV is // an FP value, pointer or vector, don't do this optimization because a select @@ -1879,7 +1878,7 @@ // If the global is in different address space, don't bring it to stack. if (!GS.HasMultipleAccessingFunctions && GS.AccessingFunction && - GV->getType()->getElementType()->isSingleValueType() && + GV->getValueType()->isSingleValueType() && GV->getType()->getAddressSpace() == 0 && !GV->isExternallyInitialized() && allNonInstructionUsersCanBeMadeInstructions(GV) && @@ -1888,7 +1887,7 @@ DEBUG(dbgs() << "LOCALIZING GLOBAL: " << *GV << "\n"); Instruction &FirstI = const_cast(*GS.AccessingFunction ->getEntryBlock().begin()); - Type *ElemTy = GV->getType()->getElementType(); + Type *ElemTy = GV->getValueType(); // FIXME: Pass Global's alignment when globals have alignment AllocaInst *Alloca = new AllocaInst(ElemTy, nullptr, GV->getName(), &FirstI); @@ -2627,7 +2626,7 @@ Value *PtrArg = getVal(II->getArgOperand(1)); Value *Ptr = PtrArg->stripPointerCasts(); if (GlobalVariable *GV = dyn_cast(Ptr)) { - Type *ElemTy = cast(GV->getType())->getElementType(); + Type *ElemTy = GV->getValueType(); if (!Size->isAllOnesValue() && Size->getValue().getLimitedValue() >= DL.getTypeStoreSize(ElemTy)) { Index: lib/Transforms/InstCombine/InstCombineCalls.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineCalls.cpp +++ lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -2351,8 +2351,7 @@ "transformCallThroughTrampoline called with incorrect CallSite."); Function *NestF =cast(Tramp->getArgOperand(1)->stripPointerCasts()); - PointerType *NestFPTy = cast(NestF->getType()); - FunctionType *NestFTy = cast(NestFPTy->getElementType()); + FunctionType *NestFTy = cast(NestF->getValueType()); const AttributeSet &NestAttrs = NestF->getAttributes(); if (!NestAttrs.isEmpty()) { Index: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp =================================================================== --- lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -637,7 +637,7 @@ if (!GV->hasDefinitiveInitializer() || !GV->isConstant()) return false; - uint64_t InitSize = DL.getTypeAllocSize(GV->getType()->getElementType()); + uint64_t InitSize = DL.getTypeAllocSize(GV->getValueType()); if (InitSize > MaxSize) return false; continue; Index: lib/Transforms/Instrumentation/AddressSanitizer.cpp =================================================================== --- lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -1184,7 +1184,7 @@ } bool AddressSanitizerModule::ShouldInstrumentGlobal(GlobalVariable *G) { - Type *Ty = cast(G->getType())->getElementType(); + Type *Ty = G->getValueType(); DEBUG(dbgs() << "GLOBAL: " << *G << "\n"); if (GlobalsMD.get(G).IsBlacklisted) return false; @@ -1338,8 +1338,7 @@ M, MD.Name.empty() ? G->getName() : MD.Name, /*AllowMerging*/ true); - PointerType *PtrTy = cast(G->getType()); - Type *Ty = PtrTy->getElementType(); + Type *Ty = G->getValueType(); uint64_t SizeInBytes = DL.getTypeAllocSize(Ty); uint64_t MinRZ = MinRedzoneSizeForGlobal(); // MinRZ <= RZ <= kMaxGlobalRedzone Index: lib/Transforms/Instrumentation/DataFlowSanitizer.cpp =================================================================== --- lib/Transforms/Instrumentation/DataFlowSanitizer.cpp +++ lib/Transforms/Instrumentation/DataFlowSanitizer.cpp @@ -134,7 +134,7 @@ StringRef GetGlobalTypeString(const GlobalValue &G) { // Types of GlobalVariables are always pointer types. - Type *GType = G.getType()->getElementType(); + Type *GType = G.getValueType(); // For now we support blacklisting struct types only. if (StructType *SGType = dyn_cast(GType)) { if (!SGType->isLiteral()) @@ -166,7 +166,7 @@ if (isIn(*GA.getParent(), Category)) return true; - if (isa(GA.getType()->getElementType())) + if (isa(GA.getValueType())) return SCL->inSection("fun", GA.getName(), Category); return SCL->inSection("global", GA.getName(), Category) || Index: lib/Transforms/Instrumentation/GCOVProfiling.cpp =================================================================== --- lib/Transforms/Instrumentation/GCOVProfiling.cpp +++ lib/Transforms/Instrumentation/GCOVProfiling.cpp @@ -874,7 +874,7 @@ GlobalVariable *GV = CountersBySP[j].first; unsigned Arcs = - cast(GV->getType()->getElementType())->getNumElements(); + cast(GV->getValueType())->getNumElements(); Builder.CreateCall(EmitArcs, {Builder.getInt32(Arcs), Builder.CreateConstGEP2_64(GV, 0, 0)}); } @@ -966,7 +966,7 @@ I = CountersBySP.begin(), E = CountersBySP.end(); I != E; ++I) { GlobalVariable *GV = I->first; - Constant *Null = Constant::getNullValue(GV->getType()->getElementType()); + Constant *Null = Constant::getNullValue(GV->getValueType()); Builder.CreateStore(Null, GV); } Index: lib/Transforms/Scalar/PlaceSafepoints.cpp =================================================================== --- lib/Transforms/Scalar/PlaceSafepoints.cpp +++ lib/Transforms/Scalar/PlaceSafepoints.cpp @@ -763,7 +763,7 @@ auto *F = M->getFunction(GCSafepointPollName); assert(F && "gc.safepoint_poll function is missing"); - assert(F->getType()->getElementType() == + assert(F->getValueType() == FunctionType::get(Type::getVoidTy(M->getContext()), false) && "gc.safepoint_poll declared with wrong type"); assert(!F->empty() && "gc.safepoint_poll must be a non-empty function"); Index: lib/Transforms/Scalar/SCCP.cpp =================================================================== --- lib/Transforms/Scalar/SCCP.cpp +++ lib/Transforms/Scalar/SCCP.cpp @@ -228,7 +228,7 @@ /// performing Interprocedural SCCP. void TrackValueOfGlobalVariable(GlobalVariable *GV) { // We only track the contents of scalar globals. - if (GV->getType()->getElementType()->isSingleValueType()) { + if (GV->getValueType()->isSingleValueType()) { LatticeVal &IV = TrackedGlobals[GV]; if (!isa(GV->getInitializer())) IV.markConstant(GV->getInitializer()); Index: lib/Transforms/Utils/CloneModule.cpp =================================================================== --- lib/Transforms/Utils/CloneModule.cpp +++ lib/Transforms/Utils/CloneModule.cpp @@ -53,7 +53,7 @@ for (Module::const_global_iterator I = M->global_begin(), E = M->global_end(); I != E; ++I) { GlobalVariable *GV = new GlobalVariable(*New, - I->getType()->getElementType(), + I->getValueType(), I->isConstant(), I->getLinkage(), (Constant*) nullptr, I->getName(), (GlobalVariable*) nullptr, @@ -66,7 +66,7 @@ // Loop over the functions in the module, making external functions as before for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) { Function *NF = - Function::Create(cast(I->getType()->getElementType()), + Function::Create(cast(I->getValueType()), I->getLinkage(), I->getName(), New.get()); NF->copyAttributesFrom(&*I); VMap[&*I] = NF; Index: lib/Transforms/Utils/ModuleUtils.cpp =================================================================== --- lib/Transforms/Utils/ModuleUtils.cpp +++ lib/Transforms/Utils/ModuleUtils.cpp @@ -33,7 +33,7 @@ if (GlobalVariable *GVCtor = M.getNamedGlobal(Array)) { // If there is a global_ctors array, use the existing struct type, which can // have 2 or 3 fields. - ArrayType *ATy = cast(GVCtor->getType()->getElementType()); + ArrayType *ATy = cast(GVCtor->getValueType()); EltTy = cast(ATy->getElementType()); if (Constant *Init = GVCtor->getInitializer()) { unsigned n = Init->getNumOperands(); Index: tools/llvm-nm/llvm-nm.cpp =================================================================== --- tools/llvm-nm/llvm-nm.cpp +++ tools/llvm-nm/llvm-nm.cpp @@ -792,7 +792,7 @@ } static char getSymbolNMTypeChar(const GlobalValue &GV) { - if (GV.getType()->getElementType()->isFunctionTy()) + if (GV.getValueType()->isFunctionTy()) return 't'; // FIXME: should we print 'b'? At the IR level we cannot be sure if this // will be in bss or not, but we could approximate.