From 2352b30c9606e1323cfc39f141bdeb42bca858b1 Mon Sep 17 00:00:00 2001 From: David Green Date: Wed, 12 Sep 2018 09:54:17 +0000 Subject: [SimplifyCFG] Put an alignment on generated switch tables Previously the alignment on the newly created switch table data was not set, meaning that DataLayout::getPreferredAlignment was free to overalign it to 16 bytes. This causes unnecessary code bloat. Differential Revision: https://reviews.llvm.org/D51800 llvm-svn: 342039 --- llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp') diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index b2b8c248b99..422d1c9ef0a 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -5036,6 +5036,9 @@ SwitchLookupTable::SwitchLookupTable( GlobalVariable::PrivateLinkage, Initializer, "switch.table." + FuncName); Array->setUnnamedAddr(GlobalValue::UnnamedAddr::Global); + // Set the alignment to that of an array items. We will be only loading one + // value out of it. + Array->setAlignment(DL.getPrefTypeAlignment(ValueType)); Kind = ArrayKind; } -- cgit v1.2.3