Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyFastISel.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyFastISel.cpp +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyFastISel.cpp @@ -851,6 +851,13 @@ Args.push_back(Reg); } + unsigned CalleeReg = 0; + if (!IsDirect) { + CalleeReg = getRegForValue(Call->getCalledValue()); + if (!CalleeReg) + return false; + } + auto MIB = BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, TII.get(Opc)); if (!IsVoid) @@ -858,12 +865,8 @@ if (IsDirect) MIB.addGlobalAddress(Func); - else { - unsigned Reg = getRegForValue(Call->getCalledValue()); - if (Reg == 0) - return false; - MIB.addReg(Reg); - } + else + MIB.addReg(CalleeReg); for (unsigned ArgReg : Args) MIB.addReg(ArgReg); Index: llvm/trunk/test/CodeGen/WebAssembly/call-pic.ll =================================================================== --- llvm/trunk/test/CodeGen/WebAssembly/call-pic.ll +++ llvm/trunk/test/CodeGen/WebAssembly/call-pic.ll @@ -8,6 +8,11 @@ declare hidden i32 @hidden_function() @indirect_func = global i32 ()* @foo +@alias_func = hidden alias i32 (), i32 ()* @local_function + +define i32 @local_function() { + ret i32 1 +} define void @call_indirect_func() { ; CHECK-LABEL: call_indirect_func: @@ -31,6 +36,16 @@ ret void } +define void @call_alias_func() { +; CHECK-LABEL: call_alias_func: +; CHECK: .functype call_alias_func () -> () +; CHECK-NEXT: i32.call $push0=, alias_func +; CHECK-NEXT: drop $pop0{{$}} +; CHECK-NEXT: return{{$}} + %call = call i32 @alias_func() + ret void +} + define i8* @get_function_address() { ; CHECK-LABEL: get_function_address: ; CHECK: global.get $push[[L0:[0-9]+]]=, bar@GOT{{$}}