[llvm] r245746 - [opaque pointer types] Fix a few easy places in GlobalMerge that were accessing value types through pointee types
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 21 15:00:44 PDT 2015
Author: dblaikie
Date: Fri Aug 21 17:00:44 2015
New Revision: 245746
URL: http://llvm.org/viewvc/llvm-project?rev=245746&view=rev
Log:
[opaque pointer types] Fix a few easy places in GlobalMerge that were accessing value types through pointee types
Modified:
llvm/trunk/lib/CodeGen/GlobalMerge.cpp
Modified: llvm/trunk/lib/CodeGen/GlobalMerge.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalMerge.cpp?rev=245746&r1=245745&r2=245746&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalMerge.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalMerge.cpp Fri Aug 21 17:00:44 2015
@@ -193,14 +193,11 @@ bool GlobalMerge::doMerge(SmallVectorImp
Module &M, bool isConst, unsigned AddrSpace) const {
auto &DL = M.getDataLayout();
// FIXME: Find better heuristics
- std::stable_sort(
- Globals.begin(), Globals.end(),
- [&DL](const GlobalVariable *GV1, const GlobalVariable *GV2) {
- Type *Ty1 = cast<PointerType>(GV1->getType())->getElementType();
- Type *Ty2 = cast<PointerType>(GV2->getType())->getElementType();
-
- return (DL.getTypeAllocSize(Ty1) < DL.getTypeAllocSize(Ty2));
- });
+ std::stable_sort(Globals.begin(), Globals.end(),
+ [&DL](const GlobalVariable *GV1, const GlobalVariable *GV2) {
+ return DL.getTypeAllocSize(GV1->getValueType()) <
+ DL.getTypeAllocSize(GV2->getValueType());
+ });
// If we want to just blindly group all globals together, do so.
if (!GlobalMergeGroupByUse) {
@@ -429,7 +426,7 @@ bool GlobalMerge::doMerge(SmallVectorImp
std::vector<Constant*> Inits;
for (j = i; j != -1; j = GlobalSet.find_next(j)) {
- Type *Ty = Globals[j]->getType()->getElementType();
+ Type *Ty = Globals[j]->getValueType();
MergedSize += DL.getTypeAllocSize(Ty);
if (MergedSize > MaxOffset) {
break;
@@ -542,7 +539,7 @@ bool GlobalMerge::doInitialization(Modul
// Ignore fancy-aligned globals for now.
unsigned Alignment = DL.getPreferredAlignment(I);
- Type *Ty = I->getType()->getElementType();
+ Type *Ty = I->getValueType();
if (Alignment > DL.getABITypeAlignment(Ty))
continue;
More information about the llvm-commits
mailing list