1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

Supply alignment info to linker through LLVMSymbol.

llvm-svn: 31181
This commit is contained in:
Devang Patel 2006-10-25 18:10:07 +00:00
parent df59442a74
commit 3c1afad503
2 changed files with 16 additions and 8 deletions

View File

@ -57,17 +57,19 @@ namespace llvm {
void mayBeNotUsed(); void mayBeNotUsed();
LLVMSymbol (enum LTOLinkageTypes lt, GlobalValue *g, const std::string &n, LLVMSymbol (enum LTOLinkageTypes lt, GlobalValue *g, const std::string &n,
const std::string &m) : linkage(lt), gv(g), name(n), const std::string &m, int a) : linkage(lt), gv(g), name(n),
mangledName(m) {} mangledName(m), alignment(a) {}
const char *getName() { return name.c_str(); } const char *getName() { return name.c_str(); }
const char *getMangledName() { return mangledName.c_str(); } const char *getMangledName() { return mangledName.c_str(); }
int getAlignment() { return alignment; }
private: private:
enum LTOLinkageTypes linkage; enum LTOLinkageTypes linkage;
GlobalValue *gv; GlobalValue *gv;
std::string name; std::string name;
std::string mangledName; std::string mangledName;
int alignment;
}; };
class string_compare { class string_compare {

View File

@ -36,6 +36,7 @@
#include "llvm/Transforms/IPO.h" #include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Scalar.h"
#include "llvm/Analysis/LoadValueNumbering.h" #include "llvm/Analysis/LoadValueNumbering.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/LinkTimeOptimizer.h" #include "llvm/LinkTimeOptimizer.h"
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
@ -149,8 +150,7 @@ LTO::readLLVMObjectFile(const std::string &InputFilename,
return LTO_READ_FAILURE; return LTO_READ_FAILURE;
// Collect Target info // Collect Target info
if (!Target) getTarget(m);
getTarget(m);
if (!Target) if (!Target)
return LTO_READ_FAILURE; return LTO_READ_FAILURE;
@ -166,8 +166,10 @@ LTO::readLLVMObjectFile(const std::string &InputFilename,
if (!f->isExternal() && lt != LTOInternalLinkage if (!f->isExternal() && lt != LTOInternalLinkage
&& strncmp (f->getName().c_str(), "llvm.", 5)) { && strncmp (f->getName().c_str(), "llvm.", 5)) {
int alignment = ( 16 > f->getAlignment() ? 16 : f->getAlignment());
LLVMSymbol *newSymbol = new LLVMSymbol(lt, f, f->getName(), LLVMSymbol *newSymbol = new LLVMSymbol(lt, f, f->getName(),
mangler.getValueName(f)); mangler.getValueName(f),
Log2_32(alignment));
symbols[newSymbol->getMangledName()] = newSymbol; symbols[newSymbol->getMangledName()] = newSymbol;
allSymbols[newSymbol->getMangledName()] = newSymbol; allSymbols[newSymbol->getMangledName()] = newSymbol;
} }
@ -186,8 +188,10 @@ LTO::readLLVMObjectFile(const std::string &InputFilename,
LTOLinkageTypes lt = getLTOLinkageType(v); LTOLinkageTypes lt = getLTOLinkageType(v);
if (!v->isExternal() && lt != LTOInternalLinkage if (!v->isExternal() && lt != LTOInternalLinkage
&& strncmp (v->getName().c_str(), "llvm.", 5)) { && strncmp (v->getName().c_str(), "llvm.", 5)) {
const TargetData *TD = Target->getTargetData();
LLVMSymbol *newSymbol = new LLVMSymbol(lt, v, v->getName(), LLVMSymbol *newSymbol = new LLVMSymbol(lt, v, v->getName(),
mangler.getValueName(v)); mangler.getValueName(v),
TD->getPreferredAlignmentLog(v));
symbols[newSymbol->getMangledName()] = newSymbol; symbols[newSymbol->getMangledName()] = newSymbol;
allSymbols[newSymbol->getMangledName()] = newSymbol; allSymbols[newSymbol->getMangledName()] = newSymbol;
@ -206,6 +210,9 @@ LTO::readLLVMObjectFile(const std::string &InputFilename,
void void
LTO::getTarget (Module *M) { LTO::getTarget (Module *M) {
if (Target)
return;
std::string Err; std::string Err;
const TargetMachineRegistry::Entry* March = const TargetMachineRegistry::Entry* March =
TargetMachineRegistry::getClosestStaticTargetForModule(*M, Err); TargetMachineRegistry::getClosestStaticTargetForModule(*M, Err);
@ -230,8 +237,7 @@ LTO::optimize(Module *M, std::ostream &Out,
PassManager Passes; PassManager Passes;
// Collect Target info // Collect Target info
if (!Target) getTarget(M);
getTarget(M);
if (!Target) if (!Target)
return LTO_NO_TARGET; return LTO_NO_TARGET;