[PATCH] D101140: [WebAssembly][CodeGen] Allow for externref/funcref local variables

Andy Wingo via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 22 23:35:23 PDT 2021


wingo created this revision.
wingo added a reviewer: tlively.
Herald added subscribers: ecnelises, sunfish, hiraditya, jgravelle-google, dschuff.
wingo requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.

Add logic to instruction selection to lower static alloca of pointers in
certain well-known non-default address spaces to WebAssembly local
variables.

The motivation is that many language front-ends will want to represent
local variables as alloca's, relying on SROA / mem2reg to lift those
allocations to SSA variables as appropriate.  If optimizations are off,
this won't happen, and those alloca's will reach instruction selection.
But externref and funcref values can't be written to linear memory, so
there we have a problem.

The solution we are going to work towards is to annotate the initial
alloca's of reference-typed values with a special address space.
Pointers in this address space denote automatic-storage-duration
locations, i.e., function-local variables.  The instruction selector
sees loads and stores from these locations and turns the allocations
into WebAssembly locals, and turns the loads and stores into LOCAL_GET /
LOCAL_SET.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101140

Files:
  llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrRef.td
  llvm/lib/Target/WebAssembly/WebAssemblyMachineFunctionInfo.h
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyUtilities.h
  llvm/test/CodeGen/WebAssembly/externref-alloca.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101140.339898.patch
Type: text/x-patch
Size: 21497 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210423/f7fa286d/attachment.bin>


More information about the llvm-commits mailing list