summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2017-07-11 02:21:57 +0000
committerSam Clegg <sbc@chromium.org>2017-07-11 02:21:57 +0000
commit6ad8f190c8f19e119aebbc239ba600da5659db57 (patch)
tree2df98fd1d9b162023be893179f3406d5906ffaec /llvm/lib
parent60fe5792ae65c13078c92a347cc2d6ae0e11ebf6 (diff)
downloadbcm5719-llvm-6ad8f190c8f19e119aebbc239ba600da5659db57.tar.gz
bcm5719-llvm-6ad8f190c8f19e119aebbc239ba600da5659db57.zip
[WebAssembly] Fix use of cast vs dyn_cast
Differential Revision: https://reviews.llvm.org/D35233 llvm-svn: 307612
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/MC/WasmObjectWriter.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index a38d9339880..54c8d00ebc2 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -404,15 +404,11 @@ void WasmObjectWriter::recordRelocation(MCAssembler &Asm,
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(MCAssembler &Asm,
// 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::registerFunctionType(const MCSymbolWasm& Symbol) {
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(MCAssembler &Asm,
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);
OpenPOWER on IntegriCloud