[PATCH] D48178: [WebAssembly] Ignore explict section names for functions

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 14 11:52:52 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL334752: [WebAssembly] Ignore explicit section names for functions (authored by sbc, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D48178

Files:
  llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/trunk/test/MC/WebAssembly/function-sections.ll


Index: llvm/trunk/test/MC/WebAssembly/function-sections.ll
===================================================================
--- llvm/trunk/test/MC/WebAssembly/function-sections.ll
+++ llvm/trunk/test/MC/WebAssembly/function-sections.ll
@@ -0,0 +1,28 @@
+; RUN: llc -filetype=obj %s -o - | obj2yaml | FileCheck %s
+
+target triple = "wasm32-unknown-unknown"
+
+define hidden i32 @foo() section "baz" {
+entry:
+  ret i32 2
+}
+
+define hidden i32 @bar() section "baz" {
+entry:
+  ret i32 1
+}
+
+; CHECK:        - Type:            CUSTOM
+; CHECK-NEXT:     Name:            linking
+; CHECK-NEXT:     Version:         1
+; CHECK-NEXT:     SymbolTable:     
+; CHECK-NEXT:       - Index:           0
+; CHECK-NEXT:         Kind:            FUNCTION
+; CHECK-NEXT:         Name:            foo
+; CHECK-NEXT:         Flags:           [ VISIBILITY_HIDDEN ]
+; CHECK-NEXT:         Function:        0
+; CHECK-NEXT:       - Index:           1
+; CHECK-NEXT:         Kind:            FUNCTION
+; CHECK-NEXT:         Name:            bar
+; CHECK-NEXT:         Flags:           [ VISIBILITY_HIDDEN ]
+; CHECK-NEXT:         Function:        1
Index: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -1408,6 +1408,12 @@
 
 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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48178.151393.patch
Type: text/x-patch
Size: 1881 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180614/dab2bed3/attachment.bin>


More information about the llvm-commits mailing list