[PATCH] D42564: [WebAssembly] ignore non-SymbolRef MCExpr.
Patrick Cheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 26 00:02:33 PST 2018
patcheng created this revision.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, sbc100, dschuff, jfb.
instead of static casting a MCExpr to MCSymbolRefExpr directly, use dyn_cast and added null check.
Also removed an unnecessary (?) assertion
Repository:
rL LLVM
https://reviews.llvm.org/D42564
Files:
lib/MC/WasmObjectWriter.cpp
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<MCSymbolRefExpr>(Expr);
- if (Inner->getKind() == MCSymbolRefExpr::VK_WEAKREF)
- llvm_unreachable("weakref used in reloc not yet implemented");
+ if (const auto *Inner = dyn_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
@@ -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<MCSymbolRefExpr>(Expr);
- return cast<MCSymbolWasm>(&Inner->getSymbol());
+ if (auto *Inner = dyn_cast<MCSymbolRefExpr>(Expr)) {
+ return cast<MCSymbolWasm>(&Inner->getSymbol());
+ }
}
return &Symbol;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42564.131545.patch
Type: text/x-patch
Size: 1321 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180126/1e795755/attachment.bin>
More information about the llvm-commits
mailing list