[llvm] [GlobalOpt] Check if global gets compared to pointer of different obj. (PR #153789)

via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 15 04:18:05 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/Transforms/Utils/GlobalStatus.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/lib/Transforms/Utils/GlobalStatus.cpp b/llvm/lib/Transforms/Utils/GlobalStatus.cpp
index 2452737e9..f82b45ac8 100644
--- a/llvm/lib/Transforms/Utils/GlobalStatus.cpp
+++ b/llvm/lib/Transforms/Utils/GlobalStatus.cpp
@@ -61,14 +61,17 @@ bool llvm::isSafeToDestroyConstant(const Constant *C) {
   return true;
 }
 
-static bool maybePointerToDifferentObjectRecursive(Value *V, SmallPtrSetImpl<Value *> &Visited) {
+static bool
+maybePointerToDifferentObjectRecursive(Value *V,
+                                       SmallPtrSetImpl<Value *> &Visited) {
   if (!Visited.insert(V).second)
     return false;
 
   if (Visited.size() > 32)
     return true;
 
-  // PtrToInt may be used to construct a pointer to a different object. Loads and calls may return a pointer for a different object.
+  // PtrToInt may be used to construct a pointer to a different object. Loads
+  // and calls may return a pointer for a different object.
   if (isa<PtrToIntInst, LoadInst, CallInst>(V))
     return true;
 
@@ -197,7 +200,7 @@ static bool analyzeGlobalAux(const Value *V, GlobalStatus &GS,
 
         if (VisitedUsers.insert(I).second) {
           for (Value *Op : I->operands())
-            if ( Op != V && maybePointerToDifferentObject(Op))
+            if (Op != V && maybePointerToDifferentObject(Op))
               return true;
         }
       } else if (const MemTransferInst *MTI = dyn_cast<MemTransferInst>(I)) {

``````````

</details>


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


More information about the llvm-commits mailing list