[PATCH] D143526: [GlobalISel] Handle ptr size != index size in IRTranslator

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 8 10:31:39 PST 2023


arsenm added inline comments.


================
Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:6047
       LLVMContext &Ctx = GEP->getContext();
-      Type *IntPtrTy = DL->getIntPtrType(GEP->getType());
+      Type *PtrIdxTy = DL->getPtrIndexType(GEP->getType());
       Type *I8PtrTy =
----------------
Some addressing mode thing, probably would be best to hack up a test that hits an unreachable here


================
Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:6077
         // Create a new base.
-        Value *BaseIndex = ConstantInt::get(IntPtrTy, BaseOffset);
+        Value *BaseIndex = ConstantInt::get(PtrIdxTy, BaseOffset);
         NewBaseGEP = OldBase;
----------------
Ditto for these other CGP parts, which are really separate from the IRTranslator part


================
Comment at: llvm/lib/CodeGen/GlobalISel/CallLowering.cpp:850
+  LLT OffsetLLTy = getLLTForType(*DL.getPtrIndexType(RetPtrTy), DL);
 
   MachinePointerInfo PtrInfo = MachinePointerInfo::getFixedStack(MF, FI);
----------------
this would be an ptr addrspace(7) at the end of a large struct return value, on the caller side


================
Comment at: llvm/lib/CodeGen/GlobalISel/CallLowering.cpp:880
   LLT OffsetLLTy =
-      getLLTForType(*DL.getIntPtrType(RetTy->getPointerTo(AS)), DL);
+      getLLTForType(*DL.getPtrIndexType(RetTy->getPointerTo(AS)), DL);
 
----------------
this would be an ptr addrspace(7) at the end of a large struct return value 


================
Comment at: llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp:1516
     PtrTy = getLLTForType(*PtrIRTy, *DL);
-    OffsetIRTy = DL->getIntPtrType(PtrIRTy);
+    OffsetIRTy = DL->getPtrIndexType(PtrIRTy);
     OffsetTy = getLLTForType(*OffsetIRTy, *DL);
----------------
vector GEP with a scalar index?


================
Comment at: llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-non-integral-address-spaces.ll:42
   %gep = getelementptr i8, <2 x ptr addrspace(7)> zeroinitializer, <2 x i32> <i32 123, i32 123>
   ret <2 x ptr addrspace(7)> %gep
 }
----------------
Some vector GEP cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143526



More information about the llvm-commits mailing list