[SLC] Add an alignment to CreateGlobalString
authorDavid Green <david.green@arm.com>
Thu, 6 Sep 2018 08:42:17 +0000 (08:42 +0000)
committerDavid Green <david.green@arm.com>
Thu, 6 Sep 2018 08:42:17 +0000 (08:42 +0000)
commite6918ca2b32269faa7629c9cd2786a7748f0ba58
tree8e07522731a98f4c490b1d3705e7c7836453ad99
parent8a9e059e5c593107cc007f04865b54131fe14545
[SLC] Add an alignment to CreateGlobalString

Previously the alignment on the newly created global strings was not set,
meaning that DataLayout::getPreferredAlignment was free to overalign it
to 16 bytes. This caused unnecessary code bloat with the padding between
variables.

The main example of this happening was the printf->puts optimisation in
SimplifyLibCalls, but as the change here is made in
IRBuilderBase::CreateGlobalString, other globals using this will now be
aligned too.

Differential Revision: https://reviews.llvm.org/D51410

llvm-svn: 341527
llvm/lib/IR/IRBuilder.cpp
llvm/test/Transforms/InstCombine/printf-1.ll