diff options
author | Devang Patel <dpatel@apple.com> | 2006-10-25 18:10:07 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2006-10-25 18:10:07 +0000 |
commit | 08fb05c3ac440979021f508bfee073359be46f7e (patch) | |
tree | e080d6d1ec5c6a43fefd2cce1232343046ae8e97 /tools/lto | |
parent | 323ece6fcd9722482a0be6c82afc5abc75739c78 (diff) | |
download | external_llvm-08fb05c3ac440979021f508bfee073359be46f7e.zip external_llvm-08fb05c3ac440979021f508bfee073359be46f7e.tar.gz external_llvm-08fb05c3ac440979021f508bfee073359be46f7e.tar.bz2 |
Supply alignment info to linker through LLVMSymbol.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31181 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/lto')
-rw-r--r-- | tools/lto/lto.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp index 5c50770..b08b1a6 100644 --- a/tools/lto/lto.cpp +++ b/tools/lto/lto.cpp @@ -36,6 +36,7 @@ #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Analysis/LoadValueNumbering.h" +#include "llvm/Support/MathExtras.h" #include "llvm/LinkTimeOptimizer.h" #include <fstream> #include <iostream> @@ -149,8 +150,7 @@ LTO::readLLVMObjectFile(const std::string &InputFilename, return LTO_READ_FAILURE; // Collect Target info - if (!Target) - getTarget(m); + getTarget(m); if (!Target) return LTO_READ_FAILURE; @@ -166,8 +166,10 @@ LTO::readLLVMObjectFile(const std::string &InputFilename, if (!f->isExternal() && lt != LTOInternalLinkage && strncmp (f->getName().c_str(), "llvm.", 5)) { + int alignment = ( 16 > f->getAlignment() ? 16 : f->getAlignment()); LLVMSymbol *newSymbol = new LLVMSymbol(lt, f, f->getName(), - mangler.getValueName(f)); + mangler.getValueName(f), + Log2_32(alignment)); symbols[newSymbol->getMangledName()] = newSymbol; allSymbols[newSymbol->getMangledName()] = newSymbol; } @@ -186,8 +188,10 @@ LTO::readLLVMObjectFile(const std::string &InputFilename, LTOLinkageTypes lt = getLTOLinkageType(v); if (!v->isExternal() && lt != LTOInternalLinkage && strncmp (v->getName().c_str(), "llvm.", 5)) { + const TargetData *TD = Target->getTargetData(); LLVMSymbol *newSymbol = new LLVMSymbol(lt, v, v->getName(), - mangler.getValueName(v)); + mangler.getValueName(v), + TD->getPreferredAlignmentLog(v)); symbols[newSymbol->getMangledName()] = newSymbol; allSymbols[newSymbol->getMangledName()] = newSymbol; @@ -206,6 +210,9 @@ LTO::readLLVMObjectFile(const std::string &InputFilename, void LTO::getTarget (Module *M) { + if (Target) + return; + std::string Err; const TargetMachineRegistry::Entry* March = TargetMachineRegistry::getClosestStaticTargetForModule(*M, Err); @@ -230,8 +237,7 @@ LTO::optimize(Module *M, std::ostream &Out, PassManager Passes; // Collect Target info - if (!Target) - getTarget(M); + getTarget(M); if (!Target) return LTO_NO_TARGET; |