[llvm-commits] [llvm] r100172 - in /llvm/trunk: lib/Target/TargetData.cpp lib/Transforms/IPO/GlobalOpt.cpp test/CodeGen/X86/global-sections.ll test/CodeGen/X86/vec_shuffle-6.ll test/Transforms/GlobalOpt/gv-align.ll
Dan Gohman
gohman at apple.com
Thu Apr 1 20:04:37 PDT 2010
Author: djg
Date: Thu Apr 1 22:04:37 2010
New Revision: 100172
URL: http://llvm.org/viewvc/llvm-project?rev=100172&view=rev
Log:
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.
Removed:
llvm/trunk/test/Transforms/GlobalOpt/gv-align.ll
Modified:
llvm/trunk/lib/Target/TargetData.cpp
llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
llvm/trunk/test/CodeGen/X86/global-sections.ll
llvm/trunk/test/CodeGen/X86/vec_shuffle-6.ll
Modified: llvm/trunk/lib/Target/TargetData.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=100172&r1=100171&r2=100172&view=diff
==============================================================================
--- llvm/trunk/lib/Target/TargetData.cpp (original)
+++ llvm/trunk/lib/Target/TargetData.cpp Thu Apr 1 22:04:37 2010
@@ -651,7 +651,7 @@
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.
}
}
Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=100172&r1=100171&r2=100172&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Thu Apr 1 22:04:37 2010
@@ -1880,7 +1880,6 @@
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 @@
// 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())
Modified: llvm/trunk/test/CodeGen/X86/global-sections.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/global-sections.ll?rev=100172&r1=100171&r2=100172&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/global-sections.ll (original)
+++ llvm/trunk/test/CodeGen/X86/global-sections.ll Thu Apr 1 22:04:37 2010
@@ -113,7 +113,7 @@
; DARWIN: .globl _G9
; DARWIN: _G9:
-; LINUX: .section .rodata.str4.16,"aMS", at progbits,4
+; LINUX: .section .rodata.str4.4,"aMS", at progbits,4
; LINUX: .globl G9
; LINUX:G9
Modified: llvm/trunk/test/CodeGen/X86/vec_shuffle-6.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/vec_shuffle-6.ll?rev=100172&r1=100171&r2=100172&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/vec_shuffle-6.ll (original)
+++ llvm/trunk/test/CodeGen/X86/vec_shuffle-6.ll Thu Apr 1 22:04:37 2010
@@ -4,7 +4,7 @@
; RUN: grep movups %t | count 2
target triple = "i686-apple-darwin"
- at x = external global [4 x i32]
+ at 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]
Removed: llvm/trunk/test/Transforms/GlobalOpt/gv-align.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GlobalOpt/gv-align.ll?rev=100171&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/GlobalOpt/gv-align.ll (original)
+++ llvm/trunk/test/Transforms/GlobalOpt/gv-align.ll (removed)
@@ -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"
- at a = global [4 x i32] [i32 2, i32 3, i32 4, i32 5 ]
More information about the llvm-commits
mailing list