Skip to content

Commit 9179322

Browse files
authored
Revert "[llvm][EmbedBitcodePass] Prevent modifying the module with ThinLTO" (#145987)
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.
1 parent d829636 commit 9179322

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

llvm/lib/Transforms/IPO/EmbedBitcodePass.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "llvm/Support/raw_ostream.h"
1717
#include "llvm/TargetParser/Triple.h"
1818
#include "llvm/Transforms/IPO/ThinLTOBitcodeWriter.h"
19-
#include "llvm/Transforms/Utils/Cloning.h"
2019
#include "llvm/Transforms/Utils/ModuleUtils.h"
2120

2221
#include <string>
@@ -34,11 +33,8 @@ PreservedAnalyses EmbedBitcodePass::run(Module &M, ModuleAnalysisManager &AM) {
3433

3534
std::string Data;
3635
raw_string_ostream OS(Data);
37-
// Clone the module with Thin LTO, since ThinLTOBitcodeWriterPass changes
38-
// vtable linkage that would break the non-lto object code for FatLTO.
3936
if (IsThinLTO)
40-
ThinLTOBitcodeWriterPass(OS, /*ThinLinkOS=*/nullptr)
41-
.run(*llvm::CloneModule(M), AM);
37+
ThinLTOBitcodeWriterPass(OS, /*ThinLinkOS=*/nullptr).run(M, AM);
4238
else
4339
BitcodeWriterPass(OS, /*ShouldPreserveUseListOrder=*/false, EmitLTOSummary)
4440
.run(M, AM);

llvm/test/Transforms/EmbedBitcode/embed-wpd.ll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
; RUN: opt --mtriple x86_64-unknown-linux-gnu < %s -passes="embed-bitcode<thinlto>" -S | FileCheck %s
22

3-
; CHECK: $_ZTV3Foo = comdat any
3+
; CHECK-NOT: $_ZTV3Foo = comdat any
44
$_ZTV3Foo = comdat any
55

66
$_ZTI3Foo = comdat any
77

8-
;; ThinLTOBitcodeWriter will remove the vtable for Foo, and make it an external symbol
9-
; 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
10-
; CHECK-NOT: @foo = external unnamed_addr constant { [5 x ptr] }, align 8
8+
; CHECK: @_ZTV3Foo = external hidden unnamed_addr constant { [5 x ptr] }, align 8
9+
; 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
1110
; CHECK: @llvm.embedded.object = private constant {{.*}}, section ".llvm.lto", align 1
1211
; CHECK: @llvm.compiler.used = appending global [1 x ptr] [ptr @llvm.embedded.object], section "llvm.metadata"
1312
@_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

0 commit comments

Comments
 (0)