[llvm] r307612 - [WebAssembly] Fix use of cast vs dyn_cast
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 10 19:21:57 PDT 2017
Author: sbc
Date: Mon Jul 10 19:21:57 2017
New Revision: 307612
URL: http://llvm.org/viewvc/llvm-project?rev=307612&view=rev
Log:
[WebAssembly] Fix use of cast vs dyn_cast
Differential Revision: https://reviews.llvm.org/D35233
Modified:
llvm/trunk/lib/MC/WasmObjectWriter.cpp
Modified: llvm/trunk/lib/MC/WasmObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WasmObjectWriter.cpp?rev=307612&r1=307611&r2=307612&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WasmObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WasmObjectWriter.cpp Mon Jul 10 19:21:57 2017
@@ -404,15 +404,11 @@ void WasmObjectWriter::recordRelocation(
const MCSymbolRefExpr *RefA = Target.getSymA();
const auto *SymA = RefA ? cast<MCSymbolWasm>(&RefA->getSymbol()) : nullptr;
- bool ViaWeakRef = false;
if (SymA && SymA->isVariable()) {
const MCExpr *Expr = SymA->getVariableValue();
- if (const auto *Inner = dyn_cast<MCSymbolRefExpr>(Expr)) {
- if (Inner->getKind() == MCSymbolRefExpr::VK_WEAKREF) {
- SymA = cast<MCSymbolWasm>(&Inner->getSymbol());
- ViaWeakRef = true;
- }
- }
+ const auto *Inner = cast<MCSymbolRefExpr>(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
@@ -420,12 +416,8 @@ void WasmObjectWriter::recordRelocation(
// be negative and don't wrap.
FixedValue = 0;
- if (SymA) {
- if (ViaWeakRef)
- llvm_unreachable("weakref used in reloc not yet implemented");
- else
- SymA->setUsedInReloc();
- }
+ if (SymA)
+ SymA->setUsedInReloc();
assert(!IsPCRel);
assert(SymA);
@@ -928,7 +920,7 @@ uint32_t WasmObjectWriter::registerFunct
WasmFunctionType F;
if (Symbol.isVariable()) {
const MCExpr *Expr = Symbol.getVariableValue();
- auto *Inner = dyn_cast<MCSymbolRefExpr>(Expr);
+ auto *Inner = cast<MCSymbolRefExpr>(Expr);
const auto *ResolvedSym = cast<MCSymbolWasm>(&Inner->getSymbol());
F.Returns = ResolvedSym->getReturns();
F.Params = ResolvedSym->getParams();
@@ -1246,7 +1238,7 @@ void WasmObjectWriter::writeObject(MCAss
const auto &WS = static_cast<const MCSymbolWasm &>(S);
// Find the target symbol of this weak alias and export that index
const MCExpr *Expr = WS.getVariableValue();
- auto *Inner = dyn_cast<MCSymbolRefExpr>(Expr);
+ auto *Inner = cast<MCSymbolRefExpr>(Expr);
const auto *ResolvedSym = cast<MCSymbolWasm>(&Inner->getSymbol());
DEBUG(dbgs() << WS.getName() << ": weak alias of '" << *ResolvedSym << "'\n");
assert(SymbolIndices.count(ResolvedSym) > 0);
More information about the llvm-commits
mailing list