[llvm-branch-commits] [lld] [lld] Discard SHT_LLVM_LTO sections in relocatable links (PR #92825)

Paul Kirth via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue May 21 10:40:38 PDT 2024


https://github.com/ilovepi updated https://github.com/llvm/llvm-project/pull/92825

>From 0b9155faf2dc063f81091c8e78d14dd4446c2db5 Mon Sep 17 00:00:00 2001
From: Paul Kirth <paulkirth at google.com>
Date: Tue, 21 May 2024 09:58:46 -0700
Subject: [PATCH] Fix fallthrough and update comment

Created using spr 1.3.4
---
 lld/ELF/InputFiles.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 0ac49761601c4..33fd86b269f81 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -833,14 +833,15 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats,
           createInputSection(i, sec, check(obj.getSectionName(sec, shstrtab)));
       break;
     case SHT_LLVM_LTO:
-      // When doing a relocatable link with FatLTO objects, if we're not using
-      // the bitcode, discard it, since it will be concatenated together when
-      // handling orphan sections, and which will be an invalid bitcode object.
+      // Discard .llvm.lto in a relocatable link that does not use the bitcode.
+      // The concatenated output does not properly reflect the linking
+      // semantics. In addition, since we do not use the bitcode wrapper format,
+      // the concatenated raw bitcode would be invalid.
       if (config->relocatable && !config->fatLTOObjects) {
         sections[i] = &InputSection::discarded;
         break;
       }
-      LLVM_FALLTHROUGH;
+      [[fallthrough]];
     default:
       this->sections[i] =
           createInputSection(i, sec, check(obj.getSectionName(sec, shstrtab)));



More information about the llvm-branch-commits mailing list