Index: lib/MC/WasmObjectWriter.cpp =================================================================== --- lib/MC/WasmObjectWriter.cpp +++ lib/MC/WasmObjectWriter.cpp @@ -430,9 +430,10 @@ if (SymA && SymA->isVariable()) { const MCExpr *Expr = SymA->getVariableValue(); - const auto *Inner = cast(Expr); - if (Inner->getKind() == MCSymbolRefExpr::VK_WEAKREF) - llvm_unreachable("weakref used in reloc not yet implemented"); + if (const auto *Inner = dyn_cast(Expr)) { + if (Inner->getKind() == MCSymbolRefExpr::VK_WEAKREF) + llvm_unreachable("weakref used in reloc not yet implemented"); + } } // Put any constant offset in an addend. Offsets can be negative, and @@ -443,7 +444,6 @@ if (SymA) SymA->setUsedInReloc(); - assert(!IsPCRel); assert(SymA); unsigned Type = getRelocType(Target, Fixup); @@ -490,8 +490,9 @@ static const MCSymbolWasm* ResolveSymbol(const MCSymbolWasm& Symbol) { if (Symbol.isVariable()) { const MCExpr *Expr = Symbol.getVariableValue(); - auto *Inner = cast(Expr); - return cast(&Inner->getSymbol()); + if (auto *Inner = dyn_cast(Expr)) { + return cast(&Inner->getSymbol()); + } } return &Symbol; }