mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-04 03:06:28 +00:00
[WebAssembly] Fix use of cast vs dyn_cast
Differential Revision: https://reviews.llvm.org/D35233 llvm-svn: 307612
This commit is contained in:
parent
4dac3f000e
commit
6b124e390a
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user