diff options
-rw-r--r-- | lib/Target/TargetData.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/IPO/GlobalOpt.cpp | 8 | ||||
-rw-r--r-- | test/CodeGen/X86/global-sections.ll | 2 | ||||
-rw-r--r-- | test/CodeGen/X86/vec_shuffle-6.ll | 2 | ||||
-rw-r--r-- | test/Transforms/GlobalOpt/gv-align.ll | 6 |
5 files changed, 4 insertions, 16 deletions
diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index 652fc18..643b397 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -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. } } diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index c09e78e..ddff5ef 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -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()) diff --git a/test/CodeGen/X86/global-sections.ll b/test/CodeGen/X86/global-sections.ll index 2aba834..d79c56b 100644 --- a/test/CodeGen/X86/global-sections.ll +++ b/test/CodeGen/X86/global-sections.ll @@ -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 diff --git a/test/CodeGen/X86/vec_shuffle-6.ll b/test/CodeGen/X86/vec_shuffle-6.ll index 28fd59b..f034b0a 100644 --- a/test/CodeGen/X86/vec_shuffle-6.ll +++ b/test/CodeGen/X86/vec_shuffle-6.ll @@ -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] diff --git a/test/Transforms/GlobalOpt/gv-align.ll b/test/Transforms/GlobalOpt/gv-align.ll deleted file mode 100644 index f99e8a6..0000000 --- a/test/Transforms/GlobalOpt/gv-align.ll +++ /dev/null @@ -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 ] |