[llvm] r354694 - [WebAssembly] MC: Handle aliases of aliases
Sam Clegg via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 22 13:41:42 PST 2019
Author: sbc
Date: Fri Feb 22 13:41:42 2019
New Revision: 354694
URL: http://llvm.org/viewvc/llvm-project?rev=354694&view=rev
Log:
[WebAssembly] MC: Handle aliases of aliases
Differential Revision: https://reviews.llvm.org/D58417
Modified:
llvm/trunk/lib/MC/WasmObjectWriter.cpp
llvm/trunk/test/MC/WebAssembly/function-alias.ll
Modified: llvm/trunk/lib/MC/WasmObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WasmObjectWriter.cpp?rev=354694&r1=354693&r2=354694&view=diff
==============================================================================
--- llvm/trunk/lib/MC/WasmObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/WasmObjectWriter.cpp Fri Feb 22 13:41:42 2019
@@ -558,12 +558,13 @@ void WasmObjectWriter::recordRelocation(
}
static const MCSymbolWasm *resolveSymbol(const MCSymbolWasm &Symbol) {
- if (Symbol.isVariable()) {
- const MCExpr *Expr = Symbol.getVariableValue();
+ const MCSymbolWasm* Ret = &Symbol;
+ while (Ret->isVariable()) {
+ const MCExpr *Expr = Ret->getVariableValue();
auto *Inner = cast<MCSymbolRefExpr>(Expr);
- return cast<MCSymbolWasm>(&Inner->getSymbol());
+ Ret = cast<MCSymbolWasm>(&Inner->getSymbol());
}
- return &Symbol;
+ return Ret;
}
// Compute a value to write into the code at the location covered
@@ -1422,12 +1423,12 @@ uint64_t WasmObjectWriter::writeObject(M
LLVM_DEBUG(dbgs() << WS.getName() << ": weak alias of '" << *ResolvedSym
<< "'\n");
- if (WS.isFunction()) {
+ if (ResolvedSym->isFunction()) {
assert(WasmIndices.count(ResolvedSym) > 0);
uint32_t WasmIndex = WasmIndices.find(ResolvedSym)->second;
WasmIndices[&WS] = WasmIndex;
LLVM_DEBUG(dbgs() << " -> index:" << WasmIndex << "\n");
- } else if (WS.isData()) {
+ } else if (ResolvedSym->isData()) {
assert(DataLocations.count(ResolvedSym) > 0);
const wasm::WasmDataReference &Ref =
DataLocations.find(ResolvedSym)->second;
Modified: llvm/trunk/test/MC/WebAssembly/function-alias.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/function-alias.ll?rev=354694&r1=354693&r2=354694&view=diff
==============================================================================
--- llvm/trunk/test/MC/WebAssembly/function-alias.ll (original)
+++ llvm/trunk/test/MC/WebAssembly/function-alias.ll Fri Feb 22 13:41:42 2019
@@ -5,8 +5,10 @@ target triple = "wasm32-unknown-unknown-
@foo = alias i8, bitcast (i8* ()* @func to i8*)
@bar = alias i8* (), i8* ()* @func
+ at bar2 = alias i8* (), i8* ()* @bar
define i8* @func() {
+ call i8* @bar2();
ret i8* @foo;
}
@@ -16,6 +18,13 @@ define i8* @func() {
; CHECK-NEXT: Type: FUNCTION (0x0)
; CHECK-NEXT: Flags [ (0x0)
; CHECK-NEXT: ]
+; CHECK-NEXT: ElementIndex: 0x0
+; CHECK-NEXT: }
+; CHECK-NEXT: Symbol {
+; CHECK-NEXT: Name: bar2
+; CHECK-NEXT: Type: FUNCTION (0x0)
+; CHECK-NEXT: Flags [ (0x0)
+; CHECK-NEXT: ]
; CHECK-NEXT: ElementIndex: 0x0
; CHECK-NEXT: }
; CHECK-NEXT: Symbol {
More information about the llvm-commits
mailing list