[PATCH] D43205: [WebAssembly] Fix casting MCSymbol to MCSymbolWasm on ELF

Jacob Gravelle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 12 12:12:05 PST 2018


jgravelle-google created this revision.
jgravelle-google added reviewers: dschuff, sunfish.
Herald added subscribers: aheejin, sbc100, jfb.

wasm32-unknown-unknown-elf has MCSymbols that are not MCSymbolWasms, so
we need a non-asserting cast here.


Repository:
  rL LLVM

https://reviews.llvm.org/D43205

Files:
  lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp


Index: lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
===================================================================
--- lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
+++ lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
@@ -84,13 +84,14 @@
       SmallVector<MVT, 4> Results;
       SmallVector<MVT, 4> Params;
       ComputeSignatureVTs(F, TM, Params, Results);
-      MCSymbolWasm *Sym = cast<MCSymbolWasm>(getSymbol(&F));
+      MCSymbol *Sym = getSymbol(&F);
       getTargetStreamer()->emitIndirectFunctionType(Sym, Params, Results);
 
-      if (F.hasFnAttribute("wasm-import-module")) {
+      MCSymbolWasm *WasmSym = dyn_cast<MCSymbolWasm>(Sym);
+      if (WasmSym && F.hasFnAttribute("wasm-import-module")) {
         StringRef Name = F.getFnAttribute("wasm-import-module")
                              .getValueAsString();
-        getTargetStreamer()->emitImportModule(Sym, Name);
+        getTargetStreamer()->emitImportModule(WasmSym, Name);
       }
     }
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43205.133913.patch
Type: text/x-patch
Size: 987 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180212/2cfe8376/attachment.bin>


More information about the llvm-commits mailing list