[clang] [llvm] [mlir] Fix mismatches between function parameter definitions and declarations (PR #89512)

Troy Butler via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 23 12:27:25 PDT 2024


https://github.com/Troy-Butler updated https://github.com/llvm/llvm-project/pull/89512

>From f03466fa44a3c7210e7590e6305bc0c9f9aeb446 Mon Sep 17 00:00:00 2001
From: Troy-Butler <squintik at outlook.com>
Date: Sat, 20 Apr 2024 15:13:09 -0400
Subject: [PATCH 1/5] Fix Definition-Declaration Mismatches

Signed-off-by: Troy-Butler <squintik at outlook.com>
---
 .../include/clang/StaticAnalyzer/Core/PathSensitive/Store.h | 4 ++--
 llvm/lib/Transforms/InstCombine/InstCombineInternal.h       | 2 +-
 llvm/lib/Transforms/Vectorize/VPlan.h                       | 4 ++--
 .../SparseTensor/Transforms/Utils/SparseTensorIterator.h    | 6 +++---
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
index fac0c04ae2caab..e60a49f68b7a0d 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
@@ -227,12 +227,12 @@ class StoreManager {
   ///   information will not be used.
   virtual StoreRef invalidateRegions(Store store,
                                   ArrayRef<SVal> Values,
-                                  const Expr *E, unsigned Count,
+                                  const Expr *Ex, unsigned Count,
                                   const LocationContext *LCtx,
                                   const CallEvent *Call,
                                   InvalidatedSymbols &IS,
                                   RegionAndSymbolInvalidationTraits &ITraits,
-                                  InvalidatedRegions *InvalidatedTopLevel,
+                                  InvalidatedRegions *TopLevelRegions,
                                   InvalidatedRegions *Invalidated) = 0;
 
   /// enterStackFrame - Let the StoreManager to do something when execution
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
index 4479afbd09afde..4ec5f417998273 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -433,7 +433,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
   Value *foldAndOrOfICmpsOfAndWithPow2(ICmpInst *LHS, ICmpInst *RHS,
                                        Instruction *CxtI, bool IsAnd,
                                        bool IsLogical = false);
-  Value *matchSelectFromAndOr(Value *A, Value *B, Value *C, Value *D,
+  Value *matchSelectFromAndOr(Value *A, Value *C, Value *B, Value *D,
                               bool InvertFalseVal = false);
   Value *getSelectCondition(Value *A, Value *B, bool ABIsTheSame);
 
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index c74329a0bcc4ac..21b088cd238660 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -3278,8 +3278,8 @@ class VPlan {
 private:
   /// Add to the given dominator tree the header block and every new basic block
   /// that was created between it and the latch block, inclusive.
-  static void updateDominatorTree(DominatorTree *DT, BasicBlock *LoopLatchBB,
-                                  BasicBlock *LoopPreHeaderBB,
+  static void updateDominatorTree(DominatorTree *DT, BasicBlock *LoopHeaderBB,
+                                  BasicBlock *LoopLatchBB,
                                   BasicBlock *LoopExitBB);
 };
 
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorIterator.h b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorIterator.h
index 9d69a233555986..38f8c8423fd16f 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorIterator.h
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorIterator.h
@@ -284,9 +284,9 @@ class SparseIterator {
 };
 
 /// Helper function to create a TensorLevel object from given `tensor`.
-std::unique_ptr<SparseTensorLevel> makeSparseTensorLevel(OpBuilder &builder,
-                                                         Location loc, Value t,
-                                                         unsigned tid, Level l);
+std::unique_ptr<SparseTensorLevel> makeSparseTensorLevel(OpBuilder &b,
+                                                         Location l, Value t,
+                                                         unsigned tid, Level lvl);
 
 /// Helper function to create a simple SparseIterator object that iterate over
 /// the SparseTensorLevel.

>From 4fe63ddecc056bc521d439952fb2b7fc5d83d9b6 Mon Sep 17 00:00:00 2001
From: Troy-Butler <squintik at outlook.com>
Date: Sat, 20 Apr 2024 15:33:43 -0400
Subject: [PATCH 2/5] Fix Code Formatting Issues

Signed-off-by: Troy-Butler <squintik at outlook.com>
---
 .../StaticAnalyzer/Core/PathSensitive/Store.h      | 14 +++++---------
 .../Transforms/Utils/SparseTensorIterator.h        |  3 ++-
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
index e60a49f68b7a0d..ef23b160a3c032 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
@@ -225,15 +225,11 @@ class StoreManager {
   ///   invalidated. This should include any regions explicitly invalidated
   ///   even if they do not currently have bindings. Pass \c NULL if this
   ///   information will not be used.
-  virtual StoreRef invalidateRegions(Store store,
-                                  ArrayRef<SVal> Values,
-                                  const Expr *Ex, unsigned Count,
-                                  const LocationContext *LCtx,
-                                  const CallEvent *Call,
-                                  InvalidatedSymbols &IS,
-                                  RegionAndSymbolInvalidationTraits &ITraits,
-                                  InvalidatedRegions *TopLevelRegions,
-                                  InvalidatedRegions *Invalidated) = 0;
+  virtual StoreRef invalidateRegions(
+      Store store, ArrayRef<SVal> Values, const Expr *Ex, unsigned Count,
+      const LocationContext *LCtx, const CallEvent *Call,
+      InvalidatedSymbols &IS, RegionAndSymbolInvalidationTraits &ITraits,
+      InvalidatedRegions *TopLevelRegions, InvalidatedRegions *Invalidated) = 0;
 
   /// enterStackFrame - Let the StoreManager to do something when execution
   /// engine is about to execute into a callee.
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorIterator.h b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorIterator.h
index 38f8c8423fd16f..0a8d0230e2b004 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorIterator.h
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorIterator.h
@@ -286,7 +286,8 @@ class SparseIterator {
 /// Helper function to create a TensorLevel object from given `tensor`.
 std::unique_ptr<SparseTensorLevel> makeSparseTensorLevel(OpBuilder &b,
                                                          Location l, Value t,
-                                                         unsigned tid, Level lvl);
+                                                         unsigned tid, 
+                                                         Level lvl);
 
 /// Helper function to create a simple SparseIterator object that iterate over
 /// the SparseTensorLevel.

>From f7e7f51a85db5f4a2a7a750bf2f17471c366711f Mon Sep 17 00:00:00 2001
From: Troy-Butler <squintik at outlook.com>
Date: Sat, 20 Apr 2024 15:38:10 -0400
Subject: [PATCH 3/5] Remove trailing whitespace

Signed-off-by: Troy-Butler <squintik at outlook.com>
---
 .../SparseTensor/Transforms/Utils/SparseTensorIterator.h        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorIterator.h b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorIterator.h
index 0a8d0230e2b004..46b923250dd893 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorIterator.h
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorIterator.h
@@ -286,7 +286,7 @@ class SparseIterator {
 /// Helper function to create a TensorLevel object from given `tensor`.
 std::unique_ptr<SparseTensorLevel> makeSparseTensorLevel(OpBuilder &b,
                                                          Location l, Value t,
-                                                         unsigned tid, 
+                                                         unsigned tid,
                                                          Level lvl);
 
 /// Helper function to create a simple SparseIterator object that iterate over

>From 2282268f4472c7181724a0c90ecf9819f92627b3 Mon Sep 17 00:00:00 2001
From: Troy-Butler <squintik at outlook.com>
Date: Tue, 23 Apr 2024 15:19:08 -0400
Subject: [PATCH 4/5] Fix instCombineAndOrXor parameter names

Signed-off-by: Troy-Butler <squintik at outlook.com>
---
 .../InstCombine/InstCombineAndOrXor.cpp       | 32 +++++++++----------
 .../InstCombine/InstCombineInternal.h         |  2 +-
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index e1923a3441790a..38ce0f393cda1f 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -3141,24 +3141,24 @@ Value *InstCombinerImpl::getSelectCondition(Value *A, Value *B,
   return nullptr;
 }
 
-/// We have an expression of the form (A & C) | (B & D). Try to simplify this
-/// to "A' ? C : D", where A' is a boolean or vector of booleans.
+/// We have an expression of the form (A & B) | (C & D). Try to simplify this
+/// to "A' ? B : D", where A' is a boolean or vector of booleans.
 /// When InvertFalseVal is set to true, we try to match the pattern
-/// where we have peeked through a 'not' op and A and B are the same:
-/// (A & C) | ~(A | D) --> (A & C) | (~A & ~D) --> A' ? C : ~D
-Value *InstCombinerImpl::matchSelectFromAndOr(Value *A, Value *C, Value *B,
-                                              Value *D, bool InvertFalseVal) {
+/// where we have peeked through a 'not' op and A and C are the same:
+/// (A & B) | ~(A | D) --> (A & B) | (~A & ~D) --> A' ? B : ~D
+Value *InstCombinerImpl::matchSelectFromAndOr(Value *valA, Value *valB, Value *valC,
+                                              Value *valD, bool InvertFalseVal) {
   // The potential condition of the select may be bitcasted. In that case, look
   // through its bitcast and the corresponding bitcast of the 'not' condition.
-  Type *OrigType = A->getType();
-  A = peekThroughBitcast(A, true);
-  B = peekThroughBitcast(B, true);
-  if (Value *Cond = getSelectCondition(A, B, InvertFalseVal)) {
-    // ((bc Cond) & C) | ((bc ~Cond) & D) --> bc (select Cond, (bc C), (bc D))
+  Type *OrigType = valA->getType();
+  valA = peekThroughBitcast(valA, true);
+  valC = peekThroughBitcast(valC, true);
+  if (Value *Cond = getSelectCondition(valA, valC, InvertFalseVal)) {
+    // ((bc Cond) & B) | ((bc ~Cond) & D) --> bc (select Cond, (bc B), (bc D))
     // If this is a vector, we may need to cast to match the condition's length.
     // The bitcasts will either all exist or all not exist. The builder will
     // not create unnecessary casts if the types already match.
-    Type *SelTy = A->getType();
+    Type *SelTy = valA->getType();
     if (auto *VecTy = dyn_cast<VectorType>(Cond->getType())) {
       // For a fixed or scalable vector get N from <{vscale x} N x iM>
       unsigned Elts = VecTy->getElementCount().getKnownMinValue();
@@ -3168,11 +3168,11 @@ Value *InstCombinerImpl::matchSelectFromAndOr(Value *A, Value *C, Value *B,
       Type *EltTy = Builder.getIntNTy(SelEltSize / Elts);
       SelTy = VectorType::get(EltTy, VecTy->getElementCount());
     }
-    Value *BitcastC = Builder.CreateBitCast(C, SelTy);
+    Value *BitcastB = Builder.CreateBitCast(valB, SelTy);
     if (InvertFalseVal)
-      D = Builder.CreateNot(D);
-    Value *BitcastD = Builder.CreateBitCast(D, SelTy);
-    Value *Select = Builder.CreateSelect(Cond, BitcastC, BitcastD);
+      valD = Builder.CreateNot(valD);
+    Value *BitcastD = Builder.CreateBitCast(valD, SelTy);
+    Value *Select = Builder.CreateSelect(Cond, BitcastB, BitcastD);
     return Builder.CreateBitCast(Select, OrigType);
   }
 
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
index 4ec5f417998273..3006d083184e22 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -433,7 +433,7 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
   Value *foldAndOrOfICmpsOfAndWithPow2(ICmpInst *LHS, ICmpInst *RHS,
                                        Instruction *CxtI, bool IsAnd,
                                        bool IsLogical = false);
-  Value *matchSelectFromAndOr(Value *A, Value *C, Value *B, Value *D,
+  Value *matchSelectFromAndOr(Value *valA, Value *valB, Value *valC, Value *valD,
                               bool InvertFalseVal = false);
   Value *getSelectCondition(Value *A, Value *B, bool ABIsTheSame);
 

>From b1e5b710023ba94cc06c485d3c22de2a521f2a17 Mon Sep 17 00:00:00 2001
From: Troy-Butler <squintik at outlook.com>
Date: Tue, 23 Apr 2024 15:27:03 -0400
Subject: [PATCH 5/5] Adjust code formatting

Signed-off-by: Troy-Butler <squintik at outlook.com>
---
 llvm/lib/Transforms/InstCombine/InstCombineInternal.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
index 3006d083184e22..aba08f11ca1902 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
+++ b/llvm/lib/Transforms/InstCombine/InstCombineInternal.h
@@ -433,8 +433,8 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
   Value *foldAndOrOfICmpsOfAndWithPow2(ICmpInst *LHS, ICmpInst *RHS,
                                        Instruction *CxtI, bool IsAnd,
                                        bool IsLogical = false);
-  Value *matchSelectFromAndOr(Value *valA, Value *valB, Value *valC, Value *valD,
-                              bool InvertFalseVal = false);
+  Value *matchSelectFromAndOr(Value *valA, Value *valB, Value *valC,
+                              Value *valD, bool InvertFalseVal = false);
   Value *getSelectCondition(Value *A, Value *B, bool ABIsTheSame);
 
   Instruction *foldLShrOverflowBit(BinaryOperator &I);



More information about the llvm-commits mailing list