llvm.org GIT mirror llvm / 08fb05c
Supply alignment info to linker through LLVMSymbol. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31181 91177308-0d34-0410-b5e6-96231b3b80d8 Devang Patel 12 years ago
2 changed file(s) with 16 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
5656 void mayBeNotUsed();
5757
5858 LLVMSymbol (enum LTOLinkageTypes lt, GlobalValue *g, const std::string &n,
59 const std::string &m) : linkage(lt), gv(g), name(n),
60 mangledName(m) {}
59 const std::string &m, int a) : linkage(lt), gv(g), name(n),
60 mangledName(m), alignment(a) {}
6161
6262 const char *getName() { return name.c_str(); }
6363 const char *getMangledName() { return mangledName.c_str(); }
64 int getAlignment() { return alignment; }
6465
6566 private:
6667 enum LTOLinkageTypes linkage;
6768 GlobalValue *gv;
6869 std::string name;
6970 std::string mangledName;
71 int alignment;
7072 };
7173
7274 class string_compare {
3535 #include "llvm/Transforms/IPO.h"
3636 #include "llvm/Transforms/Scalar.h"
3737 #include "llvm/Analysis/LoadValueNumbering.h"
38 #include "llvm/Support/MathExtras.h"
3839 #include "llvm/LinkTimeOptimizer.h"
3940 #include
4041 #include
148149 return LTO_READ_FAILURE;
149150
150151 // Collect Target info
151 if (!Target)
152 getTarget(m);
152 getTarget(m);
153153
154154 if (!Target)
155155 return LTO_READ_FAILURE;
165165
166166 if (!f->isExternal() && lt != LTOInternalLinkage
167167 && strncmp (f->getName().c_str(), "llvm.", 5)) {
168 int alignment = ( 16 > f->getAlignment() ? 16 : f->getAlignment());
168169 LLVMSymbol *newSymbol = new LLVMSymbol(lt, f, f->getName(),
169 mangler.getValueName(f));
170 mangler.getValueName(f),
171 Log2_32(alignment));
170172 symbols[newSymbol->getMangledName()] = newSymbol;
171173 allSymbols[newSymbol->getMangledName()] = newSymbol;
172174 }
185187 LTOLinkageTypes lt = getLTOLinkageType(v);
186188 if (!v->isExternal() && lt != LTOInternalLinkage
187189 && strncmp (v->getName().c_str(), "llvm.", 5)) {
190 const TargetData *TD = Target->getTargetData();
188191 LLVMSymbol *newSymbol = new LLVMSymbol(lt, v, v->getName(),
189 mangler.getValueName(v));
192 mangler.getValueName(v),
193 TD->getPreferredAlignmentLog(v));
190194 symbols[newSymbol->getMangledName()] = newSymbol;
191195 allSymbols[newSymbol->getMangledName()] = newSymbol;
192196
204208 /// Use module M to find appropriate Target.
205209 void
206210 LTO::getTarget (Module *M) {
211
212 if (Target)
213 return;
207214
208215 std::string Err;
209216 const TargetMachineRegistry::Entry* March =
229236 PassManager Passes;
230237
231238 // Collect Target info
232 if (!Target)
233 getTarget(M);
239 getTarget(M);
234240
235241 if (!Target)
236242 return LTO_NO_TARGET;