[llvm] [InlineCost] Replace getAllocatedType with getAllocationSize (PR #178355)

Jameson Nash via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 29 07:46:39 PST 2026


================
@@ -1602,19 +1602,21 @@ bool CallAnalyzer::visitAlloca(AllocaInst &I) {
     }
   }
 
-  // Accumulate the allocated size.
   if (I.isStaticAlloca()) {
-    Type *Ty = I.getAllocatedType();
-    AllocatedSize = SaturatingAdd(DL.getTypeAllocSize(Ty).getKnownMinValue(),
-                                  AllocatedSize);
-  }
-
-  // FIXME: This is overly conservative. Dynamic allocas are inefficient for
-  // a variety of reasons, and so we would like to not inline them into
-  // functions which don't currently have a dynamic alloca. This simply
-  // disables inlining altogether in the presence of a dynamic alloca.
-  if (!I.isStaticAlloca())
+    // Accumulate the allocated size if constant and executed once.
+    // Note: if AllocSize is a vscale value, this is a non-static alloca, but
+    // is not considered a dynamic alloca since it is only allocated at the top
+    // of the function, and using vscale should not deter inlining.
----------------
vtjnash wrote:

Great feedback–I rewrote this to clarify that this comment is a statement that this is known to not deter inlining as much as expected for the equivalent non-vscale alloca.

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


More information about the llvm-commits mailing list