[clang] [llvm] [WebAssembly] Represent reference types as TargetExtType (PR #203165)

Hood Chatham via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 24 06:18:51 PDT 2026


================
@@ -275,6 +275,27 @@ void WebAssemblyDAGToDAGISel::Select(SDNode *Node) {
       ReplaceNode(Node, TLSAlign);
       return;
     }
+    case Intrinsic::wasm_ptr_to_funcref: {
+      // Convert a function pointer to a funcref by reading the corresponding
+      // entry from the __indirect_function_table.
+      MachineFunction &MF = CurDAG->getMachineFunction();
+      auto PtrVT = MVT::getIntegerVT(MF.getDataLayout().getPointerSizeInBits());
+      MCSymbol *Table = WebAssembly::getOrCreateFunctionTableSymbol(
+          MF.getContext(), Subtarget);
+      SDValue TableSym = CurDAG->getMCSymbol(Table, PtrVT);
+      SDValue FuncPtr = Node->getOperand(1);
+      if (Subtarget->hasAddr64() && FuncPtr.getValueType() == MVT::i64) {
+        // table.get expects an i32 but on 64 bit platforms the function pointer
----------------
hoodmane wrote:

Resolving as blocked on #180649.

https://github.com/llvm/llvm-project/pull/203165


More information about the llvm-commits mailing list