- // Make sure our result is globally accessible...
- // by putting them in the used array
- {
- std::vector<Constant *> AUGs;
- const Type *SBP= PointerType::getUnqual(Type::Int8Ty);
- for (std::vector<GlobalValue*>::iterator GI = Named.begin(),
- GE = Named.end(); GI != GE; ++GI) {
- (*GI)->setLinkage(GlobalValue::ExternalLinkage);
- AUGs.push_back(ConstantExpr::getBitCast(*GI, SBP));
- }
- ArrayType *AT = ArrayType::get(SBP, AUGs.size());
- Constant *Init = ConstantArray::get(AT, AUGs);
- GlobalValue *gv = new GlobalVariable(AT, false,
- GlobalValue::AppendingLinkage,
- Init, "llvm.used", &M);
- gv->setSection("llvm.metadata");
- }
-
- // All of the functions may be used by global variables or the named
- // globals. Loop through them and create a new, external functions that
- // can be "used", instead of ones with bodies.
- std::vector<Function*> NewFunctions;