llvm.org GIT mirror llvm / 775079c
Rename some variables to match the style guide. I am about to patch this code, and this makes the diff far more readable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189982 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 7 years ago
4 changed file(s) with 28 addition(s) and 28 deletion(s). Raw diff Collapse all Expand all
108108 ///
109109 /// Note that commandline options that are used with the above function are not
110110 /// used now!
111 ModulePass *createInternalizePass(ArrayRef exportList);
111 ModulePass *createInternalizePass(ArrayRef ExportList);
112112 /// createInternalizePass - Same as above, but with an empty exportList.
113113 ModulePass *createInternalizePass();
114114
4949 public:
5050 static char ID; // Pass identification, replacement for typeid
5151 explicit InternalizePass();
52 explicit InternalizePass(ArrayRef exportList);
52 explicit InternalizePass(ArrayRef ExportList);
5353 void LoadFile(const char *Filename);
5454 virtual bool runOnModule(Module &M);
5555
7272 ExternalNames.insert(APIList.begin(), APIList.end());
7373 }
7474
75 InternalizePass::InternalizePass(ArrayRef exportList)
75 InternalizePass::InternalizePass(ArrayRef ExportList)
7676 : ModulePass(ID){
7777 initializeInternalizePassPass(*PassRegistry::getPassRegistry());
78 for(ArrayRef::const_iterator itr = exportList.begin();
79 itr != exportList.end(); itr++) {
78 for(ArrayRef::const_iterator itr = ExportList.begin();
79 itr != ExportList.end(); itr++) {
8080 ExternalNames.insert(*itr);
8181 }
8282 }
209209 return new InternalizePass();
210210 }
211211
212 ModulePass *llvm::createInternalizePass(ArrayRef el) {
213 return new InternalizePass(el);
214 }
212 ModulePass *llvm::createInternalizePass(ArrayRef ExportList) {
213 return new InternalizePass(ExportList);
214 }
299299
300300 void LTOCodeGenerator::
301301 applyRestriction(GlobalValue &GV,
302 std::vector &mustPreserveList,
303 SmallPtrSet &asmUsed,
304 Mangler &mangler) {
302 std::vector &MustPreserveList,
303 SmallPtrSet &AsmUsed,
304 Mangler &Mangler) {
305305 SmallString<64> Buffer;
306 mangler.getNameWithPrefix(Buffer, &GV, false);
306 Mangler.getNameWithPrefix(Buffer, &GV, false);
307307
308308 if (GV.isDeclaration())
309309 return;
310310 if (MustPreserveSymbols.count(Buffer))
311 mustPreserveList.push_back(GV.getName().data());
311 MustPreserveList.push_back(GV.getName().data());
312312 if (AsmUndefinedRefs.count(Buffer))
313 asmUsed.insert(&GV);
313 AsmUsed.insert(&GV);
314314 }
315315
316316 static void findUsedValues(GlobalVariable *LLVMUsed,
336336 // mark which symbols can not be internalized
337337 MCContext MContext(TargetMach->getMCAsmInfo(), TargetMach->getRegisterInfo(),
338338 NULL);
339 Mangler mangler(MContext, TargetMach);
340 std::vector mustPreserveList;
341 SmallPtrSet asmUsed;
339 Mangler Mangler(MContext, TargetMach);
340 std::vector MustPreserveList;
341 SmallPtrSet AsmUsed;
342342
343343 for (Module::iterator f = mergedModule->begin(),
344344 e = mergedModule->end(); f != e; ++f)
345 applyRestriction(*f, mustPreserveList, asmUsed, mangler);
345 applyRestriction(*f, MustPreserveList, AsmUsed, Mangler);
346346 for (Module::global_iterator v = mergedModule->global_begin(),
347347 e = mergedModule->global_end(); v != e; ++v)
348 applyRestriction(*v, mustPreserveList, asmUsed, mangler);
348 applyRestriction(*v, MustPreserveList, AsmUsed, Mangler);
349349 for (Module::alias_iterator a = mergedModule->alias_begin(),
350350 e = mergedModule->alias_end(); a != e; ++a)
351 applyRestriction(*a, mustPreserveList, asmUsed, mangler);
351 applyRestriction(*a, MustPreserveList, AsmUsed, Mangler);
352352
353353 GlobalVariable *LLVMCompilerUsed =
354354 mergedModule->getGlobalVariable("llvm.compiler.used");
355 findUsedValues(LLVMCompilerUsed, asmUsed);
355 findUsedValues(LLVMCompilerUsed, AsmUsed);
356356 if (LLVMCompilerUsed)
357357 LLVMCompilerUsed->eraseFromParent();
358358
359 if (!asmUsed.empty()) {
359 if (!AsmUsed.empty()) {
360360 llvm::Type *i8PTy = llvm::Type::getInt8PtrTy(Context);
361361 std::vector asmUsed2;
362 for (SmallPtrSet::const_iterator i = asmUsed.begin(),
363 e = asmUsed.end(); i !=e; ++i) {
362 for (SmallPtrSet::const_iterator i = AsmUsed.begin(),
363 e = AsmUsed.end(); i !=e; ++i) {
364364 GlobalValue *GV = *i;
365365 Constant *c = ConstantExpr::getBitCast(GV, i8PTy);
366366 asmUsed2.push_back(c);
376376 LLVMCompilerUsed->setSection("llvm.metadata");
377377 }
378378
379 passes.add(createInternalizePass(mustPreserveList));
379 passes.add(createInternalizePass(MustPreserveList));
380380
381381 // apply scope restrictions
382382 passes.run(*mergedModule);
105105 bool generateObjectFile(llvm::raw_ostream &out, std::string &errMsg);
106106 void applyScopeRestrictions();
107107 void applyRestriction(llvm::GlobalValue &GV,
108 std::vector &mustPreserveList,
109 llvm::SmallPtrSet &asmUsed,
110 llvm::Mangler &mangler);
108 std::vector &MustPreserveList,
109 llvm::SmallPtrSet &AsmUsed,
110 llvm::Mangler &Mangler);
111111 bool determineTarget(std::string &errMsg);
112112
113113 typedef llvm::StringMap StringSet;