[llvm] [NFC][AMDGPU] Construct MMO inside getTgtMemIntrinsic. (PR #83554)

Nicolai Hähnle via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 09:37:54 PST 2024


================
@@ -2643,8 +2643,12 @@ bool IRTranslator::translateCall(const User &U, MachineIRBuilder &MIRBuilder) {
       MPI = MachinePointerInfo(Info.ptrVal, Info.offset);
     else if (Info.fallbackAddressSpace)
       MPI = MachinePointerInfo(*Info.fallbackAddressSpace);
-    MIB.addMemOperand(
-        MF->getMachineMemOperand(MPI, Info.flags, MemTy, Alignment, CI.getAAMetadata()));
+
+    if (Info.MMO)
+      MIB.addMemOperand(Info.MMO);
+    else
+      MIB.addMemOperand(MF->getMachineMemOperand(
+          MPI, Info.flags, MemTy, Alignment, CI.getAAMetadata()));
----------------
nhaehnle wrote:

It's not just syncscope and ordering, but also failure ordering, AAInfo and Ranges. Basically, you end up replicating MachineMemOperand in a second place, which I find pretty questionable.

I agree that the desirable end result is that everybody just creates `MachineMemOperand`s. Adding the field in IntrinsicInfo in this way was my proposal to provide a smoother upgrade path, but perhaps an alternative can be found.

For example, perhaps a second overload
```
virtual MachineMemOperand *getTgtMemIntrinsic(const CallInst &Call, MachineFunction &MF, unsigned IntrinsicID) 
```
could be added whose default implementation forwards to the currently-existing overload.

https://github.com/llvm/llvm-project/pull/83554


More information about the llvm-commits mailing list