-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Revert "[llvm][EmbedBitcodePass] Prevent modifying the module with ThinLTO" #145987
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
Conversation
…inLTO (#…" This reverts commit 55c7d5c.
@llvm/pr-subscribers-llvm-transforms Author: Paul Kirth (ilovepi) ChangesReverts llvm/llvm-project#139999 This has a reported crash in #139999 (comment) This PR was intended to fix an error when linking, which is unfortunately preferable to crashing clang. For now, we'll revert and investigate the problem. Full diff: https://github.com/llvm/llvm-project/pull/145987.diff 2 Files Affected:
diff --git a/llvm/lib/Transforms/IPO/EmbedBitcodePass.cpp b/llvm/lib/Transforms/IPO/EmbedBitcodePass.cpp
index 5e8b2a4e3d842..73f567734a91b 100644
--- a/llvm/lib/Transforms/IPO/EmbedBitcodePass.cpp
+++ b/llvm/lib/Transforms/IPO/EmbedBitcodePass.cpp
@@ -16,7 +16,6 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
-#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
#include <string>
@@ -34,11 +33,8 @@ PreservedAnalyses EmbedBitcodePass::run(Module &M, ModuleAnalysisManager &AM) {
std::string Data;
raw_string_ostream OS(Data);
- // Clone the module with Thin LTO, since ThinLTOBitcodeWriterPass changes
- // vtable linkage that would break the non-lto object code for FatLTO.
if (IsThinLTO)
- ThinLTOBitcodeWriterPass(OS, /*ThinLinkOS=*/nullptr)
- .run(*llvm::CloneModule(M), AM);
+ ThinLTOBitcodeWriterPass(OS, /*ThinLinkOS=*/nullptr).run(M, AM);
else
BitcodeWriterPass(OS, /*ShouldPreserveUseListOrder=*/false, EmitLTOSummary)
.run(M, AM);
diff --git a/llvm/test/Transforms/EmbedBitcode/embed-wpd.ll b/llvm/test/Transforms/EmbedBitcode/embed-wpd.ll
index 54931be42b4eb..f1f7712f54039 100644
--- a/llvm/test/Transforms/EmbedBitcode/embed-wpd.ll
+++ b/llvm/test/Transforms/EmbedBitcode/embed-wpd.ll
@@ -1,13 +1,12 @@
; RUN: opt --mtriple x86_64-unknown-linux-gnu < %s -passes="embed-bitcode<thinlto>" -S | FileCheck %s
-; CHECK: $_ZTV3Foo = comdat any
+; CHECK-NOT: $_ZTV3Foo = comdat any
$_ZTV3Foo = comdat any
$_ZTI3Foo = comdat any
-;; ThinLTOBitcodeWriter will remove the vtable for Foo, and make it an external symbol
-; CHECK: @_ZTV3Foo = linkonce_odr hidden unnamed_addr constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTI3Foo, ptr @_ZN3FooD2Ev, ptr @_ZN3FooD0Ev, ptr @_ZNKSt13runtime_error4whatEv] }, comdat, align 8, !type !0, !type !1, !type !2, !type !3, !type !4, !type !5
-; CHECK-NOT: @foo = external unnamed_addr constant { [5 x ptr] }, align 8
+; CHECK: @_ZTV3Foo = external hidden unnamed_addr constant { [5 x ptr] }, align 8
+; CHECK: @_ZTI3Foo = linkonce_odr hidden constant { ptr, ptr, ptr } { ptr getelementptr inbounds (ptr, ptr @_ZTVN10__cxxabiv120__si_class_type_infoE, i64 2), ptr @_ZTS3Foo, ptr @_ZTISt13runtime_error }, comdat, align 8
; CHECK: @llvm.embedded.object = private constant {{.*}}, section ".llvm.lto", align 1
; CHECK: @llvm.compiler.used = appending global [1 x ptr] [ptr @llvm.embedded.object], section "llvm.metadata"
@_ZTV3Foo = linkonce_odr hidden unnamed_addr constant { [5 x ptr] } { [5 x ptr] [ptr null, ptr @_ZTI3Foo, ptr @_ZN3FooD2Ev, ptr @_ZN3FooD0Ev, ptr @_ZNKSt13runtime_error4whatEv] }, comdat, align 8, !type !0, !type !1, !type !2, !type !3, !type !4, !type !5
|
We have a related report here as well https://fxbug.dev/428031906 |
Expensive checks complains when we mark them as preserved. The bitcode being embedded generally doesn't change anything important in the module, but some things are modified under ThinLTO, like vtables under WPD. This became a non-issue when we cloned the module, but after we had to revert that in #145987, we need to handle this case properly.
Expensive checks complains when we mark them as preserved. The bitcode being embedded generally doesn't change anything important in the module, but some things are modified under ThinLTO, like vtables under WPD. This became a non-issue when we cloned the module, but after we had to revert that in #145987, we need to handle this case properly.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/16/builds/21604 Here is the relevant piece of the build log for the reference
|
…inLTO" (llvm#145987) Reverts llvm#139999 This has a reported crash in llvm#139999 (comment) This PR was intended to fix an error when linking, which is unfortunately preferable to crashing clang. For now, we'll revert and investigate the problem.
…46118) Expensive checks complains when we mark them as preserved. The bitcode being embedded generally doesn't change anything important in the module, but some things are modified under ThinLTO, like vtables under WPD. This became a non-issue when we cloned the module, but after we had to revert that in llvm#145987, we need to handle this case properly.
Reverts #139999
This has a reported crash in #139999 (comment)
This PR was intended to fix an error when linking, which is unfortunately preferable to crashing clang. For now, we'll revert and investigate the problem.