summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorDavid Green <david.green@arm.com>2018-09-06 08:42:17 +0000
committerDavid Green <david.green@arm.com>2018-09-06 08:42:17 +0000
commite6918ca2b32269faa7629c9cd2786a7748f0ba58 (patch)
tree8e07522731a98f4c490b1d3705e7c7836453ad99 /llvm
parent8a9e059e5c593107cc007f04865b54131fe14545 (diff)
downloadbcm5719-llvm-e6918ca2b32269faa7629c9cd2786a7748f0ba58.tar.gz
bcm5719-llvm-e6918ca2b32269faa7629c9cd2786a7748f0ba58.zip
[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
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/IR/IRBuilder.cpp1
-rw-r--r--llvm/test/Transforms/InstCombine/printf-1.ll2
2 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp
index 405a56bfb31..91c950da71b 100644
--- a/llvm/lib/IR/IRBuilder.cpp
+++ b/llvm/lib/IR/IRBuilder.cpp
@@ -50,6 +50,7 @@ GlobalVariable *IRBuilderBase::CreateGlobalString(StringRef Str,
nullptr, GlobalVariable::NotThreadLocal,
AddressSpace);
GV->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
+ GV->setAlignment(1);
return GV;
}
diff --git a/llvm/test/Transforms/InstCombine/printf-1.ll b/llvm/test/Transforms/InstCombine/printf-1.ll
index ce1a91da72f..9d13b360f81 100644
--- a/llvm/test/Transforms/InstCombine/printf-1.ll
+++ b/llvm/test/Transforms/InstCombine/printf-1.ll
@@ -14,7 +14,7 @@ target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f3
@percent_f = constant [3 x i8] c"%f\00"
@percent_s = constant [4 x i8] c"%s\0A\00"
@empty = constant [1 x i8] c"\00"
-; CHECK: [[$STR:@[a-z0-9]+]] = private unnamed_addr constant [12 x i8] c"hello world\00"
+; CHECK: [[$STR:@[a-z0-9]+]] = private unnamed_addr constant [12 x i8] c"hello world\00", align 1
declare i32 @printf(i8*, ...)
OpenPOWER on IntegriCloud