Skip to content

Commit ebf8576

Browse files
committed
Collect bitcode libfuncs
1 parent 148a1a7 commit ebf8576

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

lld/ELF/Driver.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2709,7 +2709,19 @@ void LinkerDriver::compileBitcodeFiles(bool skipLinkedOutput) {
27092709
if (!ctx.bitcodeFiles.empty())
27102710
markBuffersAsDontNeed(ctx, skipLinkedOutput);
27112711

2712-
ltoObjectFiles = lto->compile();
2712+
llvm::Triple tt(ctx.bitcodeFiles.front()->obj->getTargetTriple());
2713+
llvm::BumpPtrAllocator alloc;
2714+
llvm::StringSaver saver(alloc);
2715+
SmallVector<const char *> bitcodeLibFuncs;
2716+
for (const char *libFunc : lto::LTO::getLibFuncSymbols(tt, saver)) {
2717+
Symbol *sym = ctx.symtab->find(libFunc);
2718+
if (!sym)
2719+
continue;
2720+
if (isa<BitcodeFile>(sym->file))
2721+
bitcodeLibFuncs.push_back(libFunc);
2722+
}
2723+
2724+
ltoObjectFiles = lto->compile(bitcodeLibFuncs);
27132725
for (auto &file : ltoObjectFiles) {
27142726
auto *obj = cast<ObjFile<ELFT>>(file.get());
27152727
obj->parse(/*ignoreComdats=*/true);

lld/ELF/LTO.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ void BitcodeCompiler::add(BitcodeFile &f) {
235235
const lto::InputFile::Symbol &objSym = objSyms[i];
236236
lto::SymbolResolution &r = resols[i];
237237

238+
dbgs() << sym->
239+
238240
// Ideally we shouldn't check for SF_Undefined but currently IRObjectFile
239241
// reports two symbols for module ASM defined. Without this check, lld
240242
// flags an undefined in IR with a definition in ASM as prevailing.
@@ -311,7 +313,8 @@ static void thinLTOCreateEmptyIndexFiles(Ctx &ctx) {
311313

312314
// Merge all the bitcode files we have seen, codegen the result
313315
// and return the resulting ObjectFile(s).
314-
SmallVector<std::unique_ptr<InputFile>, 0> BitcodeCompiler::compile() {
316+
SmallVector<std::unique_ptr<InputFile>, 0>
317+
BitcodeCompiler::compile(const SmallVector<const char *> &bitcodeLibfuncs) {
315318
unsigned maxTasks = ltoObj->getMaxTasks();
316319
buf.resize(maxTasks);
317320
files.resize(maxTasks);

lld/ELF/LTO.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class BitcodeCompiler {
4242
~BitcodeCompiler();
4343

4444
void add(BitcodeFile &f);
45-
SmallVector<std::unique_ptr<InputFile>, 0> compile();
45+
SmallVector<std::unique_ptr<InputFile>, 0>
46+
compile(const SmallVector<const char *> &bitcodeLibfuncs);
4647

4748
private:
4849
Ctx &ctx;

0 commit comments

Comments
 (0)