From 46084383868b63daf87f1dabdc6e09a39e2ff077 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Tue, 21 Apr 2015 17:27:59 +0000 Subject: 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 --- clang/lib/CodeGen/CodeGenModule.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 17b7ddc..b30885d 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -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()) { -- cgit v1.1