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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 28 00:28:13 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
----------------
nikic wrote:

It's still a "static alloca" as far as LLVM terminology is concerned.

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


More information about the llvm-commits mailing list