llvm.org GIT mirror llvm / 75e1cfb
GlobalValue: use getValueType() instead of getType()->getPointerElementType(). Reviewers: mjacob Subscribers: jholewinski, arsenm, dsanders, dblaikie Patch by Eduard Burtescu. Differential Revision: http://reviews.llvm.org/D16260 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257999 91177308-0d34-0410-b5e6-96231b3b80d8 Manuel Jacob 3 years ago
38 changed file(s) with 72 addition(s) and 81 deletion(s). Raw diff Collapse all Expand all
309309 ++NumNonAddrTakenGlobalVars;
310310
311311 // If this global holds a pointer type, see if it is an indirect global.
312 if (GV.getType()->getElementType()->isPointerTy() &&
312 if (GV.getValueType()->isPointerTy() &&
313313 AnalyzeIndirectGlobalMemory(&GV))
314314 ++NumIndirectGlobalVars;
315315 }
434434 // If the global may be defined differently in another compilation unit
435435 // then don't warn about funky memory accesses.
436436 if (GV->hasDefinitiveInitializer()) {
437 Type *GTy = GV->getType()->getElementType();
437 Type *GTy = GV->getValueType();
438438 if (GTy->isSized())
439439 BaseSize = DL->getTypeAllocSize(GTy);
440440 BaseAlign = GV->getAlignment();
15591559 Align = GO->getAlignment();
15601560 if (Align == 0) {
15611561 if (auto *GVar = dyn_cast(GO)) {
1562 Type *ObjectType = GVar->getType()->getElementType();
1562 Type *ObjectType = GVar->getValueType();
15631563 if (ObjectType->isSized()) {
15641564 // If the object is defined in the current Module, we'll be giving
15651565 // it the preferred alignment. Otherwise, we have to assume that it
8282
8383 // First operand points to a global struct.
8484 Value *Ptr = CE->getOperand(0);
85 if (!isa(Ptr) ||
86 !isa(cast(Ptr->getType())->getElementType()))
85 GlobalValue *GV = dyn_cast(Ptr);
86 if (!GV || !isa(GV->getValueType()))
8787 return nullptr;
8888
8989 // Second operand is zero.
17431743 GlobalVariable *GV;
17441744 if ((GV = dyn_cast(Val)) && GV->canIncreaseAlignment() &&
17451745 GV->getAlignment() < PrefAlign &&
1746 DL->getTypeAllocSize(GV->getType()->getElementType()) >=
1746 DL->getTypeAllocSize(GV->getValueType()) >=
17471747 MinSize + Offset2)
17481748 GV->setAlignment(PrefAlign);
17491749 }
102102 /// \brief Returns the address the GlobalVariable should be written into. The
103103 /// GVMemoryBlock object prefixes that.
104104 static char *Create(const GlobalVariable *GV, const DataLayout& TD) {
105 Type *ElTy = GV->getType()->getElementType();
105 Type *ElTy = GV->getValueType();
106106 size_t GVSize = (size_t)TD.getTypeAllocSize(ElTy);
107107 void *RawMemory = ::operator new(
108108 alignTo(sizeof(GVMemoryBlock), TD.getPreferredAlignment(GV)) + GVSize);
13521352 if (!GV->isThreadLocal())
13531353 InitializeMemory(GV->getInitializer(), GA);
13541354
1355 Type *ElTy = GV->getType()->getElementType();
1355 Type *ElTy = GV->getValueType();
13561356 size_t GVSize = (size_t)getDataLayout().getTypeAllocSize(ElTy);
13571357 NumInitBytes += (unsigned)GVSize;
13581358 ++NumGlobals;
115115 ValueToValueMapTy *VMap) {
116116 assert(F.getParent() != &Dst && "Can't copy decl over existing function.");
117117 Function *NewF =
118 Function::Create(cast(F.getType()->getElementType()),
118 Function::Create(cast(F.getValueType()),
119119 F.getLinkage(), F.getName(), &Dst);
120120 NewF->copyAttributesFrom(&F);
121121
153153 ValueToValueMapTy *VMap) {
154154 assert(GV.getParent() != &Dst && "Can't copy decl over existing global var.");
155155 GlobalVariable *NewGV = new GlobalVariable(
156 Dst, GV.getType()->getElementType(), GV.isConstant(),
156 Dst, GV.getValueType(), GV.isConstant(),
157157 GV.getLinkage(), nullptr, GV.getName(), nullptr,
158158 GV.getThreadLocalMode(), GV.getType()->getAddressSpace());
159159 NewGV->copyAttributesFrom(&GV);
24152415 Out << "addrspace(" << AddressSpace << ") ";
24162416 if (GV->isExternallyInitialized()) Out << "externally_initialized ";
24172417 Out << (GV->isConstant() ? "constant " : "global ");
2418 TypePrinter.print(GV->getType()->getElementType(), Out);
2418 TypePrinter.print(GV->getValueType(), Out);
24192419
24202420 if (GV->hasInitializer()) {
24212421 Out << ' ';
763763 /// global. This includes an explicitly requested alignment (if the global
764764 /// has one).
765765 unsigned DataLayout::getPreferredAlignment(const GlobalVariable *GV) const {
766 Type *ElemType = GV->getType()->getElementType();
766 Type *ElemType = GV->getValueType();
767767 unsigned Alignment = getPrefTypeAlignment(ElemType);
768768 unsigned GVAlignment = GV->getAlignment();
769769 if (GVAlignment >= Alignment) {
241241 setGlobalVariableNumOperands(0);
242242 }
243243 } else {
244 assert(InitVal->getType() == getType()->getElementType() &&
244 assert(InitVal->getType() == getValueType() &&
245245 "Initializer type must match GlobalVariable type");
246246 // Note, the num operands is used to compute the offset of the operand, so
247247 // the order here matters. We need to set num operands to 1 first so that
520520
521521 void Verifier::visitGlobalVariable(const GlobalVariable &GV) {
522522 if (GV.hasInitializer()) {
523 Assert(GV.getInitializer()->getType() == GV.getType()->getElementType(),
523 Assert(GV.getInitializer()->getType() == GV.getValueType(),
524524 "Global variable initializer type does not match global "
525525 "variable type!",
526526 &GV);
718718 // identical version of the symbol over in the dest module... the
719719 // initializer will be filled in later by LinkGlobalInits.
720720 GlobalVariable *NewDGV =
721 new GlobalVariable(DstM, TypeMap.get(SGVar->getType()->getElementType()),
721 new GlobalVariable(DstM, TypeMap.get(SGVar->getValueType()),
722722 SGVar->isConstant(), GlobalValue::ExternalLinkage,
723723 /*init*/ nullptr, SGVar->getName(),
724724 /*insertbefore*/ nullptr, SGVar->getThreadLocalMode(),
758758 NewGV = copyGlobalAliasProto(cast(SGV));
759759 else
760760 NewGV = new GlobalVariable(
761 DstM, TypeMap.get(SGV->getType()->getElementType()),
761 DstM, TypeMap.get(SGV->getValueType()),
762762 /*isConstant*/ false, GlobalValue::ExternalLinkage,
763763 /*init*/ nullptr, SGV->getName(),
764764 /*insertbefore*/ nullptr, SGV->getThreadLocalMode(),
801801 }
802802
803803 // Unify the element type of appending arrays.
804 ArrayType *DAT = cast(DGV->getType()->getElementType());
805 ArrayType *SAT = cast(SGV.getType()->getElementType());
804 ArrayType *DAT = cast(DGV->getValueType());
805 ArrayType *SAT = cast(SGV.getValueType());
806806 TypeMap.addTypeMapping(DAT->getElementType(), SAT->getElementType());
807807 }
808808
873873 /// Return true on error.
874874 Constant *IRLinker::linkAppendingVarProto(GlobalVariable *DstGV,
875875 const GlobalVariable *SrcGV) {
876 Type *EltTy = cast(TypeMap.get(SrcGV->getType()->getElementType()))
876 Type *EltTy = cast(TypeMap.get(SrcGV->getValueType()))
877877 ->getElementType();
878878
879879 StringRef Name = SrcGV->getName();
894894 }
895895
896896 if (DstGV) {
897 ArrayType *DstTy = cast(DstGV->getType()->getElementType());
897 ArrayType *DstTy = cast(DstGV->getValueType());
898898
899899 if (!SrcGV->hasAppendingLinkage() || !DstGV->hasAppendingLinkage()) {
900900 emitError(
470470
471471 const DataLayout &DstDL = DstM.getDataLayout();
472472 const DataLayout &SrcDL = SrcM.getDataLayout();
473 uint64_t DstSize =
474 DstDL.getTypeAllocSize(DstGV->getType()->getPointerElementType());
475 uint64_t SrcSize =
476 SrcDL.getTypeAllocSize(SrcGV->getType()->getPointerElementType());
473 uint64_t DstSize = DstDL.getTypeAllocSize(DstGV->getValueType());
474 uint64_t SrcSize = SrcDL.getTypeAllocSize(SrcGV->getValueType());
477475 if (Result == Comdat::SelectionKind::ExactMatch) {
478476 if (SrcGV->getInitializer() != DstGV->getInitializer())
479477 return emitError("Linking COMDATs named '" + ComdatName +
597595 }
598596
599597 const DataLayout &DL = Dest.getParent()->getDataLayout();
600 uint64_t DestSize = DL.getTypeAllocSize(Dest.getType()->getElementType());
601 uint64_t SrcSize = DL.getTypeAllocSize(Src.getType()->getElementType());
598 uint64_t DestSize = DL.getTypeAllocSize(Dest.getValueType());
599 uint64_t SrcSize = DL.getTypeAllocSize(Src.getValueType());
602600 LinkFromSrc = SrcSize > DestSize;
603601 return false;
604602 }
686686
687687 const GlobalValue *GV = GAN->getGlobal();
688688 unsigned Alignment = GV->getAlignment();
689 Type *Ty = GV->getType()->getElementType();
689 Type *Ty = GV->getValueType();
690690 if (Alignment == 0 && Ty->isSized())
691691 Alignment = DL.getABITypeAlignment(Ty);
692692
807807
808808 unsigned Offset;
809809 if (MFI->LocalMemoryObjects.count(GV) == 0) {
810 uint64_t Size = DL.getTypeAllocSize(GV->getType()->getElementType());
810 uint64_t Size = DL.getTypeAllocSize(GV->getValueType());
811811 Offset = MFI->LDSSize;
812812 MFI->LocalMemoryObjects[GV] = Offset;
813813 // XXX: Account for alignment?
821821 }
822822 case AMDGPUAS::CONSTANT_ADDRESS: {
823823 MachineFrameInfo *FrameInfo = DAG.getMachineFunction().getFrameInfo();
824 Type *EltType = GV->getType()->getElementType();
824 Type *EltType = GV->getValueType();
825825 unsigned Size = DL.getTypeAllocSize(EltType);
826826 unsigned Alignment = DL.getPrefTypeAlignment(EltType);
827827
7777 for (Module::global_iterator I = Mod->global_begin(),
7878 E = Mod->global_end(); I != E; ++I) {
7979 GlobalVariable *GV = &*I;
80 PointerType *GVTy = GV->getType();
81 if (GVTy->getAddressSpace() != AMDGPUAS::LOCAL_ADDRESS)
80 if (GV->getType()->getAddressSpace() != AMDGPUAS::LOCAL_ADDRESS)
8281 continue;
8382 for (Value::use_iterator U = GV->use_begin(),
8483 UE = GV->use_end(); U != UE; ++U) {
8786 continue;
8887 if (Use->getParent()->getParent() == &F)
8988 LocalMemAvailable -=
90 Mod->getDataLayout().getTypeAllocSize(GVTy->getElementType());
89 Mod->getDataLayout().getTypeAllocSize(GV->getValueType());
9190 }
9291 }
9392 }
436436
437437 if (const GlobalVariable* GV = dyn_cast(val)) {
438438 name = std::string("gvar_") +
439 getTypePrefix(GV->getType()->getElementType());
439 getTypePrefix(GV->getValueType());
440440 } else if (isa(val)) {
441441 name = std::string("func_");
442442 } else if (const Constant* C = dyn_cast(val)) {
996996 if (is_inline) {
997997 Out << " = mod->getGlobalVariable(mod->getContext(), ";
998998 printEscapedString(GV->getName());
999 Out << ", " << getCppName(GV->getType()->getElementType()) << ",true)";
999 Out << ", " << getCppName(GV->getValueType()) << ",true)";
10001000 nl(Out) << "if (!" << getCppName(GV) << ") {";
10011001 in(); nl(Out) << getCppName(GV);
10021002 }
10031003 Out << " = new GlobalVariable(/*Module=*/*mod, ";
10041004 nl(Out) << "/*Type=*/";
1005 printCppName(GV->getType()->getElementType());
1005 printCppName(GV->getValueType());
10061006 Out << ",";
10071007 nl(Out) << "/*isConstant=*/" << (GV->isConstant()?"true":"false");
10081008 Out << ",";
7373 return false;
7474
7575 if (Kind.isBSS() || Kind.isData() || Kind.isCommon()) {
76 Type *Ty = GV->getType()->getElementType();
76 Type *Ty = GV->getValueType();
7777 return IsInSmallSection(
7878 GV->getParent()->getDataLayout().getTypeAllocSize(Ty));
7979 }
105105 GV->hasCommonLinkage()))
106106 return false;
107107
108 Type *Ty = GV->getType()->getElementType();
108 Type *Ty = GV->getValueType();
109109 return IsInSmallSection(
110110 GV->getParent()->getDataLayout().getTypeAllocSize(Ty));
111111 }
10291029
10301030 // GlobalVariables are always constant pointers themselves.
10311031 PointerType *PTy = GVar->getType();
1032 Type *ETy = PTy->getElementType();
1032 Type *ETy = GVar->getValueType();
10331033
10341034 if (GVar->hasExternalLinkage()) {
10351035 if (GVar->hasInitializer())
13401340 const DataLayout &DL = getDataLayout();
13411341
13421342 // GlobalVariables are always constant pointers themselves.
1343 PointerType *PTy = GVar->getType();
1344 Type *ETy = PTy->getElementType();
1343 Type *ETy = GVar->getValueType();
13451344
13461345 O << ".";
1347 emitPTXAddressSpace(PTy->getAddressSpace(), O);
1346 emitPTXAddressSpace(GVar->getType()->getAddressSpace(), O);
13481347 if (GVar->getAlignment() == 0)
13491348 O << " .align " << (int)DL.getPrefTypeAlignment(ETy);
13501349 else
17141713 return;
17151714 }
17161715 if (const GlobalValue *GVar = dyn_cast(CPV)) {
1717 PointerType *PTy = dyn_cast(GVar->getType());
17181716 bool IsNonGenericPointer = false;
1719 if (PTy && PTy->getAddressSpace() != 0) {
1717 if (GVar->getType()->getAddressSpace() != 0) {
17201718 IsNonGenericPointer = true;
17211719 }
17221720 if (EmitGeneric && !isa(CPV) && !IsNonGenericPointer) {
8585 !llvm::isTexture(*GV) && !llvm::isSurface(*GV) &&
8686 !llvm::isSampler(*GV) && !GV->getName().startswith("llvm.")) {
8787 GlobalVariable *NewGV = new GlobalVariable(
88 M, GV->getType()->getElementType(), GV->isConstant(),
88 M, GV->getValueType(), GV->isConstant(),
8989 GV->getLinkage(),
9090 GV->hasInitializer() ? GV->getInitializer() : nullptr,
9191 "", GV, GV->getThreadLocalMode(), llvm::ADDRESS_SPACE_GLOBAL);
171171
172172 // See if the address space conversion requires the operand to be bitcast
173173 // to i8 addrspace(n)* first.
174 EVT ExtendedGVType = EVT::getEVT(GVType->getElementType(), true);
174 EVT ExtendedGVType = EVT::getEVT(GV->getValueType(), true);
175175 if (!ExtendedGVType.isInteger() && !ExtendedGVType.isFloatingPoint()) {
176176 // A bitcast to i8 addrspace(n)* on the operand is needed.
177177 LLVMContext &Context = M->getContext();
190190 // Another bitcast from i8 * to * is
191191 // required.
192192 DestTy =
193 PointerType::get(GVType->getElementType(), llvm::ADDRESS_SPACE_GENERIC);
193 PointerType::get(GV->getValueType(), llvm::ADDRESS_SPACE_GENERIC);
194194 CVTA = Builder.CreateBitCast(CVTA, DestTy, "cvta");
195195 } else {
196196 // A simple CVTA is enough.
197197 SmallVector ParamTypes;
198 ParamTypes.push_back(PointerType::get(GVType->getElementType(),
198 ParamTypes.push_back(PointerType::get(GV->getValueType(),
199199 llvm::ADDRESS_SPACE_GENERIC));
200200 ParamTypes.push_back(GVType);
201201 Function *CVTAFunction = Intrinsic::getDeclaration(
40904090 Callee.getOpcode() == ISD::TargetGlobalTLSAddress)
40914091 return false;
40924092
4093 return G->getGlobal()->getType()->getElementType()->isFunctionTy();
4093 return G->getGlobal()->getValueType()->isFunctionTy();
40944094 }
40954095
40964096 return false;
9292 assert( ( GV->hasExternalLinkage() || GV->hasWeakLinkage() ||
9393 GV->hasLinkOnceLinkage() || GV->hasCommonLinkage() ) &&
9494 "Unexpected linkage");
95 if (ArrayType *ATy = dyn_cast(
96 cast(GV->getType())->getElementType())) {
95 if (ArrayType *ATy = dyn_cast(GV->getValueType())) {
9796
9897 MCSymbol *SymGlob = OutContext.getOrCreateSymbol(
9998 Twine(Sym->getName() + StringRef(".globound")));
256256 // FIXME there is no actual debug info here
257257 SDLoc dl(GA);
258258
259 if (GV->getType()->getElementType()->isFunctionTy())
259 if (GV->getValueType()->isFunctionTy())
260260 return DAG.getNode(XCoreISD::PCRelativeWrapper, dl, MVT::i32, GA);
261261
262262 const auto *GVar = dyn_cast(GV);
271271 if (XTL.getTargetMachine().getCodeModel() == CodeModel::Small)
272272 return true;
273273
274 Type *ObjType = GV->getType()->getPointerElementType();
274 Type *ObjType = GV->getValueType();
275275 if (!ObjType->isSized())
276276 return false;
277277
188188 return false;
189189
190190 // Create replacement global.
191 ArrayType *NewType = createLoweredType(GV->getType()->getElementType());
191 ArrayType *NewType = createLoweredType(GV->getValueType());
192192 Constant *NewInitializer = nullptr;
193193 if (GV->hasInitializer())
194194 NewInitializer = createLoweredInitializer(NewType,
121121 if (Kind.isMergeableConst8()) return MergeableConst8Section;
122122 if (Kind.isMergeableConst16()) return MergeableConst16Section;
123123 }
124 Type *ObjType = GV->getType()->getPointerElementType();
124 Type *ObjType = GV->getValueType();
125125 auto &DL = GV->getParent()->getDataLayout();
126126 if (TM.getCodeModel() == CodeModel::Small || !ObjType->isSized() ||
127127 DL.getTypeAllocSize(ObjType) < CodeModelLargeSize) {
127127 makeVisible(*CurI, Delete);
128128
129129 if (Delete) {
130 Type *Ty = CurI->getType()->getElementType();
130 Type *Ty = CurI->getValueType();
131131
132132 CurI->removeFromParent();
133133 llvm::Value *Declaration;
119119 return false;
120120
121121 SmallVector Types;
122 Types.push_back(cast(GV->getType())->getElementType());
122 Types.push_back(GV->getValueType());
123123
124124 unsigned Limit = 20;
125125 do {
866866 }
867867
868868 Constant *RepValue = NewGV;
869 if (NewGV->getType() != GV->getType()->getElementType())
870 RepValue = ConstantExpr::getBitCast(RepValue,
871 GV->getType()->getElementType());
869 if (NewGV->getType() != GV->getValueType())
870 RepValue = ConstantExpr::getBitCast(RepValue, GV->getValueType());
872871
873872 // If there is a comparison against null, we will insert a global bool to
874873 // keep track of whether the global was initialized yet or not.
13961395
13971396 // Insert a store of null into each global.
13981397 for (unsigned i = 0, e = FieldGlobals.size(); i != e; ++i) {
1399 PointerType *PT = cast(FieldGlobals[i]->getType());
1400 Constant *Null = Constant::getNullValue(PT->getElementType());
1398 Type *ValTy = cast(FieldGlobals[i])->getValueType();
1399 Constant *Null = Constant::getNullValue(ValTy);
14011400 new StoreInst(Null, FieldGlobals[i], SI);
14021401 }
14031402 // Erase the original store.
15821581 /// boolean and select between the two values whenever it is used. This exposes
15831582 /// the values to other scalar optimizations.
15841583 static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) {
1585 Type *GVElType = GV->getType()->getElementType();
1584 Type *GVElType = GV->getValueType();
15861585
15871586 // If GVElType is already i1, it is already shrunk. If the type of the GV is
15881587 // an FP value, pointer or vector, don't do this optimization because a select
18781877 // If the global is in different address space, don't bring it to stack.
18791878 if (!GS.HasMultipleAccessingFunctions &&
18801879 GS.AccessingFunction &&
1881 GV->getType()->getElementType()->isSingleValueType() &&
1880 GV->getValueType()->isSingleValueType() &&
18821881 GV->getType()->getAddressSpace() == 0 &&
18831882 !GV->isExternallyInitialized() &&
18841883 allNonInstructionUsersCanBeMadeInstructions(GV) &&
18871886 DEBUG(dbgs() << "LOCALIZING GLOBAL: " << *GV << "\n");
18881887 Instruction &FirstI = const_cast(*GS.AccessingFunction
18891888 ->getEntryBlock().begin());
1890 Type *ElemTy = GV->getType()->getElementType();
1889 Type *ElemTy = GV->getValueType();
18911890 // FIXME: Pass Global's alignment when globals have alignment
18921891 AllocaInst *Alloca = new AllocaInst(ElemTy, nullptr,
18931892 GV->getName(), &FirstI);
26262625 Value *PtrArg = getVal(II->getArgOperand(1));
26272626 Value *Ptr = PtrArg->stripPointerCasts();
26282627 if (GlobalVariable *GV = dyn_cast(Ptr)) {
2629 Type *ElemTy = cast(GV->getType())->getElementType();
2628 Type *ElemTy = GV->getValueType();
26302629 if (!Size->isAllOnesValue() &&
26312630 Size->getValue().getLimitedValue() >=
26322631 DL.getTypeStoreSize(ElemTy)) {
23502350 "transformCallThroughTrampoline called with incorrect CallSite.");
23512351
23522352 Function *NestF =cast(Tramp->getArgOperand(1)->stripPointerCasts());
2353 PointerType *NestFPTy = cast(NestF->getType());
2354 FunctionType *NestFTy = cast(NestFPTy->getElementType());
2353 FunctionType *NestFTy = cast(NestF->getValueType());
23552354
23562355 const AttributeSet &NestAttrs = NestF->getAttributes();
23572356 if (!NestAttrs.isEmpty()) {
636636 if (!GV->hasDefinitiveInitializer() || !GV->isConstant())
637637 return false;
638638
639 uint64_t InitSize = DL.getTypeAllocSize(GV->getType()->getElementType());
639 uint64_t InitSize = DL.getTypeAllocSize(GV->getValueType());
640640 if (InitSize > MaxSize)
641641 return false;
642642 continue;
11831183 }
11841184
11851185 bool AddressSanitizerModule::ShouldInstrumentGlobal(GlobalVariable *G) {
1186 Type *Ty = cast(G->getType())->getElementType();
1186 Type *Ty = G->getValueType();
11871187 DEBUG(dbgs() << "GLOBAL: " << *G << "\n");
11881188
11891189 if (GlobalsMD.get(G).IsBlacklisted) return false;
13371337 M, MD.Name.empty() ? G->getName() : MD.Name,
13381338 /*AllowMerging*/ true);
13391339
1340 PointerType *PtrTy = cast(G->getType());
1341 Type *Ty = PtrTy->getElementType();
1340 Type *Ty = G->getValueType();
13421341 uint64_t SizeInBytes = DL.getTypeAllocSize(Ty);
13431342 uint64_t MinRZ = MinRedzoneSizeForGlobal();
13441343 // MinRZ <= RZ <= kMaxGlobalRedzone
133133
134134 StringRef GetGlobalTypeString(const GlobalValue &G) {
135135 // Types of GlobalVariables are always pointer types.
136 Type *GType = G.getType()->getElementType();
136 Type *GType = G.getValueType();
137137 // For now we support blacklisting struct types only.
138138 if (StructType *SGType = dyn_cast(GType)) {
139139 if (!SGType->isLiteral())
165165 if (isIn(*GA.getParent(), Category))
166166 return true;
167167
168 if (isa(GA.getType()->getElementType()))
168 if (isa(GA.getValueType()))
169169 return SCL->inSection("fun", GA.getName(), Category);
170170
171171 return SCL->inSection("global", GA.getName(), Category) ||
873873
874874 GlobalVariable *GV = CountersBySP[j].first;
875875 unsigned Arcs =
876 cast(GV->getType()->getElementType())->getNumElements();
876 cast(GV->getValueType())->getNumElements();
877877 Builder.CreateCall(EmitArcs, {Builder.getInt32(Arcs),
878878 Builder.CreateConstGEP2_64(GV, 0, 0)});
879879 }
965965 I = CountersBySP.begin(), E = CountersBySP.end();
966966 I != E; ++I) {
967967 GlobalVariable *GV = I->first;
968 Constant *Null = Constant::getNullValue(GV->getType()->getElementType());
968 Constant *Null = Constant::getNullValue(GV->getValueType());
969969 Builder.CreateStore(Null, GV);
970970 }
971971
762762
763763 auto *F = M->getFunction(GCSafepointPollName);
764764 assert(F && "gc.safepoint_poll function is missing");
765 assert(F->getType()->getElementType() ==
765 assert(F->getValueType() ==
766766 FunctionType::get(Type::getVoidTy(M->getContext()), false) &&
767767 "gc.safepoint_poll declared with wrong type");
768768 assert(!F->empty() && "gc.safepoint_poll must be a non-empty function");
227227 /// performing Interprocedural SCCP.
228228 void TrackValueOfGlobalVariable(GlobalVariable *GV) {
229229 // We only track the contents of scalar globals.
230 if (GV->getType()->getElementType()->isSingleValueType()) {
230 if (GV->getValueType()->isSingleValueType()) {
231231 LatticeVal &IV = TrackedGlobals[GV];
232232 if (!isa(GV->getInitializer()))
233233 IV.markConstant(GV->getInitializer());
5252 for (Module::const_global_iterator I = M->global_begin(), E = M->global_end();
5353 I != E; ++I) {
5454 GlobalVariable *GV = new GlobalVariable(*New,
55 I->getType()->getElementType(),
55 I->getValueType(),
5656 I->isConstant(), I->getLinkage(),
5757 (Constant*) nullptr, I->getName(),
5858 (GlobalVariable*) nullptr,
6565 // Loop over the functions in the module, making external functions as before
6666 for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) {
6767 Function *NF =
68 Function::Create(cast(I->getType()->getElementType()),
68 Function::Create(cast(I->getValueType()),
6969 I->getLinkage(), I->getName(), New.get());
7070 NF->copyAttributesFrom(&*I);
7171 VMap[&*I] = NF;
3232 if (GlobalVariable *GVCtor = M.getNamedGlobal(Array)) {
3333 // If there is a global_ctors array, use the existing struct type, which can
3434 // have 2 or 3 fields.
35 ArrayType *ATy = cast(GVCtor->getType()->getElementType());
35 ArrayType *ATy = cast(GVCtor->getValueType());
3636 EltTy = cast(ATy->getElementType());
3737 if (Constant *Init = GVCtor->getInitializer()) {
3838 unsigned n = Init->getNumOperands();
791791 }
792792
793793 static char getSymbolNMTypeChar(const GlobalValue &GV) {
794 if (GV.getType()->getElementType()->isFunctionTy())
794 if (GV.getValueType()->isFunctionTy())
795795 return 't';
796796 // FIXME: should we print 'b'? At the IR level we cannot be sure if this
797797 // will be in bss or not, but we could approximate.