Skip to content

Commit

Permalink
Revert "[gold] Add preliminary FatLTO support to the Gold plugin"
Browse files Browse the repository at this point in the history
This reverts commit 421e402.

One of the test needs a requires line, but we've also seen some issues
for downstream projects that may need coordination, so I'm reverting
this for until we can address those issues. see
https://reviews.llvm.org/D152973#4520240 for context.
  • Loading branch information
ilovepi committed Jul 20, 2023
1 parent eb3f2fe commit 2f34288
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 152 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Object/ObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ uint32_t ObjectFile::getSymbolAlignment(DataRefImpl DRI) const { return 0; }
bool ObjectFile::isSectionBitcode(DataRefImpl Sec) const {
Expected<StringRef> NameOrErr = getSectionName(Sec);
if (NameOrErr)
return *NameOrErr == ".llvm.lto";
return *NameOrErr == ".llvmbc" || *NameOrErr == ".llvm.lto";
consumeError(NameOrErr.takeError());
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/LTO/X86/Inputs/bcsection.macho.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
.asciz "Wrong Section"

.section __LLVM,__bitcode
.incbin "llvm.lto.section.bc"
.incbin "bcsection.bc"
2 changes: 0 additions & 2 deletions llvm/test/LTO/X86/Inputs/llvm.lto.section.s

This file was deleted.

18 changes: 12 additions & 6 deletions llvm/test/LTO/X86/bcsection.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@
; RUN: llvm-as -o %t/bcsection.bc %s

; RUN: llvm-mc -I=%t -filetype=obj -triple=x86_64-pc-win32 -o %t/bcsection.coff.bco %p/Inputs/bcsection.s
; RUN: llvm-nm %t/bcsection.coff.bco | FileCheck %s --allow-empty
; RUN: not llvm-lto -exported-symbol=main -exported-symbol=_main -o %t/bcsection.coff.o %t/bcsection.coff.bco
; RUN: llvm-nm %t/bcsection.coff.bco | FileCheck %s
; RUN: llvm-lto -exported-symbol=main -exported-symbol=_main -o %t/bcsection.coff.o %t/bcsection.coff.bco
; RUN: llvm-nm %t/bcsection.coff.o | FileCheck %s

; RUN: llvm-mc -I=%t -filetype=obj -triple=x86_64-unknown-linux-gnu -o %t/bcsection.elf.bco %p/Inputs/bcsection.s
; RUN: llvm-nm %t/bcsection.elf.bco | FileCheck %s --allow-empty
; RUN: not llvm-lto -exported-symbol=main -exported-symbol=_main -o %t/bcsection.elf.o %t/bcsection.elf.bco
; RUN: llvm-nm %t/bcsection.elf.bco | FileCheck %s
; RUN: llvm-lto -exported-symbol=main -exported-symbol=_main -o %t/bcsection.elf.o %t/bcsection.elf.bco
; RUN: llvm-nm %t/bcsection.elf.o | FileCheck %s

; RUN: llvm-mc -I=%t -filetype=obj -triple=x86_64-apple-darwin11 -o %t/bcsection.macho.bco %p/Inputs/bcsection.macho.s
; RUN: llvm-nm %t/bcsection.macho.bco | FileCheck %s
; RUN: llvm-lto -exported-symbol=main -exported-symbol=_main -o %t/bcsection.macho.o %t/bcsection.macho.bco
; RUN: llvm-nm %t/bcsection.macho.o | FileCheck %s

target triple = "x86_64-unknown-linux-gnu"

;; The .llvmbc section is not intended for use with LTO, so there should be nothing here
; CHECK-NOT: main
; CHECK: main
define i32 @main() {
ret i32 0
}
25 changes: 0 additions & 25 deletions llvm/test/LTO/X86/llvm.lto.section.ll

This file was deleted.

9 changes: 0 additions & 9 deletions llvm/test/tools/gold/X86/fatlto/fatlto.invalid.s

This file was deleted.

108 changes: 0 additions & 108 deletions llvm/test/tools/gold/X86/fatlto/fatlto.test

This file was deleted.

8 changes: 8 additions & 0 deletions llvm/tools/gold/gold-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,14 @@ static ld_plugin_status claim_file_hook(const ld_plugin_input_file *file,
BufferRef = Buffer->getMemBufferRef();
}

// Only use bitcode files for LTO. InputFile::create() will load bitcode
// from the .llvmbc section within a binary object, this bitcode is typically
// generated by -fembed-bitcode and is not to be used by LLVMgold.so for LTO.
if (identify_magic(BufferRef.getBuffer()) != file_magic::bitcode) {
*claimed = 0;
return LDPS_OK;
}

*claimed = 1;

Expected<std::unique_ptr<InputFile>> ObjOrErr = InputFile::create(BufferRef);
Expand Down

0 comments on commit 2f34288

Please sign in to comment.