Name Date Size #Lines LOC

..--

AsmParser/H--2,1101,694

Disassembler/H--323270

MCTargetDesc/H--2,3341,753

TargetInfo/H--7937

Utils/H--420275

README.txtH A D02-Sep-20237.2 KiB174119

WebAssembly.hH A D07-Dec-20254.7 KiB11276

WebAssembly.tdH A D07-Dec-20256.8 KiB168132

WebAssemblyAddMissingPrototypes.cppH A D07-Dec-20255.7 KiB154103

WebAssemblyArgumentMove.cppH A D07-Dec-20253.3 KiB9552

WebAssemblyAsmPrinter.cppH A D07-Dec-202528.4 KiB769556

WebAssemblyAsmPrinter.hH A D07-Dec-20253.1 KiB8657

WebAssemblyCFGSort.cppH A D07-Dec-202514.7 KiB399250

WebAssemblyCFGStackify.cppH A D07-Dec-202599.8 KiB2,6731,408

WebAssemblyCleanCodeAfterTrap.cppH A D28-Jul-20242.5 KiB8156

WebAssemblyDebugFixup.cppH A D07-Dec-20256.4 KiB159103

WebAssemblyDebugValueManager.cppH A D28-Jul-202415.7 KiB420205

WebAssemblyDebugValueManager.hH A D02-Sep-20232 KiB5824

WebAssemblyExceptionInfo.cppH A D07-Dec-202514.5 KiB373250

WebAssemblyExceptionInfo.hH A D07-Dec-20256.5 KiB175116

WebAssemblyExplicitLocals.cppH A D10-Jan-202618 KiB496343

WebAssemblyFastISel.cppH A D07-Dec-202542.5 KiB1,4531,213

WebAssemblyFixBrTableDefaults.cppH A D07-Dec-20257.8 KiB202115

WebAssemblyFixFunctionBitcasts.cppH A D07-Dec-202511.7 KiB306202

WebAssemblyFixIrreducibleControlFlow.cppH A D07-Dec-202520.8 KiB561329

WebAssemblyFrameLowering.cppH A D07-Dec-202515.6 KiB395260

WebAssemblyFrameLowering.hH A D07-Dec-20253.3 KiB8345

WebAssemblyISD.defH A D07-Dec-20252 KiB6358

WebAssemblyISelDAGToDAG.cppH A D07-Dec-202516.1 KiB449331

WebAssemblyISelLowering.cppH A D07-Dec-2025134.8 KiB3,5362,651

WebAssemblyISelLowering.hH A D07-Dec-20256.9 KiB152113

WebAssemblyInstrAtomics.tdH A D07-Dec-202525.4 KiB537480

WebAssemblyInstrBulkMemory.tdH A D07-Dec-20254.3 KiB11194

WebAssemblyInstrCall.tdH A D02-Sep-20233.4 KiB8571

WebAssemblyInstrControl.tdH A D07-Dec-20258.9 KiB208177

WebAssemblyInstrConv.tdH A D22-Aug-202113.9 KiB241228

WebAssemblyInstrFloat.tdH A D02-Sep-20236.2 KiB128114

WebAssemblyInstrFormats.tdH A D04-Jul-20223.1 KiB6964

WebAssemblyInstrInfo.cppH A D07-Dec-20258.4 KiB236166

WebAssemblyInstrInfo.hH A D07-Dec-20252.8 KiB7544

WebAssemblyInstrInfo.tdH A D07-Dec-202518.9 KiB468385

WebAssemblyInstrInteger.tdH A D07-Dec-20258.5 KiB177161

WebAssemblyInstrMemory.tdH A D07-Dec-20258.8 KiB208180

WebAssemblyInstrRef.tdH A D07-Dec-20252.3 KiB5752

WebAssemblyInstrSIMD.tdH A D07-Dec-202567.1 KiB1,6281,425

WebAssemblyInstrTable.tdH A D28-Jul-20244.5 KiB9278

WebAssemblyLateEHPrepare.cppH A D07-Dec-202515 KiB413282

WebAssemblyLowerBrUnless.cppH A D20-Mar-20226.2 KiB210172

WebAssemblyLowerEmscriptenEHSjLj.cppH A D07-Dec-202572.3 KiB1,808991

WebAssemblyLowerRefTypesIntPtrConv.cppH A D07-Dec-20252.9 KiB8647

WebAssemblyMCInstLower.cppH A D07-Dec-202512.6 KiB324243

WebAssemblyMCInstLower.hH A D02-Sep-20231.6 KiB4826

WebAssemblyMCLowerPrePass.cppH A D07-Dec-20253.1 KiB9761

WebAssemblyMachineFunctionInfo.cppH A D07-Dec-20256.5 KiB172120

WebAssemblyMachineFunctionInfo.hH A D07-Dec-20258 KiB225148

WebAssemblyMemIntrinsicResults.cppH A D28-Jul-20247.5 KiB211140

WebAssemblyNullifyDebugValueLists.cppH A D07-Dec-20252.2 KiB6437

WebAssemblyOptimizeLiveIntervals.cppH A D07-Dec-20254.8 KiB12473

WebAssemblyOptimizeReturned.cppH A D20-Mar-20222.5 KiB8052

WebAssemblyPeephole.cppH A D18-Dec-20235.7 KiB166130

WebAssemblyRefTypeMem2Local.cppH A D28-Jul-20243.1 KiB9564

WebAssemblyRegColoring.cppH A D07-Dec-202512.5 KiB332208

WebAssemblyRegNumbering.cppH A D07-Dec-20253.7 KiB10871

WebAssemblyRegStackify.cppH A D10-Jan-202638.9 KiB1,031692

WebAssemblyRegisterInfo.cppH A D07-Dec-20256.2 KiB159118

WebAssemblyRegisterInfo.hH A D14-Apr-20231.7 KiB5426

WebAssemblyRegisterInfo.tdH A D07-Dec-20253.1 KiB7361

WebAssemblyReplacePhysRegs.cppH A D07-Dec-20253.7 KiB10872

WebAssemblyRuntimeLibcallSignatures.cppH A D07-Dec-202535.9 KiB951876

WebAssemblyRuntimeLibcallSignatures.hH A D28-Jul-20241.3 KiB4018

WebAssemblySelectionDAGInfo.cppH A D07-Dec-20253.3 KiB8149

WebAssemblySelectionDAGInfo.hH A D07-Dec-20252.1 KiB5028

WebAssemblySetP2AlignOperands.cppH A D07-Dec-20253.3 KiB9768

WebAssemblySortRegion.cppH A D07-Dec-20252.9 KiB7957

WebAssemblySortRegion.hH A D13-Jun-20213 KiB9256

WebAssemblySubtarget.cppH A D07-Dec-20252.6 KiB7942

WebAssemblySubtarget.hH A D07-Dec-20254.4 KiB12487

WebAssemblyTargetMachine.cppH A D07-Dec-202526.6 KiB697435

WebAssemblyTargetMachine.hH A D07-Dec-20253.1 KiB8249

WebAssemblyTargetObjectFile.cppH A D07-Dec-2025848 247

WebAssemblyTargetObjectFile.hH A D20-Dec-2019959 3010

WebAssemblyTargetTransformInfo.cppH A D07-Dec-202510 KiB314212

WebAssemblyTargetTransformInfo.hH A D07-Dec-20254 KiB10559

WebAssemblyUtilities.cppH A D07-Dec-20256.9 KiB198150

WebAssemblyUtilities.hH A D28-Jul-20242.8 KiB8134

README.txt

1//===-- README.txt - Notes for WebAssembly code gen -----------------------===//
2
3The object format emitted by the WebAssembly backed is documented in:
4
5  * https://github.com/WebAssembly/tool-conventions/blob/main/Linking.md
6
7The C ABI is described in:
8
9  * https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md
10
11For more information on WebAssembly itself, see the home page:
12
13  * https://webassembly.github.io/
14
15Emscripten provides a C/C++ compilation environment based on clang which
16includes standard libraries, tools, and packaging for producing WebAssembly
17applications that can run in browsers and other environments.
18
19wasi-sdk provides a more minimal C/C++ SDK based on clang, llvm and a libc based
20on musl, for producing WebAssembly applications that use the WASI ABI.
21
22Rust provides WebAssembly support integrated into Cargo. There are two
23main options:
24 - wasm32-unknown-unknown, which provides a relatively minimal environment
25   that has an emphasis on being "native"
26 - wasm32-unknown-emscripten, which uses Emscripten internally and
27   provides standard C/C++ libraries, filesystem emulation, GL and SDL
28   bindings
29For more information, see:
30  * https://www.hellorust.com/
31
32The following documents contain some information on the semantics and binary
33encoding of WebAssembly itself:
34  * https://github.com/WebAssembly/design/blob/main/Semantics.md
35  * https://github.com/WebAssembly/design/blob/main/BinaryEncoding.md
36
37Some notes on ways that the generated code could be improved follow:
38
39//===---------------------------------------------------------------------===//
40
41Br, br_if, and br_table instructions can support having a value on the value
42stack across the jump (sometimes). We should (a) model this, and (b) extend
43the stackifier to utilize it.
44
45//===---------------------------------------------------------------------===//
46
47The min/max instructions aren't exactly a<b?a:b because of NaN and negative zero
48behavior. The ARM target has the same kind of min/max instructions and has
49implemented optimizations for them; we should do similar optimizations for
50WebAssembly.
51
52//===---------------------------------------------------------------------===//
53
54AArch64 runs SeparateConstOffsetFromGEPPass, followed by EarlyCSE and LICM.
55Would these be useful to run for WebAssembly too? Also, it has an option to
56run SimplifyCFG after running the AtomicExpand pass. Would this be useful for
57us too?
58
59//===---------------------------------------------------------------------===//
60
61Register stackification uses the VALUE_STACK physical register to impose
62ordering dependencies on instructions with stack operands. This is pessimistic;
63we should consider alternate ways to model stack dependencies.
64
65//===---------------------------------------------------------------------===//
66
67Lots of things could be done in WebAssemblyTargetTransformInfo.cpp. Similarly,
68there are numerous optimization-related hooks that can be overridden in
69WebAssemblyTargetLowering.
70
71//===---------------------------------------------------------------------===//
72
73Instead of the OptimizeReturned pass, which should consider preserving the
74"returned" attribute through to MachineInstrs and extending the
75MemIntrinsicResults pass to do this optimization on calls too. That would also
76let the WebAssemblyPeephole pass clean up dead defs for such calls, as it does
77for stores.
78
79//===---------------------------------------------------------------------===//
80
81Consider implementing optimizeSelect, optimizeCompareInstr, optimizeCondBranch,
82optimizeLoadInstr, and/or getMachineCombinerPatterns.
83
84//===---------------------------------------------------------------------===//
85
86Find a clean way to fix the problem which leads to the Shrink Wrapping pass
87being run after the WebAssembly PEI pass.
88
89//===---------------------------------------------------------------------===//
90
91When setting multiple local variables to the same constant, we currently get
92code like this:
93
94    i32.const   $4=, 0
95    i32.const   $3=, 0
96
97It could be done with a smaller encoding like this:
98
99    i32.const   $push5=, 0
100    local.tee   $push6=, $4=, $pop5
101    local.copy  $3=, $pop6
102
103//===---------------------------------------------------------------------===//
104
105WebAssembly registers are implicitly initialized to zero. Explicit zeroing is
106therefore often redundant and could be optimized away.
107
108//===---------------------------------------------------------------------===//
109
110Small indices may use smaller encodings than large indices.
111WebAssemblyRegColoring and/or WebAssemblyRegRenumbering should sort registers
112according to their usage frequency to maximize the usage of smaller encodings.
113
114//===---------------------------------------------------------------------===//
115
116Many cases of irreducible control flow could be transformed more optimally
117than via the transform in WebAssemblyFixIrreducibleControlFlow.cpp.
118
119It may also be worthwhile to do transforms before register coloring,
120particularly when duplicating code, to allow register coloring to be aware of
121the duplication.
122
123//===---------------------------------------------------------------------===//
124
125WebAssemblyRegStackify could use AliasAnalysis to reorder loads and stores more
126aggressively.
127
128//===---------------------------------------------------------------------===//
129
130WebAssemblyRegStackify is currently a greedy algorithm. This means that, for
131example, a binary operator will stackify with its user before its operands.
132However, if moving the binary operator to its user moves it to a place where
133its operands can't be moved to, it would be better to leave it in place, or
134perhaps move it up, so that it can stackify its operands. A binary operator
135has two operands and one result, so in such cases there could be a net win by
136preferring the operands.
137
138//===---------------------------------------------------------------------===//
139
140Instruction ordering has a significant influence on register stackification and
141coloring. Consider experimenting with the MachineScheduler (enable via
142enableMachineScheduler) and determine if it can be configured to schedule
143instructions advantageously for this purpose.
144
145//===---------------------------------------------------------------------===//
146
147WebAssemblyRegStackify currently assumes that the stack must be empty after
148an instruction with no return values, however wasm doesn't actually require
149this. WebAssemblyRegStackify could be extended, or possibly rewritten, to take
150full advantage of what WebAssembly permits.
151
152//===---------------------------------------------------------------------===//
153
154Add support for mergeable sections in the Wasm writer, such as for strings and
155floating-point constants.
156
157//===---------------------------------------------------------------------===//
158
159The function @dynamic_alloca_redzone in test/CodeGen/WebAssembly/userstack.ll
160ends up with a local.tee in its prolog which has an unused result, requiring
161an extra drop:
162
163    global.get  $push8=, 0
164    local.tee   $push9=, 1, $pop8
165    drop        $pop9
166    [...]
167
168The prologue code initially thinks it needs an FP register, but later it
169turns out to be unneeded, so one could either approach this by being more
170clever about not inserting code for an FP in the first place, or optimizing
171away the copy later.
172
173//===---------------------------------------------------------------------===//
174