diff options
author | Richard Osborne <richard@xmos.com> | 2012-09-18 09:31:44 +0000 |
---|---|---|
committer | Richard Osborne <richard@xmos.com> | 2012-09-18 09:31:44 +0000 |
commit | d7cc8b839cba201b552698646b624da7a79ede8e (patch) | |
tree | 412b93a532a7dd14b1d7491fd584bbecdd4fb4b2 /lib/Transforms/InstCombine | |
parent | 97ecb83dffb5ff78ff84e9da21189268f52c63b2 (diff) | |
download | external_llvm-d7cc8b839cba201b552698646b624da7a79ede8e.zip external_llvm-d7cc8b839cba201b552698646b624da7a79ede8e.tar.gz external_llvm-d7cc8b839cba201b552698646b624da7a79ede8e.tar.bz2 |
Fix instcombine to obey requested alignment when merging allocas.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164117 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/InstCombine')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp index 6ecb4c5..5b6cf4a 100644 --- a/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -246,12 +246,16 @@ Instruction *InstCombiner::visitAllocaInst(AllocaInst &AI) { return &AI; } + // If the alignment of the entry block alloca is 0 (unspecified), + // assign it the preferred alignment. + if (EntryAI->getAlignment() == 0) + EntryAI->setAlignment( + TD->getPrefTypeAlignment(EntryAI->getAllocatedType())); // Replace this zero-sized alloca with the one at the start of the entry // block after ensuring that the address will be aligned enough for both // types. - unsigned MaxAlign = - std::max(TD->getPrefTypeAlignment(EntryAI->getAllocatedType()), - TD->getPrefTypeAlignment(AI.getAllocatedType())); + unsigned MaxAlign = std::max(EntryAI->getAlignment(), + AI.getAlignment()); EntryAI->setAlignment(MaxAlign); if (AI.getType() != EntryAI->getType()) return new BitCastInst(EntryAI, AI.getType()); |