[WebAssembly] MC: Fix crash when -g specified.

At this point we don't output any debug sections or thier
relocations.

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

llvm-svn: 316240
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index 55e7c93..44f2ba6 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -437,10 +437,13 @@
   WasmRelocationEntry Rec(FixupOffset, SymA, C, Type, &FixupSection);
   DEBUG(dbgs() << "WasmReloc: " << Rec << "\n");
 
-  if (FixupSection.hasInstructions())
-    CodeRelocations.push_back(Rec);
-  else
+  if (FixupSection.isWasmData())
     DataRelocations.push_back(Rec);
+  else if (FixupSection.getKind().isText())
+    CodeRelocations.push_back(Rec);
+  else if (!FixupSection.getKind().isMetadata())
+    // TODO(sbc): Add support for debug sections.
+    llvm_unreachable("unexpected section type");
 }
 
 // Write X as an (unsigned) LEB value at offset Offset in Stream, padded
@@ -1060,7 +1063,8 @@
   // In the special .global_variables section, we've encoded global
   // variables used by the function. Translate them into the Globals
   // list.
-  MCSectionWasm *GlobalVars = Ctx.getWasmSection(".global_variables", wasm::WASM_SEC_DATA);
+  MCSectionWasm *GlobalVars =
+      Ctx.getWasmSection(".global_variables", SectionKind::getMetadata());
   if (!GlobalVars->getFragmentList().empty()) {
     if (GlobalVars->getFragmentList().size() != 1)
       report_fatal_error("only one .global_variables fragment supported");
@@ -1116,7 +1120,8 @@
 
   // In the special .stack_pointer section, we've encoded the stack pointer
   // index.
-  MCSectionWasm *StackPtr = Ctx.getWasmSection(".stack_pointer", wasm::WASM_SEC_DATA);
+  MCSectionWasm *StackPtr =
+      Ctx.getWasmSection(".stack_pointer", SectionKind::getMetadata());
   if (!StackPtr->getFragmentList().empty()) {
     if (StackPtr->getFragmentList().size() != 1)
       report_fatal_error("only one .stack_pointer fragment supported");
@@ -1135,7 +1140,7 @@
 
   for (MCSection &Sec : Asm) {
     auto &Section = static_cast<MCSectionWasm &>(Sec);
-    if (Section.getType() != wasm::WASM_SEC_DATA)
+    if (!Section.isWasmData())
       continue;
 
     DataSize = alignTo(DataSize, Section.getAlignment());