[llvm] [SPIR-V] Emit SPIR-V bitcasts between source/expected pointer type (PR #69621)

via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 19 11:11:52 PDT 2023


github-actions[bot] wrote:


<!--LLVM CODE FORMAT COMMENT: {clang-format}-->

:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 3343d000a3511a4ea6fbd73bad86a3bbef8117e4 53e65ef70d113e906e81c129bb9a4b1612fb4fbd -- llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp b/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
index 47fab8a76a12..bd8ff9a75679 100644
--- a/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp
@@ -260,7 +260,7 @@ Instruction *SPIRVEmitIntrinsics::visitGetElementPtrInst(GetElementPtrInst &I) {
 
 Instruction *SPIRVEmitIntrinsics::visitBitCastInst(BitCastInst &I) {
   Value *Source = I.getOperand(0);
-  
+
   // SPIR-V, contrary to LLVM 17+ IR, supports bitcasts between pointers of
   // varying element types. In case of IR coming from older versions of LLVM
   // such bitcasts do not provide sufficient information, should be just skipped
@@ -270,7 +270,7 @@ Instruction *SPIRVEmitIntrinsics::visitBitCastInst(BitCastInst &I) {
     I.eraseFromParent();
     return &I;
   }
-    
+
   SmallVector<Type *, 2> Types = {I.getType(), Source->getType()};
   SmallVector<Value *> Args(I.op_begin(), I.op_end());
   auto *NewI = IRB->CreateIntrinsic(Intrinsic::spv_bitcast, {Types}, {Args});
@@ -287,7 +287,8 @@ void SPIRVEmitIntrinsics::insertPtrCastInstr(Instruction *I) {
     return;
 
   // TODO: Do not emit new spv_ptrcast if equivalent one already exists or when
-  // spv_assign_ptr_type already targets this pointer with the same element type.
+  // spv_assign_ptr_type already targets this pointer with the same element
+  // type.
 
   Value *Pointer = SI->getPointerOperand();
   Type *ExpectedElementType = SI->getValueOperand()->getType();
diff --git a/llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp b/llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp
index c0d631fb69de..113f0ca2235f 100644
--- a/llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp
@@ -140,11 +140,11 @@ static void insertBitcasts(MachineFunction &MF, SPIRVGlobalRegistry *GR,
             BaseTy, MI, *MF.getSubtarget<SPIRVSubtarget>().getInstrInfo(),
             addressSpaceToStorageClass(MI.getOperand(4).getImm()));
 
-        GR->assignSPIRVTypeToVReg(AssignedPtrType, MI.getOperand(0).getReg(), MF);
+        GR->assignSPIRVTypeToVReg(AssignedPtrType, MI.getOperand(0).getReg(),
+                                  MF);
         MIB.buildBitcast(MI.getOperand(0).getReg(), MI.getOperand(2).getReg());
         ToErase.push_back(&MI);
       }
-
     }
   }
   for (MachineInstr *MI : ToErase)

``````````

</details>


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


More information about the llvm-commits mailing list