1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

Revert the recent alignment changes. They're broken for -Os because,

in particular, they end up aligning strings at 16-byte boundaries, and
there's no way for GlobalOpt to check OptForSize.

llvm-svn: 100172
This commit is contained in:
Dan Gohman 2010-04-02 03:04:37 +00:00
parent 921fc2c77b
commit 7051600e3f
5 changed files with 4 additions and 16 deletions

View File

@ -651,7 +651,7 @@ unsigned TargetData::getPreferredAlignment(const GlobalVariable *GV) const {
if (Alignment < 16) {
// If the global is not external, see if it is large. If so, give it a
// larger alignment.
if (getTypeSizeInBits(ElemType) >= 128)
if (getTypeSizeInBits(ElemType) > 128)
Alignment = 16; // 16-byte alignment.
}
}

View File

@ -1880,7 +1880,6 @@ bool GlobalOpt::OptimizeFunctions(Module &M) {
bool GlobalOpt::OptimizeGlobalVars(Module &M) {
bool Changed = false;
TargetData *TD = getAnalysisIfAvailable<TargetData>();
for (Module::global_iterator GVI = M.global_begin(), E = M.global_end();
GVI != E; ) {
GlobalVariable *GV = GVI++;
@ -1890,16 +1889,11 @@ bool GlobalOpt::OptimizeGlobalVars(Module &M) {
// Simplify the initializer.
if (GV->hasInitializer())
if (ConstantExpr *CE = dyn_cast<ConstantExpr>(GV->getInitializer())) {
TargetData *TD = getAnalysisIfAvailable<TargetData>();
Constant *New = ConstantFoldConstantExpression(CE, TD);
if (New && New != CE)
GV->setInitializer(New);
}
// Refine the alignment value.
if (TD && GV->hasDefinitiveInitializer()) {
unsigned Align = TD->getPreferredAlignment(GV);
if (Align > GV->getAlignment())
GV->setAlignment(Align);
}
// Do more involved optimizations if the global is internal.
if (!GV->isConstant() && GV->hasLocalLinkage() &&
GV->hasInitializer())

View File

@ -113,7 +113,7 @@
; DARWIN: .globl _G9
; DARWIN: _G9:
; LINUX: .section .rodata.str4.16,"aMS",@progbits,4
; LINUX: .section .rodata.str4.4,"aMS",@progbits,4
; LINUX: .globl G9
; LINUX:G9

View File

@ -4,7 +4,7 @@
; RUN: grep movups %t | count 2
target triple = "i686-apple-darwin"
@x = external global [4 x i32]
@x = global [4 x i32] [ i32 1, i32 2, i32 3, i32 4 ] ; <[4 x i32]*> [#uses=4]
define <2 x i64> @test1() {
%tmp = load i32* getelementptr ([4 x i32]* @x, i32 0, i32 0) ; <i32> [#uses=1]

View File

@ -1,6 +0,0 @@
; RUN: opt -globalopt -S < %s | grep {, align 16}
; Globalopt should refine the alignment for global variables.
target datalayout = "e-p:64:64:64"
@a = global [4 x i32] [i32 2, i32 3, i32 4, i32 5 ]