[PATCH] D34044: [WebAssembly] WebAssemblyFastISel getelementptr variable index support

Jacob Gravelle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 13 14:36:58 PDT 2017


jgravelle-google added a comment.

In https://reviews.llvm.org/D34044#777275, @sunfish wrote:

> A more precise fix would be to have that code at the bottom of WebAssemblyFastISel::computeAddress return false in the case where there's already a (non-zero) base register.


That's probably worth doing, the problem is that the line that does this problematic folding already checks `Addr.getReg() == 0`, so it doesn't actually fix the problem.
The real underlying cause is that we think we're folding Add instructions, but we haven't actually checked that the Use is an Add yet. Moving the unscaled add after the check makes that a correct assumption, and everything seems happy about it.
Note that adding the `return false` made the lit tests pass, and only failed on the wasm waterfall. I added a test case (`@store_i8_with_array_alloca_gep`) to cover it.
This also only fails with the `-elf` triple, because we store the stack pointer in memory instead of in a global, making allocas loads instead of get_globals.

> For extra caution, it may be possible to have Address::setReg assert that the base is zero before overwriting it.

Probably a good idea going forward. Added.

@sunfish PTAL


https://reviews.llvm.org/D34044





More information about the llvm-commits mailing list