Skip to content

[CodeGen] Assign SHT_LLVM_LTO to .llvm.lto section #92856

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

MaskRay
Copy link
Member

@MaskRay MaskRay commented May 21, 2024

This follows up to SHT_LLVM_LTO (https://reviews.llvm.org/D153215) and
resolves the comment of the FatLTO patch
https://reviews.llvm.org/D146776#4430626

Created using spr 1.3.5-bogner
@MaskRay MaskRay requested a review from ilovepi May 21, 2024 05:08
@llvmbot llvmbot added clang Clang issues not falling into any other category backend:X86 labels May 21, 2024
@llvmbot
Copy link
Member

llvmbot commented May 21, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-x86

Author: Fangrui Song (MaskRay)

Changes

This follows up to SHT_LLVM_LTO (https://reviews.llvm.org/D153215) and
resolves the comment of the FatLTO patch
https://reviews.llvm.org/D146776#4430626


Full diff: https://github.com/llvm/llvm-project/pull/92856.diff

3 Files Affected:

  • (modified) clang/test/CodeGen/fat-lto-objects.c (+1-1)
  • (modified) llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (+2)
  • (modified) llvm/test/CodeGen/X86/fat-lto-section.ll (+1-1)
diff --git a/clang/test/CodeGen/fat-lto-objects.c b/clang/test/CodeGen/fat-lto-objects.c
index b50567c024fc8..36a73684e7bfe 100644
--- a/clang/test/CodeGen/fat-lto-objects.c
+++ b/clang/test/CodeGen/fat-lto-objects.c
@@ -62,7 +62,7 @@
 
 // ELF: .llvm.lto
 
-//      ASM: .section        .llvm.lto,"e",@progbits
+//      ASM: .section        .llvm.lto,"e",@llvm_lto
 // ASM-NEXT: .Lllvm.embedded.object:
 // ASM-NEXT:        .asciz  "BC
 // ASM-NEXT: .size   .Lllvm.embedded.object
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 3e1897ce670a6..0fc915d89f6c0 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -523,6 +523,8 @@ static unsigned getELFSectionType(StringRef Name, SectionKind K) {
 
   if (hasPrefix(Name, ".llvm.offloading"))
     return ELF::SHT_LLVM_OFFLOADING;
+  if (Name == ".llvm.lto")
+    return ELF::SHT_LLVM_LTO;
 
   if (K.isBSS() || K.isThreadBSS())
     return ELF::SHT_NOBITS;
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

@MaskRay
Copy link
Member Author

MaskRay commented May 21, 2024

@ilovepi I just realized that the FatLTO LLVM patch did not incorporate https://reviews.llvm.org/D153215 . I thought it did... Hope this is not too late.

Copy link
Contributor

@ilovepi ilovepi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I had thought I added you in #92820, but you're still listed as "request". I saw your avatar and just assumed you were a reviewer. Also, I guess I missed the clang test, when I was checking locally, though.

We'll just go w/ your patch, since they're almost identical.

@MaskRay
Copy link
Member Author

MaskRay commented May 21, 2024

Oh, I didn't know #92820! Thanks. Landing...

@MaskRay MaskRay merged commit 446f66d into main May 21, 2024
@MaskRay MaskRay deleted the users/MaskRay/spr/codegen-assign-sht_llvm_lto-to-llvmlto-section branch May 21, 2024 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants