[llvm] [InferAddressSpaces] apply InferAddressSpaces to inttoptr-zext-ptrtoint address expression. (PR #79108)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 22 23:57:03 PST 2024


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 ab32a3c166e9eae12260b4c6eca9bcf21f500e87 2ea244c1ddddd2d1c79d431d71870024ec235aa2 -- llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
index 2b1229a115..b2008576e5 100644
--- a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
+++ b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
@@ -311,11 +311,14 @@ static bool isZExtPtrIntCastPair(const Operator *I2P, const DataLayout &DL) {
     return false;
   unsigned P2IOp0AS = P2I->getOperand(0)->getType()->getPointerAddressSpace();
   unsigned I2PAS = I2P->getType()->getPointerAddressSpace();
-  unsigned P2IOp0SizeInBits = DL.getIntPtrType(P2I->getOperand(0)->getType())->getScalarSizeInBits();
-  unsigned I2PSizeInBits = DL.getIntPtrType(I2P->getType())->getScalarSizeInBits();
+  unsigned P2IOp0SizeInBits =
+      DL.getIntPtrType(P2I->getOperand(0)->getType())->getScalarSizeInBits();
+  unsigned I2PSizeInBits =
+      DL.getIntPtrType(I2P->getType())->getScalarSizeInBits();
   // Check:
   // 1. `inttoptr` and `ptrtoint` are no-op casts
-  // 2. src address pointer and dst address pointer should be different address space and different size
+  // 2. src address pointer and dst address pointer should be different address
+  // space and different size
   return CastInst::isNoopCast(Instruction::CastOps(I2P->getOpcode()),
                               I2P->getOperand(0)->getType(), I2P->getType(),
                               DL) &&
@@ -349,8 +352,7 @@ static bool isAddressExpression(const Value &V, const DataLayout &DL,
     return II && II->getIntrinsicID() == Intrinsic::ptrmask;
   }
   case Instruction::IntToPtr:
-    return isNoopPtrIntCastPair(Op, DL, TTI) ||
-           isZExtPtrIntCastPair(Op, DL);
+    return isNoopPtrIntCastPair(Op, DL, TTI) || isZExtPtrIntCastPair(Op, DL);
   default:
     // That value is an address expression if it has an assumed address space.
     return TTI->getAssumedAddrSpace(&V) != UninitializedAddressSpace;

``````````

</details>


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


More information about the llvm-commits mailing list