diff options
author | Sam Clegg <sbc@chromium.org> | 2017-12-07 02:55:51 +0000 |
---|---|---|
committer | Sam Clegg <sbc@chromium.org> | 2017-12-07 02:55:51 +0000 |
commit | e1694f9bf88dad94fa7b52de2bbad609d6cb37c7 (patch) | |
tree | 8773db63802bfc005b5f6e9088bcea6aa3baf087 /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | |
parent | 74fe0ba10577c2d72ff99290f92151e5e062c112 (diff) | |
download | bcm5719-llvm-e1694f9bf88dad94fa7b52de2bbad609d6cb37c7.tar.gz bcm5719-llvm-e1694f9bf88dad94fa7b52de2bbad609d6cb37c7.zip |
[WebAssembly] section kind can be code
Currently, when creating a named section, the Wasm
frontend forces it to use `SectionKind::Data`, whereas
in fact C++ does generate code sections with custom
names.
Patch by Nicholas Wilson
Differential Revision: https://reviews.llvm.org/D40906
llvm-svn: 320002
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 910ca4682b9..925e67b01f6 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -1265,11 +1265,22 @@ static void checkWasmComdat(const GlobalValue *GV) { "' cannot be lowered."); } +static SectionKind getWasmKindForNamedSection(StringRef Name, SectionKind K) { + // If we're told we have function data, then use that. + if (K.isText()) + return SectionKind::getText(); + + // Otherwise, ignore whatever section type the generic impl detected and use + // a plain data section. + return SectionKind::getData(); +} + MCSection *TargetLoweringObjectFileWasm::getExplicitSectionGlobal( const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const { StringRef Name = GO->getSection(); checkWasmComdat(GO); - return getContext().getWasmSection(Name, SectionKind::getData()); + Kind = getWasmKindForNamedSection(Name, Kind); + return getContext().getWasmSection(Name, Kind); } static MCSectionWasm *selectWasmSectionForGlobal( |