[llvm] RFC: Argpromotion of externally visible functions (PR #87731)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 4 17:10:27 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 ca55ee88263e5b190965c3f14fd3b2647efab26a ebfa8bbb884467da62b199d266a1fe7afd66fb1a -- llvm/include/llvm/Transforms/IPO/ArgumentPromotion.h llvm/lib/Passes/PassBuilderPipelines.cpp llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
``````````

</details>

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

``````````diff
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index 6a58abcc22..765db3bdfa 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -437,7 +437,8 @@ doPromotion(Function *F, FunctionAnalysisManager &FAM,
 /// specified function argument.
 static bool allCallersPassValidPointerForArgument(Argument *Arg,
                                                   Align NeededAlign,
-                                                  uint64_t NeededDerefBytes, bool HasLocalLinkage) {
+                                                  uint64_t NeededDerefBytes,
+                                                  bool HasLocalLinkage) {
   Function *Callee = Arg->getParent();
   const DataLayout &DL = Callee->getParent()->getDataLayout();
   APInt Bytes(64, NeededDerefBytes);
@@ -449,10 +450,10 @@ static bool allCallersPassValidPointerForArgument(Argument *Arg,
   // Look at all call sites of the function.  At this point we know we only have
   // direct callees, unless the function is visible externally.
   return HasLocalLinkage && all_of(Callee->users(), [&](User *U) {
-    CallBase &CB = cast<CallBase>(*U);
-    return isDereferenceableAndAlignedPointer(CB.getArgOperand(Arg->getArgNo()),
-                                              NeededAlign, Bytes, DL);
-  });
+           CallBase &CB = cast<CallBase>(*U);
+           return isDereferenceableAndAlignedPointer(
+               CB.getArgOperand(Arg->getArgNo()), NeededAlign, Bytes, DL);
+         });
 }
 
 /// Generate a wrapper around F that allows F to be argpromoted even if its
@@ -545,7 +546,8 @@ static bool wrapForExternPromotion(Function *F) {
 /// Determine that this argument is safe to promote, and find the argument
 /// parts it can be promoted into.
 static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR,
-                         unsigned MaxElements, bool IsRecursive, bool HasLocalLinkage,
+                         unsigned MaxElements, bool IsRecursive,
+                         bool HasLocalLinkage,
                          SmallVectorImpl<OffsetAndArgPart> &ArgPartsVec) {
   // Quick exit for unused arguments
   if (Arg->use_empty())
@@ -718,8 +720,8 @@ static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR,
 
   if (NeededDerefBytes || NeededAlign > 1) {
     // Try to prove a required deref / aligned requirement.
-    if (!allCallersPassValidPointerForArgument(Arg, NeededAlign,
-                                               NeededDerefBytes, HasLocalLinkage)) {
+    if (!allCallersPassValidPointerForArgument(
+            Arg, NeededAlign, NeededDerefBytes, HasLocalLinkage)) {
       LLVM_DEBUG(dbgs() << "ArgPromotion of " << *Arg << " failed: "
                         << "not dereferenceable or aligned\n");
       return false;
@@ -868,7 +870,8 @@ static Function *promoteArguments(Function *F, FunctionAnalysisManager &FAM,
     // If we can promote the pointer to its value.
     SmallVector<OffsetAndArgPart, 4> ArgParts;
 
-    if (findArgParts(PtrArg, DL, AAR, MaxElements, IsRecursive, F->hasLocalLinkage(), ArgParts)) {
+    if (findArgParts(PtrArg, DL, AAR, MaxElements, IsRecursive,
+                     F->hasLocalLinkage(), ArgParts)) {
       SmallVector<Type *, 4> Types;
       for (const auto &Pair : ArgParts)
         Types.push_back(Pair.second.Ty);

``````````

</details>


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


More information about the llvm-commits mailing list