Skip to content

Commit 3b5ae72

Browse files
Align global strings according to data layout
When creating global strings, some targets have requirements that need to be taken into account. Previously, the global strings created by `IRBuilder::createGlobalString` had a hard-coded alignment of `1`. This commit makes it so that the alignment is taken from the data layout instead, giving targets the chance to align global strings according to their preferences.
1 parent 5e21f2b commit 3b5ae72

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

llvm/lib/IR/IRBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ GlobalVariable *IRBuilderBase::CreateGlobalString(StringRef Str,
5252
*M, StrConstant->getType(), true, GlobalValue::PrivateLinkage,
5353
StrConstant, Name, nullptr, GlobalVariable::NotThreadLocal, AddressSpace);
5454
GV->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
55-
GV->setAlignment(Align(1));
55+
GV->setAlignment(M->getDataLayout().getPreferredAlign(GV));
5656
return GV;
5757
}
5858

0 commit comments

Comments
 (0)