@@ -798,10 +798,6 @@ bool WebAssemblyCallLowering::lowerCall(MachineIRBuilder &MIRBuilder,
798
798
auto PtrIntLLT = LLT::scalar (PtrSize);
799
799
800
800
IndirectIdx = MIRBuilder.buildPtrToInt (PtrIntLLT, IndirectIdx).getReg (0 );
801
- if (PtrSize > 32 ) {
802
- IndirectIdx =
803
- MIRBuilder.buildTrunc (LLT::scalar (32 ), IndirectIdx).getReg (0 );
804
- }
805
801
} else if (CalleeType.getAddressSpace () ==
806
802
WebAssembly::WASM_ADDRESS_SPACE_FUNCREF) {
807
803
Table = WebAssembly::getOrCreateFuncrefCallTableSymbol (MF.getContext (),
@@ -833,8 +829,7 @@ bool WebAssemblyCallLowering::lowerCall(MachineIRBuilder &MIRBuilder,
833
829
if (Info.Callee .isGlobal ()) {
834
830
CallInst.addGlobalAddress (Info.Callee .getGlobal ());
835
831
} else if (Info.Callee .isSymbol ()) {
836
- // TODO: figure out how to trigger/test this
837
- CallInst.addSym (Info.Callee .getMCSymbol ());
832
+ CallInst.addExternalSymbol (Info.Callee .getSymbolName ());
838
833
} else {
839
834
llvm_unreachable (" Trying to lower call with a callee other than reg, "
840
835
" global, or a symbol." );
@@ -1078,8 +1073,24 @@ bool WebAssemblyCallLowering::lowerCall(MachineIRBuilder &MIRBuilder,
1078
1073
for (auto SplitEVT : SplitEVTs) {
1079
1074
Register CurVReg = Info.OrigRet .Regs [i];
1080
1075
ArgInfo CurArgInfo = ArgInfo{CurVReg, SplitEVT.getTypeForEVT (Ctx), 0 };
1081
- setArgFlags (CurArgInfo, AttributeList::ReturnIndex, DL, *Info.CB );
1082
-
1076
+ if (Info.CB ) {
1077
+ setArgFlags (CurArgInfo, AttributeList::ReturnIndex, DL, *Info.CB );
1078
+ } else {
1079
+ // we don't have a call base, so chances are we're looking at a libcall
1080
+ // (external symbol).
1081
+
1082
+ // TODO: figure out how to get ALL the correct attributes
1083
+ auto &Flags = CurArgInfo.Flags [0 ];
1084
+ PointerType *PtrTy =
1085
+ dyn_cast<PointerType>(CurArgInfo.Ty ->getScalarType ());
1086
+ if (PtrTy) {
1087
+ Flags.setPointer ();
1088
+ Flags.setPointerAddrSpace (PtrTy->getPointerAddressSpace ());
1089
+ }
1090
+ Align MemAlign = DL.getABITypeAlign (CurArgInfo.Ty );
1091
+ Flags.setMemAlign (MemAlign);
1092
+ Flags.setOrigAlign (MemAlign);
1093
+ }
1083
1094
splitToValueTypes (CurArgInfo, SplitReturns, DL, CallConv);
1084
1095
++i;
1085
1096
}
0 commit comments