From 759631c77bb8f7a8b76e1c1a7cd78532a5d809d2 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 15 Sep 2017 20:54:59 +0000 Subject: [WebAssembly] MC: Create wasm data segments based on MCSections This means that we can honor -fdata-sections rather than always creating a segment for each symbol. It also allows for a followup change to add .init_array and friends. Differential Revision: https://reviews.llvm.org/D37876 llvm-svn: 313395 --- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp') diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index fcb20184116..0149c82a00e 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -1248,8 +1248,8 @@ static const Comdat *getWasmComdat(const GlobalValue *GV) { MCSection *TargetLoweringObjectFileWasm::getExplicitSectionGlobal( const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const { - llvm_unreachable("getExplicitSectionGlobal not yet implemented"); - return nullptr; + StringRef Name = GO->getSection(); + return getContext().getWasmSection(Name, wasm::WASM_SEC_DATA); } static MCSectionWasm *selectWasmSectionForGlobal( @@ -1262,10 +1262,12 @@ static MCSectionWasm *selectWasmSectionForGlobal( bool UniqueSectionNames = TM.getUniqueSectionNames(); SmallString<128> Name = getSectionPrefixForGlobal(Kind); + uint32_t Type = wasm::WASM_SEC_DATA; if (const auto *F = dyn_cast(GO)) { const auto &OptionalPrefix = F->getSectionPrefix(); if (OptionalPrefix) Name += *OptionalPrefix; + Type = wasm::WASM_SEC_CODE; } if (EmitUniqueSection && UniqueSectionNames) { @@ -1277,7 +1279,7 @@ static MCSectionWasm *selectWasmSectionForGlobal( UniqueID = *NextUniqueID; (*NextUniqueID)++; } - return Ctx.getWasmSection(Name, /*Type=*/0, Group, UniqueID); + return Ctx.getWasmSection(Name, Type, Group, UniqueID); } MCSection *TargetLoweringObjectFileWasm::SelectSectionForGlobal( -- cgit v1.2.3