forked from OSchip/llvm-project
[opaque pointer types] Switch a few cases of getElementType over, since I had them lying around anyway
llvm-svn: 247610
This commit is contained in:
parent
601771ebc0
commit
6614d8d230
|
@ -441,13 +441,13 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals,
|
|||
M, MergedTy, isConst, GlobalValue::PrivateLinkage, MergedInit,
|
||||
"_MergedGlobals", nullptr, GlobalVariable::NotThreadLocal, AddrSpace);
|
||||
|
||||
for (ssize_t k = i, idx = 0; k != j; k = GlobalSet.find_next(k)) {
|
||||
for (ssize_t k = i, idx = 0; k != j; k = GlobalSet.find_next(k), ++idx) {
|
||||
GlobalValue::LinkageTypes Linkage = Globals[k]->getLinkage();
|
||||
std::string Name = Globals[k]->getName();
|
||||
|
||||
Constant *Idx[2] = {
|
||||
ConstantInt::get(Int32Ty, 0),
|
||||
ConstantInt::get(Int32Ty, idx++)
|
||||
ConstantInt::get(Int32Ty, idx),
|
||||
};
|
||||
Constant *GEP =
|
||||
ConstantExpr::getInBoundsGetElementPtr(MergedTy, MergedGV, Idx);
|
||||
|
@ -461,9 +461,7 @@ bool GlobalMerge::doMerge(const SmallVectorImpl<GlobalVariable *> &Globals,
|
|||
// MergedGlobals variable) may be dead stripped at link time.
|
||||
if (Linkage != GlobalValue::InternalLinkage ||
|
||||
!TM->getTargetTriple().isOSBinFormatMachO()) {
|
||||
auto *PTy = cast<PointerType>(GEP->getType());
|
||||
GlobalAlias::create(PTy->getElementType(), PTy->getAddressSpace(),
|
||||
Linkage, Name, GEP, &M);
|
||||
GlobalAlias::create(Tys[idx], AddrSpace, Linkage, Name, GEP, &M);
|
||||
}
|
||||
|
||||
NumMerged++;
|
||||
|
|
|
@ -585,8 +585,8 @@ static GlobalAlias *copyGlobalAliasProto(TypeMapTy &TypeMap, Module &DstM,
|
|||
const GlobalAlias *SGA) {
|
||||
// If there is no linkage to be performed or we're linking from the source,
|
||||
// bring over SGA.
|
||||
auto *PTy = cast<PointerType>(TypeMap.get(SGA->getType()));
|
||||
return GlobalAlias::create(PTy->getElementType(), PTy->getAddressSpace(),
|
||||
auto *Ty = TypeMap.get(SGA->getValueType());
|
||||
return GlobalAlias::create(Ty, SGA->getType()->getPointerAddressSpace(),
|
||||
SGA->getLinkage(), SGA->getName(), &DstM);
|
||||
}
|
||||
|
||||
|
|
|
@ -537,7 +537,7 @@ void LowerBitSets::buildBitSetsFromGlobalVariables(
|
|||
const DataLayout &DL = M->getDataLayout();
|
||||
for (GlobalVariable *G : Globals) {
|
||||
GlobalInits.push_back(G->getInitializer());
|
||||
uint64_t InitSize = DL.getTypeAllocSize(G->getInitializer()->getType());
|
||||
uint64_t InitSize = DL.getTypeAllocSize(G->getValueType());
|
||||
|
||||
// Compute the amount of padding required.
|
||||
uint64_t Padding = NextPowerOf2(InitSize - 1) - InitSize;
|
||||
|
@ -553,12 +553,12 @@ void LowerBitSets::buildBitSetsFromGlobalVariables(
|
|||
if (!GlobalInits.empty())
|
||||
GlobalInits.pop_back();
|
||||
Constant *NewInit = ConstantStruct::getAnon(M->getContext(), GlobalInits);
|
||||
auto CombinedGlobal =
|
||||
auto *CombinedGlobal =
|
||||
new GlobalVariable(*M, NewInit->getType(), /*isConstant=*/true,
|
||||
GlobalValue::PrivateLinkage, NewInit);
|
||||
|
||||
const StructLayout *CombinedGlobalLayout =
|
||||
DL.getStructLayout(cast<StructType>(NewInit->getType()));
|
||||
StructType *NewTy = cast<StructType>(NewInit->getType());
|
||||
const StructLayout *CombinedGlobalLayout = DL.getStructLayout(NewTy);
|
||||
|
||||
// Compute the offsets of the original globals within the new global.
|
||||
DenseMap<GlobalObject *, uint64_t> GlobalLayout;
|
||||
|
@ -580,10 +580,10 @@ void LowerBitSets::buildBitSetsFromGlobalVariables(
|
|||
if (LinkerSubsectionsViaSymbols) {
|
||||
Globals[I]->replaceAllUsesWith(CombinedGlobalElemPtr);
|
||||
} else {
|
||||
GlobalAlias *GAlias = GlobalAlias::create(
|
||||
Globals[I]->getType()->getElementType(),
|
||||
Globals[I]->getType()->getAddressSpace(), Globals[I]->getLinkage(),
|
||||
"", CombinedGlobalElemPtr, M);
|
||||
assert(Globals[I]->getType()->getAddressSpace() == 0);
|
||||
GlobalAlias *GAlias = GlobalAlias::create(NewTy->getElementType(I * 2), 0,
|
||||
Globals[I]->getLinkage(), "",
|
||||
CombinedGlobalElemPtr, M);
|
||||
GAlias->setVisibility(Globals[I]->getVisibility());
|
||||
GAlias->takeName(Globals[I]);
|
||||
Globals[I]->replaceAllUsesWith(GAlias);
|
||||
|
@ -818,10 +818,10 @@ void LowerBitSets::buildBitSetsFromFunctions(ArrayRef<Metadata *> BitSets,
|
|||
if (LinkerSubsectionsViaSymbols || Functions[I]->isDeclarationForLinker()) {
|
||||
Functions[I]->replaceAllUsesWith(CombinedGlobalElemPtr);
|
||||
} else {
|
||||
GlobalAlias *GAlias = GlobalAlias::create(
|
||||
Functions[I]->getType()->getElementType(),
|
||||
Functions[I]->getType()->getAddressSpace(),
|
||||
Functions[I]->getLinkage(), "", CombinedGlobalElemPtr, M);
|
||||
assert(Functions[I]->getType()->getAddressSpace() == 0);
|
||||
GlobalAlias *GAlias = GlobalAlias::create(Functions[I]->getValueType(), 0,
|
||||
Functions[I]->getLinkage(), "",
|
||||
CombinedGlobalElemPtr, M);
|
||||
GAlias->setVisibility(Functions[I]->getVisibility());
|
||||
GAlias->takeName(Functions[I]);
|
||||
Functions[I]->replaceAllUsesWith(GAlias);
|
||||
|
|
|
@ -1682,9 +1682,7 @@ void MergeFunctions::writeThunk(Function *F, Function *G) {
|
|||
|
||||
// Replace G with an alias to F and delete G.
|
||||
void MergeFunctions::writeAlias(Function *F, Function *G) {
|
||||
PointerType *PTy = G->getType();
|
||||
auto *GA = GlobalAlias::create(PTy->getElementType(), PTy->getAddressSpace(),
|
||||
G->getLinkage(), "", F);
|
||||
auto *GA = GlobalAlias::create(G->getLinkage(), "", F);
|
||||
F->setAlignment(std::max(F->getAlignment(), G->getAlignment()));
|
||||
GA->takeName(G);
|
||||
GA->setVisibility(G->getVisibility());
|
||||
|
|
|
@ -94,10 +94,9 @@ Module *llvm::CloneModule(
|
|||
// correctness.
|
||||
continue;
|
||||
}
|
||||
auto *PTy = cast<PointerType>(I->getType());
|
||||
auto *GA =
|
||||
GlobalAlias::create(PTy->getElementType(), PTy->getAddressSpace(),
|
||||
I->getLinkage(), I->getName(), New);
|
||||
auto *GA = GlobalAlias::create(I->getValueType(),
|
||||
I->getType()->getPointerAddressSpace(),
|
||||
I->getLinkage(), I->getName(), New);
|
||||
GA->copyAttributesFrom(I);
|
||||
VMap[I] = GA;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue