llvm.org GIT mirror llvm / 50f3183
Revert r169656. The linker will call `lto_codegen_add_must_preserve_symbol' on all globals that should be kept around. The linker will pretend that a dylib is being created. <rdar://problem/12528059> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169770 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 6 years ago
5 changed file(s) with 3 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
250250 int nargs);
251251
252252 /**
253 * If set, then codegen will export all symbols (e.g. the internalize
254 * pass won't run).
255 */
256 extern void
257 lto_codegen_set_export_dynamic(lto_code_gen_t cg, bool val);
258
259 /**
260253 * Adds to a list of all global symbols that must exist in the final
261254 * generated code. If a function is not listed, it might be
262255 * inlined into every usage and optimized away.
6565 : _context(getGlobalContext()),
6666 _linker("LinkTimeOptimizer", "ld-temp.o", _context), _target(NULL),
6767 _emitDwarfDebugInfo(false), _scopeRestrictionsDone(false),
68 _exportDynamic(false), _codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
68 _codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
6969 _nativeObjectFile(NULL) {
7070 InitializeAllTargets();
7171 InitializeAllTargetMCs();
338338
339339 LLVMCompilerUsed->setSection("llvm.metadata");
340340
341 if (!_exportDynamic)
342 passes.add(createInternalizePass(mustPreserveList));
341 passes.add(createInternalizePass(mustPreserveList));
343342
344343 // apply scope restrictions
345344 passes.run(*mergedModule);
378377 // keeps only main if it exists and does nothing for libraries. Instead
379378 // we create the pass ourselves with the symbol list provided by the linker.
380379 PassManagerBuilder().populateLTOPassManager(passes,
381 /*Internalize=*/
382 // FIXME: remove 'false' once
383 // Darwin linker can pass this
384 // option.
385 //
386 false /*!_exportDynamic*/,
380 /*Internalize=*/false,
387381 !DisableInline,
388382 DisableGVNLoadPRE);
389383
4343 bool setCodePICModel(lto_codegen_model, std::string &errMsg);
4444
4545 void setCpu(const char* mCpu) { _mCpu = mCpu; }
46 void setExportDynamic(bool V) { _exportDynamic = V; }
4746
4847 void addMustPreserveSymbol(const char* sym) {
4948 _mustPreserveSymbols[sym] = 1;
7069 llvm::TargetMachine* _target;
7170 bool _emitDwarfDebugInfo;
7271 bool _scopeRestrictionsDone;
73 bool _exportDynamic;
7472 lto_codegen_model _codeModel;
7573 StringSet _mustPreserveSymbols;
7674 StringSet _asmUndefinedRefs;
173173 // In here only for backwards compatibility. We use MC now.
174174 }
175175
176 /// lto_codegen_set_export_dynamic - If set, then codegen will export all
177 /// symbols (e.g. the internalize pass won't run).
178 void lto_codegen_set_export_dynamic(lto_code_gen_t cg, bool val) {
179 cg->setExportDynamic(val);
180 }
181
182176 /// lto_codegen_add_must_preserve_symbol - Adds to a list of all global symbols
183177 /// that must exist in the final generated code. If a function is not listed
184178 /// there, it might be inlined into every usage and optimized away.
2626 lto_codegen_set_assembler_args
2727 lto_codegen_set_assembler_path
2828 lto_codegen_set_cpu
29 lto_codegen_set_export_dynamic
3029 lto_codegen_compile_to_file
3130 LLVMCreateDisasm
3231 LLVMCreateDisasmCPU