diff options
| author | Bill Wendling <isanbard@gmail.com> | 2012-03-16 07:40:08 +0000 | 
|---|---|---|
| committer | Bill Wendling <isanbard@gmail.com> | 2012-03-16 07:40:08 +0000 | 
| commit | a2a26b546c488b83b6c1e3955ebae941fb48b2d0 (patch) | |
| tree | 57b35b41ecb519f03869381cd6c1cdc98d5e22d8 /llvm/lib/Transforms | |
| parent | 501d95c176df9e09ad0800bda598e63f7050a951 (diff) | |
| download | bcm5719-llvm-a2a26b546c488b83b6c1e3955ebae941fb48b2d0.tar.gz bcm5719-llvm-a2a26b546c488b83b6c1e3955ebae941fb48b2d0.zip | |
The alignment of the pointer part of the store instruction may have an
alignment. If that's the case, then we want to make sure that we don't increase
the alignment of the store instruction. Because if we increase it to be "more
aligned" than the pointer, code-gen may use instructions which require a greater
alignment than the pointer guarantees.
<rdar://problem/11043589>
llvm-svn: 152907
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp | 18 | 
1 files changed, 15 insertions, 3 deletions
| diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp index 7446a51a4db..fa68000df58 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -379,10 +379,22 @@ Instruction *InstCombiner::visitStoreInst(StoreInst &SI) {      unsigned EffectiveStoreAlign = StoreAlign != 0 ? StoreAlign :        TD->getABITypeAlignment(Val->getType()); -    if (KnownAlign > EffectiveStoreAlign) +    if (KnownAlign > EffectiveStoreAlign) {        SI.setAlignment(KnownAlign); -    else if (StoreAlign == 0) -      SI.setAlignment(EffectiveStoreAlign); +    } else if (StoreAlign == 0) { +      unsigned PtrAlign = 0; +      if (GlobalValue *GV = dyn_cast<GlobalValue>(Ptr->stripPointerCasts())) +        PtrAlign = GV->getAlignment(); + +      if (PtrAlign != 0 && PtrAlign < EffectiveStoreAlign) +        // The pointer alignment may be less than the effective store +        // alignment. If so, then we don't want to increase the alignment here, +        // since that could lead to code-gen using instructions which require a +        // higher alignment than the pointer guarantees. +        SI.setAlignment(PtrAlign); +      else +        SI.setAlignment(EffectiveStoreAlign); +    }    }    // Don't hack volatile/atomic stores. | 

