[llvm] [llvm][ELF] Correctly set the .llvm.lto section type (PR #92820)
via llvm-commits
llvm-commits at lists.llvm.org
Mon May 20 13:59:26 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-x86
Author: Paul Kirth (ilovepi)
<details>
<summary>Changes</summary>
Support for the SHT_LLVM_LTO section type was added in
https://github.com/llvm/llvm-project/commit/a484e020d75d398049e1fcbeb0157d57011714b3,
but the `.llvm.lto` section type was never set. This patch sets the ELF
section type to SHT_LLVM_LTO for sections with a `.llvm.lto` prefix, which
should only be emitted when using FatLTO.
---
Full diff: https://github.com/llvm/llvm-project/pull/92820.diff
2 Files Affected:
- (modified) llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (+3)
- (modified) llvm/test/CodeGen/X86/fat-lto-section.ll (+1-1)
``````````diff
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 3e1897ce670a6..567e9443759f1 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -527,6 +527,9 @@ static unsigned getELFSectionType(StringRef Name, SectionKind K) {
if (K.isBSS() || K.isThreadBSS())
return ELF::SHT_NOBITS;
+ if(hasPrefix(Name, ".llvm.lto"))
+ return ELF::SHT_LLVM_LTO;
+
return ELF::SHT_PROGBITS;
}
diff --git a/llvm/test/CodeGen/X86/fat-lto-section.ll b/llvm/test/CodeGen/X86/fat-lto-section.ll
index 30c56229a0e2a..f3ca8436affb4 100644
--- a/llvm/test/CodeGen/X86/fat-lto-section.ll
+++ b/llvm/test/CodeGen/X86/fat-lto-section.ll
@@ -5,6 +5,6 @@
; RUN: | FileCheck %s --check-prefix=EXCLUDE
; EXCLUDE: Name Type {{.*}} ES Flg Lk Inf Al
-; EXCLUDE: .llvm.lto PROGBITS {{.*}} 00 E 0 0 1
+; EXCLUDE: .llvm.lto LLVM_LTO {{.*}} 00 E 0 0 1
@a = global i32 1
``````````
</details>
https://github.com/llvm/llvm-project/pull/92820
More information about the llvm-commits
mailing list