[llvm] [DirectX] Reland #142853 with Circular GEP fixes (PR #143747)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 11 09:58:50 PDT 2025
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 HEAD~1 HEAD --extensions cpp -- llvm/lib/Target/DirectX/DXILFlattenArrays.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/Target/DirectX/DXILFlattenArrays.cpp b/llvm/lib/Target/DirectX/DXILFlattenArrays.cpp
index 10883527f..e7ea80d43 100644
--- a/llvm/lib/Target/DirectX/DXILFlattenArrays.cpp
+++ b/llvm/lib/Target/DirectX/DXILFlattenArrays.cpp
@@ -225,7 +225,7 @@ void DXILFlattenArraysVisitor::recursivelyCollectGEPs(
// Check if this GEP is already in the map to avoid circular references
if (GEPChainMap.count(&CurrGEP) > 0)
return;
-
+
Value *LastIndex = CurrGEP.getOperand(CurrGEP.getNumOperands() - 1);
AllIndicesAreConstInt &= isa<ConstantInt>(LastIndex);
Indices.push_back(LastIndex);
@@ -275,17 +275,17 @@ bool DXILFlattenArraysVisitor::visitGetElementPtrInstInGEPChainBase(
genInstructionFlattenIndices(GEPInfo.Indices, GEPInfo.Dims, Builder);
ArrayType *FlattenedArrayType = GEPInfo.ParentArrayType;
-
+
// Don't append '.flat' to an empty string. If the SSA name isn't available
// it could conflict with the ParentOperand's name.
std::string FlatName = GEP.hasName() ? GEP.getName().str() + ".flat" : "";
-
- Value *FlatGEP =
- Builder.CreateGEP(FlattenedArrayType, GEPInfo.ParentOperand,
- {Builder.getInt32(0), FlatIndex},
- FlatName, GEP.getNoWrapFlags());
- // Store the new GEP in the map before replacing uses to avoid circular references
+ Value *FlatGEP = Builder.CreateGEP(FlattenedArrayType, GEPInfo.ParentOperand,
+ {Builder.getInt32(0), FlatIndex}, FlatName,
+ GEP.getNoWrapFlags());
+
+ // Store the new GEP in the map before replacing uses to avoid circular
+ // references
GEPChainMap.erase(&GEP);
GEP.replaceAllUsesWith(FlatGEP);
``````````
</details>
https://github.com/llvm/llvm-project/pull/143747
More information about the llvm-commits
mailing list