[llvm] [SPIRV] Legalize byte-buffer reinterpretation ptrcasts (#192523) (PR #212999)

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 4 07:42:26 PDT 2026


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 origin/main HEAD --extensions cpp -- llvm/lib/Target/SPIRV/SPIRVLegalizePointerCast.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

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

``````````diff
diff --git a/llvm/lib/Target/SPIRV/SPIRVLegalizePointerCast.cpp b/llvm/lib/Target/SPIRV/SPIRVLegalizePointerCast.cpp
index b0e4fcfb6..131d84209 100644
--- a/llvm/lib/Target/SPIRV/SPIRVLegalizePointerCast.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVLegalizePointerCast.cpp
@@ -248,9 +248,9 @@ class SPIRVLegalizePointerCastImpl {
           BaseOffset, ConstantInt::get(BaseOffset->getType(), ByteOffset));
     SmallVector<OperandBundleDef, 1> OpBundles;
     GetPtr->getOperandBundlesAsDefs(OpBundles);
-    CallInst *NewPtr = B.CreateCall(GetPtr->getFunctionType(),
-                                    GetPtr->getCalledOperand(),
-                                    {Handle, NewOffset}, OpBundles);
+    CallInst *NewPtr =
+        B.CreateCall(GetPtr->getFunctionType(), GetPtr->getCalledOperand(),
+                     {Handle, NewOffset}, OpBundles);
     NewPtr->setAttributes(GetPtr->getAttributes());
     NewPtr->setCallingConv(GetPtr->getCallingConv());
     Type *I8Ty = Type::getInt8Ty(B.getContext());
@@ -279,7 +279,7 @@ class SPIRVLegalizePointerCastImpl {
   }
 
   void storeScalarToByteLayout(IRBuilder<> &B, Value *Src, Value *Dst,
-                             Align Alignment) {
+                               Align Alignment) {
     LLVMContext &Ctx = B.getContext();
     Type *I8Ty = Type::getInt8Ty(Ctx);
     const DataLayout &DL = B.GetInsertBlock()->getModule()->getDataLayout();
@@ -289,7 +289,8 @@ class SPIRVLegalizePointerCastImpl {
     for (unsigned I = 0; I < NumBytes; ++I) {
       Value *Shifted =
           I == 0 ? IntVal
-                 : B.CreateLShr(IntVal, ConstantInt::get(IntVal->getType(), 8 * I));
+                 : B.CreateLShr(IntVal,
+                                ConstantInt::get(IntVal->getType(), 8 * I));
       Value *Byte = B.CreateTrunc(Shifted, I8Ty);
       buildAssignType(B, I8Ty, Byte);
       Value *Ptr = gepByteOffset(B, Dst, I);
@@ -344,8 +345,7 @@ class SPIRVLegalizePointerCastImpl {
     Type *OriginalElemTy = GR->findDeducedElementType(OriginalPtr);
     const DataLayout &DL = B.GetInsertBlock()->getModule()->getDataLayout();
     if (OriginalElemTy && OriginalElemTy == Type::getInt8Ty(B.getContext()) &&
-        AccessTy->isSingleValueType() &&
-        DL.getTypeStoreSize(AccessTy) > 1)
+        AccessTy->isSingleValueType() && DL.getTypeStoreSize(AccessTy) > 1)
       return ReinterpretKind::ByteWise;
 
     return ReinterpretKind::RetagDirect;
@@ -451,7 +451,8 @@ class SPIRVLegalizePointerCastImpl {
     if (SAT && DVT && SAT->getElementType() == DVT->getElementType())
       return loadVectorFromArray(B, DVT, GEP, IllegalLoad->getAlign());
     if (MAT && DVT && MAT->getElementType() == DVT->getElementType())
-      return loadVectorFromMatrixArray(B, DVT, GEP, MAT, IllegalLoad->getAlign());
+      return loadVectorFromMatrixArray(B, DVT, GEP, MAT,
+                                       IllegalLoad->getAlign());
 
     llvm_unreachable("Failed to load from aggregate.");
   }
@@ -724,7 +725,8 @@ class SPIRVLegalizePointerCastImpl {
     auto ResultOpt = getPointerToFirstCompatibleType(B, Dst, Dst->getType(),
                                                      Src->getType(), true);
     if (!ResultOpt) {
-      if (tryReinterpretStore(B, Src->getType(), Dst, CastedPtr, Src, Alignment))
+      if (tryReinterpretStore(B, Src->getType(), Dst, CastedPtr, Src,
+                              Alignment))
         return;
       llvm_unreachable("Failed to store to aggregate: "
                        "Could not find compatible memory layout.");

``````````

</details>


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


More information about the llvm-commits mailing list