llvm.org GIT mirror llvm / d4ee392
Don't produce an empty llvm.compiler.used in LTO. LTO was always creating an empty llvm.compiler.used. With this patch we now first check if there is anything to be added first. Unfortunately, there is no good way to test libLTO in isolation as it needs gold or ld64, but there are bots doing LTO builds that found this problem. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180202 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
1 changed file(s) with 20 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
286286 SmallPtrSet &UsedValues) {
287287 if (LLVMUsed == 0) return;
288288
289 ConstantArray *Inits = dyn_cast(LLVMUsed->getInitializer());
290 if (Inits == 0) return;
291
289 ConstantArray *Inits = cast(LLVMUsed->getInitializer());
292290 for (unsigned i = 0, e = Inits->getNumOperands(); i != e; ++i)
293291 if (GlobalValue *GV =
294292 dyn_cast(Inits->getOperand(i)->stripPointerCasts()))
325323 if (LLVMCompilerUsed)
326324 LLVMCompilerUsed->eraseFromParent();
327325
328 llvm::Type *i8PTy = llvm::Type::getInt8PtrTy(_context);
329 std::vector asmUsed2;
330 for (SmallPtrSet::const_iterator i = asmUsed.begin(),
331 e = asmUsed.end(); i !=e; ++i) {
332 GlobalValue *GV = *i;
333 Constant *c = ConstantExpr::getBitCast(GV, i8PTy);
334 asmUsed2.push_back(c);
335 }
336
337 llvm::ArrayType *ATy = llvm::ArrayType::get(i8PTy, asmUsed2.size());
338 LLVMCompilerUsed =
339 new llvm::GlobalVariable(*mergedModule, ATy, false,
340 llvm::GlobalValue::AppendingLinkage,
341 llvm::ConstantArray::get(ATy, asmUsed2),
342 "llvm.compiler.used");
343
344 LLVMCompilerUsed->setSection("llvm.metadata");
326 if (!asmUsed.empty()) {
327 llvm::Type *i8PTy = llvm::Type::getInt8PtrTy(_context);
328 std::vector asmUsed2;
329 for (SmallPtrSet::const_iterator i = asmUsed.begin(),
330 e = asmUsed.end(); i !=e; ++i) {
331 GlobalValue *GV = *i;
332 Constant *c = ConstantExpr::getBitCast(GV, i8PTy);
333 asmUsed2.push_back(c);
334 }
335
336 llvm::ArrayType *ATy = llvm::ArrayType::get(i8PTy, asmUsed2.size());
337 LLVMCompilerUsed =
338 new llvm::GlobalVariable(*mergedModule, ATy, false,
339 llvm::GlobalValue::AppendingLinkage,
340 llvm::ConstantArray::get(ATy, asmUsed2),
341 "llvm.compiler.used");
342
343 LLVMCompilerUsed->setSection("llvm.metadata");
344 }
345345
346346 passes.add(createInternalizePass(mustPreserveList));
347347