[PATCH] D35233: [WebAssembly] Fix use of cast vs dyn_cast
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 10 19:22:22 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL307612: [WebAssembly] Fix use of cast vs dyn_cast (authored by sbc).
Repository:
rL LLVM
https://reviews.llvm.org/D35233
Files:
llvm/trunk/lib/MC/WasmObjectWriter.cpp
Index: llvm/trunk/lib/MC/WasmObjectWriter.cpp
===================================================================
--- llvm/trunk/lib/MC/WasmObjectWriter.cpp
+++ llvm/trunk/lib/MC/WasmObjectWriter.cpp
@@ -404,28 +404,20 @@
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
// LLVM expects wrapping, in contrast to wasm's immediates which can't
// 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 @@
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 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35233.105959.patch
Type: text/x-patch
Size: 2217 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170711/17231cc7/attachment.bin>
More information about the llvm-commits
mailing list