[PATCH] D92744: [WebAssembly] Fix code generated for atomic operations in PIC mode

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 8 17:10:31 PST 2020


sbc100 added inline comments.


================
Comment at: llvm/lib/Target/WebAssembly/WebAssemblyInstrAtomics.td:232
 // Select loads with no constant offset.
-let Predicates = [HasAtomics] in {
 defm : LoadPatNoOffset<i32, atomic_load_32, "ATOMIC_LOAD_I32">;
----------------
aheejin wrote:
> Good point. Maybe we can restore these for load/store patterns? (This and similar `Predicates` below) These patterns don't seem to contain PIC related predicates anyway.
The do contain their own requires.  See `WebAssemblyInstrMemory.td`:

``
multiclass LoadPatImmOff<ValueType ty, PatFrag kind, PatFrag operand,            
                         string inst> {                                          
  def : Pat<(ty (kind (operand I32:$addr, imm:$off))),                           
            (!cast<NI>(inst # "_A32") 0, imm:$off, I32:$addr)>,                  
        Requires<[HasAddr32]>;                                                   
  def : Pat<(ty (kind (operand I64:$addr, imm:$off))),                           
            (!cast<NI>(inst # "_A64") 0, imm:$off, I64:$addr)>,                  
        Requires<[HasAddr64]>;                                                      
}       
```

See HasAddr64 and HasAddr32.

This means that we can't wrap the call the uses of this multclass in WebAssemblyInstrAtomics.td in `let Predicates =`.   

So... what I'm proposing here is that we accept that these atomic patterns are available even without the atomics feature.   As I explained I don't think that will actually be a problem in practice because we should have lowered them all away anyway.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92744/new/

https://reviews.llvm.org/D92744



More information about the llvm-commits mailing list