[WebAssembly] Ignore explicit section names for functions

WebAssembly doesn't support more than one function per section
and we rely on function sections being unique. This change ignores
the section provided by the function to avoid two functions being
in the same section.

Without this change the object writer produces the following
error for this test:
 LLVM ERROR: section already has a defining function: baz

Differential Revision: https://reviews.llvm.org/D48178

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@334752 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Sam Clegg
2018-06-14 18:48:19 +00:00
parent a1b4efd4bd
commit 10cde000da
2 changed files with 34 additions and 0 deletions
@@ -1408,6 +1408,12 @@ static SectionKind getWasmKindForNamedSection(StringRef Name, SectionKind K) {
MCSection *TargetLoweringObjectFileWasm::getExplicitSectionGlobal(
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
// We don't support explict section names for functions in the wasm object
// format. Each function has to be in its own unique section.
if (isa<Function>(GO)) {
return SelectSectionForGlobal(GO, Kind, TM);
}
StringRef Name = GO->getSection();
Kind = getWasmKindForNamedSection(Name, Kind);