1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +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();
LLVMSymbol (enum LTOLinkageTypes lt, GlobalValue *g, const std::string &n,
const std::string &m) : linkage(lt), gv(g), name(n),
mangledName(m) {}
const std::string &m, int a) : linkage(lt), gv(g), name(n),
mangledName(m), alignment(a) {}
const char *getName() { return name.c_str(); }
const char *getMangledName() { return mangledName.c_str(); }
int getAlignment() { return alignment; }
private:
enum LTOLinkageTypes linkage;
GlobalValue *gv;
std::string name;
std::string mangledName;
int alignment;
};
class string_compare {

View File

@ -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;