[PATCH] D39873: [WebAssembly] Explicily disable comdat support for wasm output
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 13 16:49:34 PST 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318123: [WebAssembly] Explicily disable comdat support for wasm output (authored by sbc).
Changed prior to commit:
https://reviews.llvm.org/D39873?vs=122344&id=122749#toc
Repository:
rL LLVM
https://reviews.llvm.org/D39873
Files:
llvm/trunk/include/llvm/ADT/Triple.h
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/trunk/test/CodeGen/WebAssembly/comdat.ll
Index: llvm/trunk/include/llvm/ADT/Triple.h
===================================================================
--- llvm/trunk/include/llvm/ADT/Triple.h
+++ llvm/trunk/include/llvm/ADT/Triple.h
@@ -661,7 +661,9 @@
}
/// Tests wether the target supports comdat
- bool supportsCOMDAT() const { return !isOSBinFormatMachO(); }
+ bool supportsCOMDAT() const {
+ return !isOSBinFormatMachO() && !isOSBinFormatWasm();
+ }
/// @}
/// @name Mutators
Index: llvm/trunk/test/CodeGen/WebAssembly/comdat.ll
===================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/comdat.ll
+++ llvm/trunk/test/CodeGen/WebAssembly/comdat.ll
@@ -0,0 +1,5 @@
+; RUN: not llc -mtriple wasm32-unknown-unknown-wasm %s 2>&1 | FileCheck %s
+
+$f = comdat any
+ at f = global i32 0, comdat
+; CHECK: LLVM ERROR: WebAssembly doesn't support COMDATs, 'f' cannot be lowered.
Index: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
===================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -1825,10 +1825,10 @@
auto *GO = dyn_cast<GlobalObject>(V);
if (GO) {
if (GO->getComdat() == reinterpret_cast<Comdat *>(1)) {
- if (TT.isOSBinFormatMachO())
- GO->setComdat(nullptr);
- else
+ if (TT.supportsCOMDAT())
GO->setComdat(TheModule->getOrInsertComdat(V->getName()));
+ else
+ GO->setComdat(nullptr);
}
}
return V;
Index: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -1233,30 +1233,29 @@
// Wasm
//===----------------------------------------------------------------------===//
-static const Comdat *getWasmComdat(const GlobalValue *GV) {
+static void checkWasmComdat(const GlobalValue *GV) {
const Comdat *C = GV->getComdat();
if (!C)
- return nullptr;
-
- if (C->getSelectionKind() != Comdat::Any)
- report_fatal_error("Wasm COMDATs only support SelectionKind::Any, '" +
- C->getName() + "' cannot be lowered.");
+ return;
- return C;
+ // TODO(sbc): At some point we may need COMDAT support but currently
+ // they are not supported.
+ report_fatal_error("WebAssembly doesn't support COMDATs, '" + C->getName() +
+ "' cannot be lowered.");
}
MCSection *TargetLoweringObjectFileWasm::getExplicitSectionGlobal(
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
StringRef Name = GO->getSection();
+ checkWasmComdat(GO);
return getContext().getWasmSection(Name, SectionKind::getData());
}
static MCSectionWasm *selectWasmSectionForGlobal(
MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang,
const TargetMachine &TM, bool EmitUniqueSection, unsigned *NextUniqueID) {
StringRef Group = "";
- if (getWasmComdat(GO))
- llvm_unreachable("comdat not yet supported for wasm");
+ checkWasmComdat(GO);
bool UniqueSectionNames = TM.getUniqueSectionNames();
SmallString<128> Name = getSectionPrefixForGlobal(Kind);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39873.122749.patch
Type: text/x-patch
Size: 3304 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171114/d164ab5a/attachment.bin>
More information about the llvm-commits
mailing list