[llvm] Enhance TLI detection of __size_returning_new lib funcs. (PR #102391)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 8 19:30:33 PDT 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 cece4ba5c2eebac414ad4d1028c3220e79403a7a c87dba49dce5d6711920d554c41ddbffa59b0a30 --extensions cpp -- llvm/lib/Analysis/TargetLibraryInfo.cpp llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index 88abb6e717..350d5310e5 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -1049,46 +1049,47 @@ static bool matchType(FuncArgTypeID ArgTy, const Type *Ty, unsigned IntBits,
   llvm_unreachable("Invalid type");
 }
 
-static bool isValidProtoForSizeReturningNew(const FunctionType& FTy, LibFunc F, const Module& M, int SizeTSizeBits) {
+static bool isValidProtoForSizeReturningNew(const FunctionType &FTy, LibFunc F,
+                                            const Module &M,
+                                            int SizeTSizeBits) {
   switch (F) {
-    case LibFunc_size_returning_new: {
-      if(FTy.getNumParams() != 1 || !FTy.getParamType(0)->isIntegerTy(SizeTSizeBits)) {
-        return false;
-      }
+  case LibFunc_size_returning_new: {
+    if (FTy.getNumParams() != 1 ||
+        !FTy.getParamType(0)->isIntegerTy(SizeTSizeBits)) {
+      return false;
     }
-    break;
-    case LibFunc_size_returning_new_hot_cold: {
-      if(FTy.getNumParams() != 2 ||
-         !FTy.getParamType(0)->isIntegerTy(SizeTSizeBits) ||
-         !FTy.getParamType(1)->isIntegerTy(8)) {
-        return false;
-      }
+  } break;
+  case LibFunc_size_returning_new_hot_cold: {
+    if (FTy.getNumParams() != 2 ||
+        !FTy.getParamType(0)->isIntegerTy(SizeTSizeBits) ||
+        !FTy.getParamType(1)->isIntegerTy(8)) {
+      return false;
     }
-    break;
-    case LibFunc_size_returning_new_aligned: {
-      if(FTy.getNumParams() !=2 ||
+  } break;
+  case LibFunc_size_returning_new_aligned: {
+    if (FTy.getNumParams() != 2 ||
         !FTy.getParamType(0)->isIntegerTy(SizeTSizeBits) ||
-         !FTy.getParamType(1)->isIntegerTy(SizeTSizeBits)) {
-        return false;
-      }
+        !FTy.getParamType(1)->isIntegerTy(SizeTSizeBits)) {
+      return false;
     }
-    break;
-    case LibFunc_size_returning_new_aligned_hot_cold:
-      if( FTy.getNumParams() != 3 ||
-          !FTy.getParamType(0)->isIntegerTy(SizeTSizeBits) ||
-         !FTy.getParamType(1)->isIntegerTy(SizeTSizeBits) ||
-         !FTy.getParamType(2)->isIntegerTy(8)) {
-        return false;
-      }
-    break;
-    default:
+  } break;
+  case LibFunc_size_returning_new_aligned_hot_cold:
+    if (FTy.getNumParams() != 3 ||
+        !FTy.getParamType(0)->isIntegerTy(SizeTSizeBits) ||
+        !FTy.getParamType(1)->isIntegerTy(SizeTSizeBits) ||
+        !FTy.getParamType(2)->isIntegerTy(8)) {
       return false;
+    }
+    break;
+  default:
+    return false;
   }
 
-  auto& Context = M.getContext();
+  auto &Context = M.getContext();
   llvm::Type *I8Ty = Type::getInt8Ty(Context);
   llvm::PointerType *I8PtrTy = PointerType::get(I8Ty, 0);
-  llvm::StructType *SizedPtrTy = llvm::StructType::get(Context, {I8PtrTy, Type::getIntNTy(Context, SizeTSizeBits)});
+  llvm::StructType *SizedPtrTy = llvm::StructType::get(
+      Context, {I8PtrTy, Type::getIntNTy(Context, SizeTSizeBits)});
   return FTy.getReturnType() == SizedPtrTy;
 }
 

``````````

</details>


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


More information about the llvm-commits mailing list