Add logic to instruction selection to lowerThis patch adds TargetStackID::Object. This static alloca of pointers inck holds locations of
certain well-known non-default address spaces to WebAssembly localvalues that are only addressable by name -- not via a pointer to memory.
The motivation is that many language front-ends will want to represent
local variables as alloca'sFor the WebAssembly target, relying on SROA / mem2regthese objects are lowered to lift thoseWebAssembly
allocations to SSAl variables as appropriate. If optimizations are off,, which are managed by the WebAssembly run-time and are
this won't happen, and those alloca's will reach instruction selection.not addressable by linear memory.
For the WebAssembly target IR indicates that an AllocaInst should be put
But externref and funcref values can't be written to linear memory, soon TargetStackID::Object by putting it in the non-integral address space
there we have a problem.
The solution we are going to work towards is to annotateWASM_ADDRESS_SPACE_OBJECT, with value 1. SROA will mostly lift the initialse
alloca's of reference-typed values with a special address space.tions to SSA locals, but any alloca that reaches instruction
Pointers in this address space denote automatic-storage-durationselection (usually in non-optimized builds) will be assigned the new
locations, i.e., function-local variablesTargetStackID there. The instruction selectorLoads and stores to those values are transformed
sees loads and stores from these locations and turns the allocationsto new WebAssemblyISD::LOCAL_GET / WebAssemblyISD::LOCAL_SET nodes,
into WebAssembly locals, and turns the loads and stores into LOCAL_GET /which then lower to the type-specific LOCAL_GET_I32 etc instructions via