llvm.org GIT mirror llvm / 336b488
[WebAssembly] Explicily disable comdat support for wasm output For now at least. We clearly need some kind of comdat or linkonce_odr support for wasm but currently COMDAT is not supported. Disable COMDAT support in the same way we do the Mach-O. This also causes clang not to generated COMDATs. Differential Revision: https://reviews.llvm.org/D39873 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318123 91177308-0d34-0410-b5e6-96231b3b80d8 Sam Clegg 2 years ago
4 changed file(s) with 20 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
660660 }
661661
662662 /// Tests wether the target supports comdat
663 bool supportsCOMDAT() const { return !isOSBinFormatMachO(); }
663 bool supportsCOMDAT() const {
664 return !isOSBinFormatMachO() && !isOSBinFormatWasm();
665 }
664666
665667 /// @}
666668 /// @name Mutators
18241824 auto *GO = dyn_cast(V);
18251825 if (GO) {
18261826 if (GO->getComdat() == reinterpret_cast(1)) {
1827 if (TT.isOSBinFormatMachO())
1827 if (TT.supportsCOMDAT())
1828 GO->setComdat(TheModule->getOrInsertComdat(V->getName()));
1829 else
18281830 GO->setComdat(nullptr);
1829 else
1830 GO->setComdat(TheModule->getOrInsertComdat(V->getName()));
18311831 }
18321832 }
18331833 return V;
12321232 // Wasm
12331233 //===----------------------------------------------------------------------===//
12341234
1235 static const Comdat *getWasmComdat(const GlobalValue *GV) {
1235 static void checkWasmComdat(const GlobalValue *GV) {
12361236 const Comdat *C = GV->getComdat();
12371237 if (!C)
1238 return nullptr;
1239
1240 if (C->getSelectionKind() != Comdat::Any)
1241 report_fatal_error("Wasm COMDATs only support SelectionKind::Any, '" +
1242 C->getName() + "' cannot be lowered.");
1243
1244 return C;
1238 return;
1239
1240 // TODO(sbc): At some point we may need COMDAT support but currently
1241 // they are not supported.
1242 report_fatal_error("WebAssembly doesn't support COMDATs, '" + C->getName() +
1243 "' cannot be lowered.");
12451244 }
12461245
12471246 MCSection *TargetLoweringObjectFileWasm::getExplicitSectionGlobal(
12481247 const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
12491248 StringRef Name = GO->getSection();
1249 checkWasmComdat(GO);
12501250 return getContext().getWasmSection(Name, SectionKind::getData());
12511251 }
12521252
12541254 MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang,
12551255 const TargetMachine &TM, bool EmitUniqueSection, unsigned *NextUniqueID) {
12561256 StringRef Group = "";
1257 if (getWasmComdat(GO))
1258 llvm_unreachable("comdat not yet supported for wasm");
1257 checkWasmComdat(GO);
12591258
12601259 bool UniqueSectionNames = TM.getUniqueSectionNames();
12611260 SmallString<128> Name = getSectionPrefixForGlobal(Kind);
0 ; RUN: not llc -mtriple wasm32-unknown-unknown-wasm %s 2>&1 | FileCheck %s
1
2 $f = comdat any
3 @f = global i32 0, comdat
4 ; CHECK: LLVM ERROR: WebAssembly doesn't support COMDATs, 'f' cannot be lowered.