diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 13 | ||||
| -rw-r--r-- | llvm/test/MC/WebAssembly/custom-code-section.ll | 9 |
2 files changed, 21 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( diff --git a/llvm/test/MC/WebAssembly/custom-code-section.ll b/llvm/test/MC/WebAssembly/custom-code-section.ll new file mode 100644 index 00000000000..d528d426e5b --- /dev/null +++ b/llvm/test/MC/WebAssembly/custom-code-section.ll @@ -0,0 +1,9 @@ +; RUN: llc -mtriple wasm32-unknown-unknown-wasm -O2 -filetype=obj %s -o %t.o + +; Wasm silently ignores custom sections for code. +; We had a bug where this cause a crash + +define hidden void @call_indirect() section "some_section_name" { +entry: + ret void +} |

