[llvm] r354697 - [WebAssembly] Remove unneeded MCSymbolRefExpr variants
Richard Trieu via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 22 16:01:02 PST 2019
Hi Sam,
I think your change is causing some WebAssembly tests to start failing.
Failing Tests (36):
LLVM :: CodeGen/WebAssembly/byval.ll
LLVM :: CodeGen/WebAssembly/call.ll
LLVM :: CodeGen/WebAssembly/cfg-stackify-eh.ll
LLVM :: CodeGen/WebAssembly/cfg-stackify.ll
LLVM :: CodeGen/WebAssembly/exception.ll
LLVM :: CodeGen/WebAssembly/f16.ll
LLVM :: CodeGen/WebAssembly/f32.ll
LLVM :: CodeGen/WebAssembly/f64.ll
LLVM :: CodeGen/WebAssembly/fast-isel-noreg.ll
LLVM :: CodeGen/WebAssembly/frem.ll
LLVM :: CodeGen/WebAssembly/function-bitcasts-varargs.ll
LLVM :: CodeGen/WebAssembly/function-bitcasts.ll
LLVM :: CodeGen/WebAssembly/global.ll
LLVM :: CodeGen/WebAssembly/i128.ll
LLVM :: CodeGen/WebAssembly/indirect-import.ll
LLVM :: CodeGen/WebAssembly/libcalls.ll
LLVM :: CodeGen/WebAssembly/lower-em-ehsjlj-options.ll
LLVM :: CodeGen/WebAssembly/lower-global-dtors.ll
LLVM :: CodeGen/WebAssembly/main-declaration.ll
LLVM :: CodeGen/WebAssembly/main-no-args.ll
LLVM :: CodeGen/WebAssembly/mem-intrinsics.ll
LLVM :: CodeGen/WebAssembly/muloti4.ll
LLVM :: CodeGen/WebAssembly/reg-stackify.ll
LLVM :: CodeGen/WebAssembly/returned.ll
LLVM :: CodeGen/WebAssembly/signext-arg.ll
LLVM :: CodeGen/WebAssembly/signext-zeroext.ll
LLVM :: CodeGen/WebAssembly/simd.ll
LLVM :: CodeGen/WebAssembly/stack-alignment.ll
LLVM :: CodeGen/WebAssembly/switch.ll
LLVM :: CodeGen/WebAssembly/umulo-128-legalisation-lowering.ll
LLVM :: CodeGen/WebAssembly/umulo-i64.ll
LLVM :: CodeGen/WebAssembly/unreachable.ll
LLVM :: CodeGen/WebAssembly/unsupported-function-bitcasts.ll
LLVM :: CodeGen/WebAssembly/unused-argument.ll
LLVM :: CodeGen/WebAssembly/userstack.ll
LLVM :: CodeGen/WebAssembly/varargs.ll
Expected Passes : 29131
Expected Failures : 149
Unsupported Tests : 628
Unexpected Failures: 36
Sample failure:
Output from test CodeGen/WebAssembly/cfg-stackify.ll
Command Output (stderr):
--
/llvm/test/CodeGen/WebAssembly/cfg-stackify.ll:1289:13: error: OPT-NEXT:
expected string not found in input
; OPT-NEXT: call test15_callee1 at FUNCTION{{$}}
^
<stdin>:813:2: note: scanning from here
call test15_callee1
^
It looks like the expected strings in the test just need to updated in
these tests.
Richard
On Fri, Feb 22, 2019 at 2:28 PM Sam Clegg via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: sbc
> Date: Fri Feb 22 14:29:34 2019
> New Revision: 354697
>
> URL: http://llvm.org/viewvc/llvm-project?rev=354697&view=rev
> Log:
> [WebAssembly] Remove unneeded MCSymbolRefExpr variants
>
> We record the type of the symbol (event/function/data/global) in the
> MCWasmSymbol and so it should always be clear how to handle a relocation
> based on the symbol itself.
>
> The exception is a function which still needs the special @TYPEINDEX
> then the relocation contains the signature rather than the address
> of the functions.
>
> Differential Revision: https://reviews.llvm.org/D58472
>
> Modified:
> llvm/trunk/include/llvm/MC/MCExpr.h
> llvm/trunk/lib/MC/MCExpr.cpp
> llvm/trunk/lib/MC/WasmObjectWriter.cpp
>
> llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
> llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
> llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
> llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
> llvm/trunk/test/MC/WebAssembly/annotations.s
> llvm/trunk/test/MC/WebAssembly/assembler-binary.ll
> llvm/trunk/test/MC/WebAssembly/basic-assembly.s
>
> Modified: llvm/trunk/include/llvm/MC/MCExpr.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCExpr.h?rev=354697&r1=354696&r2=354697&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/MC/MCExpr.h (original)
> +++ llvm/trunk/include/llvm/MC/MCExpr.h Fri Feb 22 14:29:34 2019
> @@ -284,10 +284,7 @@ public:
> VK_Hexagon_IE,
> VK_Hexagon_IE_GOT,
>
> - VK_WebAssembly_FUNCTION, // Function table index, rather than virtual
> addr
> - VK_WebAssembly_GLOBAL, // Global object index
> - VK_WebAssembly_TYPEINDEX,// Type table index
> - VK_WebAssembly_EVENT, // Event index
> + VK_WebAssembly_TYPEINDEX,// Reference to a symbol's type (signature)
>
> VK_AMDGPU_GOTPCREL32_LO, // symbol at gotpcrel32@lo
> VK_AMDGPU_GOTPCREL32_HI, // symbol at gotpcrel32@hi
>
> Modified: llvm/trunk/lib/MC/MCExpr.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=354697&r1=354696&r2=354697&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/MC/MCExpr.cpp (original)
> +++ llvm/trunk/lib/MC/MCExpr.cpp Fri Feb 22 14:29:34 2019
> @@ -302,10 +302,7 @@ StringRef MCSymbolRefExpr::getVariantKin
> case VK_Hexagon_LD_PLT: return "LDPLT";
> case VK_Hexagon_IE: return "IE";
> case VK_Hexagon_IE_GOT: return "IEGOT";
> - case VK_WebAssembly_FUNCTION: return "FUNCTION";
> - case VK_WebAssembly_GLOBAL: return "GLOBAL";
> case VK_WebAssembly_TYPEINDEX: return "TYPEINDEX";
> - case VK_WebAssembly_EVENT: return "EVENT";
> case VK_AMDGPU_GOTPCREL32_LO: return "gotpcrel32 at lo";
> case VK_AMDGPU_GOTPCREL32_HI: return "gotpcrel32 at hi";
> case VK_AMDGPU_REL32_LO: return "rel32 at lo";
> @@ -418,10 +415,7 @@ MCSymbolRefExpr::getVariantKindForName(S
> .Case("lo8", VK_AVR_LO8)
> .Case("hi8", VK_AVR_HI8)
> .Case("hlo8", VK_AVR_HLO8)
> - .Case("function", VK_WebAssembly_FUNCTION)
> - .Case("global", VK_WebAssembly_GLOBAL)
> .Case("typeindex", VK_WebAssembly_TYPEINDEX)
> - .Case("event", VK_WebAssembly_EVENT)
> .Case("gotpcrel32 at lo", VK_AMDGPU_GOTPCREL32_LO)
> .Case("gotpcrel32 at hi", VK_AMDGPU_GOTPCREL32_HI)
> .Case("rel32 at lo", VK_AMDGPU_REL32_LO)
>
> Modified: llvm/trunk/lib/MC/WasmObjectWriter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WasmObjectWriter.cpp?rev=354697&r1=354696&r2=354697&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/MC/WasmObjectWriter.cpp (original)
> +++ llvm/trunk/lib/MC/WasmObjectWriter.cpp Fri Feb 22 14:29:34 2019
> @@ -1557,15 +1557,16 @@ uint64_t WasmObjectWriter::writeObject(M
> assert(Fixup.getKind() ==
> MCFixup::getKindForSize(is64Bit() ? 8 : 4, false));
> const MCExpr *Expr = Fixup.getValue();
> - auto *Sym = dyn_cast<MCSymbolRefExpr>(Expr);
> - if (!Sym)
> + auto *SymRef = dyn_cast<MCSymbolRefExpr>(Expr);
> + if (!SymRef)
> report_fatal_error("fixups in .init_array should be symbol
> references");
> - if (Sym->getKind() != MCSymbolRefExpr::VK_WebAssembly_FUNCTION)
> - report_fatal_error("symbols in .init_array should be for
> functions");
> - if (Sym->getSymbol().getIndex() == InvalidIndex)
> + const auto &TargetSym = cast<const
> MCSymbolWasm>(SymRef->getSymbol());
> + if (TargetSym.getIndex() == InvalidIndex)
> report_fatal_error("symbols in .init_array should exist in
> symbtab");
> + if (!TargetSym.isFunction())
> + report_fatal_error("symbols in .init_array should be for
> functions");
> InitFuncs.push_back(
> - std::make_pair(Priority, Sym->getSymbol().getIndex()));
> + std::make_pair(Priority, TargetSym.getIndex()));
> }
> }
>
>
> Modified:
> llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp?rev=354697&r1=354696&r2=354697&view=diff
>
> ==============================================================================
> ---
> llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
> (original)
> +++
> llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyWasmObjectWriter.cpp
> Fri Feb 22 14:29:34 2019
> @@ -42,23 +42,8 @@ private:
> WebAssemblyWasmObjectWriter::WebAssemblyWasmObjectWriter(bool Is64Bit)
> : MCWasmObjectTargetWriter(Is64Bit) {}
>
> -// Test whether the given expression computes a function address.
> -static bool isFunctionExpr(const MCExpr *Expr) {
> - if (auto SyExp = dyn_cast<MCSymbolRefExpr>(Expr))
> - return cast<MCSymbolWasm>(SyExp->getSymbol()).isFunction();
> -
> - if (auto BinOp = dyn_cast<MCBinaryExpr>(Expr))
> - return isFunctionExpr(BinOp->getLHS()) !=
> isFunctionExpr(BinOp->getRHS());
> -
> - if (auto UnOp = dyn_cast<MCUnaryExpr>(Expr))
> - return isFunctionExpr(UnOp->getSubExpr());
> -
> - return false;
> -}
> -
> -static bool isFunctionType(const MCValue &Target) {
> - const MCSymbolRefExpr *RefA = Target.getSymA();
> - return RefA && RefA->getKind() ==
> MCSymbolRefExpr::VK_WebAssembly_TYPEINDEX;
> +static bool isFunctionSignatureRef(const MCSymbolRefExpr *Ref) {
> + return Ref->getKind() == MCSymbolRefExpr::VK_WebAssembly_TYPEINDEX;
> }
>
> static const MCSection *getFixupSection(const MCExpr *Expr) {
> @@ -80,41 +65,33 @@ static const MCSection *getFixupSection(
> return nullptr;
> }
>
> -static bool isGlobalType(const MCValue &Target) {
> - const MCSymbolRefExpr *RefA = Target.getSymA();
> - return RefA && RefA->getKind() ==
> MCSymbolRefExpr::VK_WebAssembly_GLOBAL;
> -}
> -
> -static bool isEventType(const MCValue &Target) {
> - const MCSymbolRefExpr *RefA = Target.getSymA();
> - return RefA && RefA->getKind() == MCSymbolRefExpr::VK_WebAssembly_EVENT;
> -}
> -
> unsigned WebAssemblyWasmObjectWriter::getRelocType(const MCValue &Target,
> const MCFixup &Fixup)
> const {
> - // WebAssembly functions are not allocated in the data address space. To
> - // resolve a pointer to a function, we must use a special relocation
> type.
> - bool IsFunction = isFunctionExpr(Fixup.getValue());
> + const MCSymbolRefExpr *RefA = Target.getSymA();
> + assert(RefA);
> + auto& SymA = cast<MCSymbolWasm>(RefA->getSymbol());
>
> switch (unsigned(Fixup.getKind())) {
> case WebAssembly::fixup_code_sleb128_i32:
> - if (IsFunction)
> + if (SymA.isFunction())
> return wasm::R_WASM_TABLE_INDEX_SLEB;
> return wasm::R_WASM_MEMORY_ADDR_SLEB;
> case WebAssembly::fixup_code_sleb128_i64:
> llvm_unreachable("fixup_sleb128_i64 not implemented yet");
> case WebAssembly::fixup_code_uleb128_i32:
> - if (isGlobalType(Target))
> + if (SymA.isFunction()) {
> + if (isFunctionSignatureRef(RefA))
> + return wasm::R_WASM_TYPE_INDEX_LEB;
> + else
> + return wasm::R_WASM_FUNCTION_INDEX_LEB;
> + }
> + if (SymA.isGlobal())
> return wasm::R_WASM_GLOBAL_INDEX_LEB;
> - if (isFunctionType(Target))
> - return wasm::R_WASM_TYPE_INDEX_LEB;
> - if (IsFunction)
> - return wasm::R_WASM_FUNCTION_INDEX_LEB;
> - if (isEventType(Target))
> + if (SymA.isEvent())
> return wasm::R_WASM_EVENT_INDEX_LEB;
> return wasm::R_WASM_MEMORY_ADDR_LEB;
> case FK_Data_4:
> - if (IsFunction)
> + if (SymA.isFunction())
> return wasm::R_WASM_TABLE_INDEX_I32;
> if (auto Section = static_cast<const MCSectionWasm *>(
> getFixupSection(Fixup.getValue()))) {
>
> Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp?rev=354697&r1=354696&r2=354697&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp (original)
> +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp Fri Feb 22
> 14:29:34 2019
> @@ -332,15 +332,6 @@ void WebAssemblyAsmPrinter::EmitInstruct
> }
> }
>
> -const MCExpr *WebAssemblyAsmPrinter::lowerConstant(const Constant *CV) {
> - if (const auto *GV = dyn_cast<GlobalValue>(CV))
> - if (GV->getValueType()->isFunctionTy()) {
> - return MCSymbolRefExpr::create(
> - getSymbol(GV), MCSymbolRefExpr::VK_WebAssembly_FUNCTION,
> OutContext);
> - }
> - return AsmPrinter::lowerConstant(CV);
> -}
> -
> bool WebAssemblyAsmPrinter::PrintAsmOperand(const MachineInstr *MI,
> unsigned OpNo, unsigned
> AsmVariant,
> const char *ExtraCode,
>
> Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h?rev=354697&r1=354696&r2=354697&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h (original)
> +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.h Fri Feb 22
> 14:29:34 2019
> @@ -63,7 +63,6 @@ public:
> void EmitConstantPool() override;
> void EmitFunctionBodyStart() override;
> void EmitInstruction(const MachineInstr *MI) override;
> - const MCExpr *lowerConstant(const Constant *CV) override;
> bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
> unsigned AsmVariant, const char *ExtraCode,
> raw_ostream &OS) override;
>
> Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp?rev=354697&r1=354696&r2=354697&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp (original)
> +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp Fri Feb
> 22 14:29:34 2019
> @@ -122,13 +122,8 @@ MCOperand WebAssemblyMCInstLower::lowerS
> int64_t Offset,
> bool IsFunc, bool
> IsGlob,
> bool IsEvent) const {
> - MCSymbolRefExpr::VariantKind VK =
> - IsFunc ? MCSymbolRefExpr::VK_WebAssembly_FUNCTION
> - : IsGlob ? MCSymbolRefExpr::VK_WebAssembly_GLOBAL
> - : IsEvent ? MCSymbolRefExpr::VK_WebAssembly_EVENT
> - : MCSymbolRefExpr::VK_None;
> -
> - const MCExpr *Expr = MCSymbolRefExpr::create(Sym, VK, Ctx);
> + const MCExpr *Expr =
> + MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_None, Ctx);
>
> if (Offset != 0) {
> if (IsFunc)
>
> Modified: llvm/trunk/test/MC/WebAssembly/annotations.s
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/annotations.s?rev=354697&r1=354696&r2=354697&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/MC/WebAssembly/annotations.s (original)
> +++ llvm/trunk/test/MC/WebAssembly/annotations.s Fri Feb 22 14:29:34 2019
> @@ -28,7 +28,7 @@ test_annotation:
> local.set 0
> block i32
> local.get 0
> - br_on_exn 0, __cpp_exception at EVENT
> + br_on_exn 0, __cpp_exception
> rethrow
> end_block
> end_try
> @@ -59,7 +59,7 @@ test_annotation:
> # CHECK-NEXT: local.set 0
> # CHECK-NEXT: block i32
> # CHECK-NEXT: local.get 0
> -# CHECK-NEXT: br_on_exn 0, __cpp_exception at EVENT # 0: down to label6
> +# CHECK-NEXT: br_on_exn 0, __cpp_exception # 0: down to label6
> # CHECK-NEXT: rethrow # to caller
> # CHECK-NEXT: end_block # label6:
> # CHECK-NEXT: end_try # label5:
>
> Modified: llvm/trunk/test/MC/WebAssembly/assembler-binary.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/assembler-binary.ll?rev=354697&r1=354696&r2=354697&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/MC/WebAssembly/assembler-binary.ll (original)
> +++ llvm/trunk/test/MC/WebAssembly/assembler-binary.ll Fri Feb 22 14:29:34
> 2019
> @@ -26,7 +26,7 @@ entry:
> ; ASM: .globl foo
> ; ASM: foo:
> ; ASM-NEXT: .functype foo (i32) -> ()
> -; ASM-NEXT: call bar at FUNCTION
> +; ASM-NEXT: call bar
> ; ASM-NEXT: end_function
> ; ASM: .functype bar () -> ()
>
>
> Modified: llvm/trunk/test/MC/WebAssembly/basic-assembly.s
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/WebAssembly/basic-assembly.s?rev=354697&r1=354696&r2=354697&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/MC/WebAssembly/basic-assembly.s (original)
> +++ llvm/trunk/test/MC/WebAssembly/basic-assembly.s Fri Feb 22 14:29:34
> 2019
> @@ -26,9 +26,9 @@ test0:
> br_if 0 # 0: down to label0
> .LBB0_1:
> loop i32 # label1:
> - call something1 at FUNCTION
> + call something1
> i64.const 1234
> - i32.call something2 at FUNCTION
> + i32.call something2
> i32.const 0
> call_indirect 0
> i32.const 1
> @@ -72,7 +72,7 @@ test0:
> local.set 0
> block i32
> local.get 0
> - br_on_exn 0, __cpp_exception at EVENT
> + br_on_exn 0, __cpp_exception
> rethrow
> .LBB0_4:
> end_block
> @@ -81,7 +81,7 @@ test0:
> throw 0
> .LBB0_5:
> #i32.trunc_sat_f32_s
> - global.get __stack_pointer at GLOBAL
> + global.get __stack_pointer
> end_function
> .globaltype __stack_pointer, i32
>
> @@ -105,9 +105,9 @@ test0:
> # CHECK-NEXT: br_if 0 # 0: down to label0
> # CHECK-NEXT: .LBB0_1:
> # CHECK-NEXT: loop i32 # label1:
> -# CHECK-NEXT: call something1 at FUNCTION
> +# CHECK-NEXT: call something1
> # CHECK-NEXT: i64.const 1234
> -# CHECK-NEXT: i32.call something2 at FUNCTION
> +# CHECK-NEXT: i32.call something2
> # CHECK-NEXT: i32.const 0
> # CHECK-NEXT: call_indirect 0
> # CHECK-NEXT: i32.const 1
> @@ -149,7 +149,7 @@ test0:
> # CHECK-NEXT: local.set 0
> # CHECK-NEXT: block i32
> # CHECK-NEXT: local.get 0
> -# CHECK-NEXT: br_on_exn 0, __cpp_exception at EVENT
> +# CHECK-NEXT: br_on_exn 0, __cpp_exception
> # CHECK-NEXT: rethrow
> # CHECK-NEXT: .LBB0_4:
> # CHECK-NEXT: end_block
> @@ -157,7 +157,7 @@ test0:
> # CHECK-NEXT: i32.const 0
> # CHECK-NEXT: throw 0
> # CHECK-NEXT: .LBB0_5:
> -# CHECK-NEXT: global.get __stack_pointer at GLOBAL
> +# CHECK-NEXT: global.get __stack_pointer
> # CHECK-NEXT: end_function
>
> # CHECK: .globaltype __stack_pointer, i32
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190222/d3a438fa/attachment.html>
More information about the llvm-commits
mailing list