Provide alignment info on LLVM external symbols

Code in CodeGenModule::GetOrCreateLLVMGlobal that sets up GlobalValue
object for LLVM external symbols has this comment:

    // FIXME: This code is overly simple and should be merged with other global
    // handling.

One part does seems to be "overly simple" currently is that this code
never sets any alignment info on the GlobalValue, so that the emitted
IR does not have any align attribute on external globals.  This can
lead to unnecessarily inefficient code generation.

This patch adds a GV->setAlignment call to set alignment info.

llvm-svn: 235396
This commit is contained in:
Ulrich Weigand
2015-04-21 17:27:59 +00:00
parent b63f779be4
commit 4608438386
2 changed files with 15 additions and 0 deletions

View File

@@ -1777,6 +1777,8 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
// handling.
GV->setConstant(isTypeConstant(D->getType(), false));
GV->setAlignment(getContext().getDeclAlign(D).getQuantity());
setLinkageAndVisibilityForGV(GV, D);
if (D->getTLSKind()) {