llvm.org GIT mirror llvm / 76b13ed
Cleanup whitespace. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153804 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 8 years ago
1 changed file(s) with 17 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
33 //
44 // This file is distributed under the University of Illinois Open Source
55 // License. See LICENSE.TXT for details.
6 //
6 //
77 //===----------------------------------------------------------------------===//
88 //
9 // This file implements the Link Time Optimization library. This library is
9 // This file implements the Link Time Optimization library. This library is
1010 // intended to be used by linker to optimize code at link time.
1111 //
1212 //===----------------------------------------------------------------------===//
6363 #endif
6464 }
6565
66 LTOCodeGenerator::LTOCodeGenerator()
66 LTOCodeGenerator::LTOCodeGenerator()
6767 : _context(getGlobalContext()),
6868 _linker("LinkTimeOptimizer", "ld-temp.o", _context), _target(NULL),
6969 _emitDwarfDebugInfo(false), _scopeRestrictionsDone(false),
9494
9595 return ret;
9696 }
97
97
9898
9999 bool LTOCodeGenerator::setDebugInfo(lto_debug_model debug, std::string& errMsg)
100100 {
102102 case LTO_DEBUG_MODEL_NONE:
103103 _emitDwarfDebugInfo = false;
104104 return false;
105
105
106106 case LTO_DEBUG_MODEL_DWARF:
107107 _emitDwarfDebugInfo = true;
108108 return false;
111111 }
112112
113113
114 bool LTOCodeGenerator::setCodePICModel(lto_codegen_model model,
114 bool LTOCodeGenerator::setCodePICModel(lto_codegen_model model,
115115 std::string& errMsg)
116116 {
117117 switch (model) {
140140 if (determineTarget(errMsg))
141141 return true;
142142
143 // mark which symbols can not be internalized
143 // mark which symbols can not be internalized
144144 applyScopeRestrictions();
145145
146146 // create output file
152152 errMsg += path;
153153 return true;
154154 }
155
155
156156 // write bitcode to it
157157 WriteBitcodeToFile(_linker.getModule(), Out.os());
158158 Out.os().close();
163163 Out.os().clear_error();
164164 return true;
165165 }
166
166
167167 Out.keep();
168168 return false;
169169 }
289289 if (Inits == 0) return;
290290
291291 for (unsigned i = 0, e = Inits->getNumOperands(); i != e; ++i)
292 if (GlobalValue *GV =
292 if (GlobalValue *GV =
293293 dyn_cast(Inits->getOperand(i)->stripPointerCasts()))
294294 UsedValues.insert(GV);
295295 }
302302 PassManager passes;
303303 passes.add(createVerifierPass());
304304
305 // mark which symbols can not be internalized
305 // mark which symbols can not be internalized
306306 MCContext Context(*_target->getMCAsmInfo(), *_target->getRegisterInfo(), NULL);
307307 Mangler mangler(Context, *_target->getTargetData());
308308 std::vector mustPreserveList;
311311 for (Module::iterator f = mergedModule->begin(),
312312 e = mergedModule->end(); f != e; ++f)
313313 applyRestriction(*f, mustPreserveList, asmUsed, mangler);
314 for (Module::global_iterator v = mergedModule->global_begin(),
314 for (Module::global_iterator v = mergedModule->global_begin(),
315315 e = mergedModule->global_end(); v != e; ++v)
316316 applyRestriction(*v, mustPreserveList, asmUsed, mangler);
317317 for (Module::alias_iterator a = mergedModule->alias_begin(),
346346
347347 // apply scope restrictions
348348 passes.run(*mergedModule);
349
349
350350 _scopeRestrictionsDone = true;
351351 }
352352
353353 /// Optimize merged modules using various IPO passes
354354 bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,
355355 std::string &errMsg) {
356 if ( this->determineTarget(errMsg) )
356 if ( this->determineTarget(errMsg) )
357357 return true;
358358
359 // mark which symbols can not be internalized
359 // mark which symbols can not be internalized
360360 this->applyScopeRestrictions();
361361
362362 Module* mergedModule = _linker.getModule();
363363
364364 // if options were requested, set them
365365 if ( !_codegenOptions.empty() )
366 cl::ParseCommandLineOptions(_codegenOptions.size(),
366 cl::ParseCommandLineOptions(_codegenOptions.size(),
367367 const_cast(&_codegenOptions[0]));
368368
369369 // Instantiate the pass manager to organize the passes.
374374
375375 // Add an appropriate TargetData instance for this module...
376376 passes.add(new TargetData(*_target->getTargetData()));
377
377
378378 PassManagerBuilder().populateLTOPassManager(passes, /*Internalize=*/ false,
379379 !DisableInline);
380380