[llvm] 2ccde3c - [InlineCost] Fix scalable vectors in visitAlloca

Cullen Rhodes via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 17 03:34:57 PDT 2020


Author: Cullen Rhodes
Date: 2020-08-17T10:34:27Z
New Revision: 2ccde3c96b784f74370beff5dab5fbf3e70fae8b

URL: https://github.com/llvm/llvm-project/commit/2ccde3c96b784f74370beff5dab5fbf3e70fae8b
DIFF: https://github.com/llvm/llvm-project/commit/2ccde3c96b784f74370beff5dab5fbf3e70fae8b.diff

LOG: [InlineCost] Fix scalable vectors in visitAlloca

Discovered as part of the VLS type work (see D85128).

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D85848

Added: 
    llvm/test/Transforms/Inline/inline-scalable.ll

Modified: 
    llvm/lib/Analysis/InlineCost.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 33d714406d7f..0a2de5d4ba9b 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -867,7 +867,7 @@ bool CallAnalyzer::visitAlloca(AllocaInst &I) {
       // is needed to track stack usage during inlining.
       Type *Ty = I.getAllocatedType();
       AllocatedSize = SaturatingMultiplyAdd(
-          AllocSize->getLimitedValue(), DL.getTypeAllocSize(Ty).getFixedSize(),
+          AllocSize->getLimitedValue(), DL.getTypeAllocSize(Ty).getKnownMinSize(),
           AllocatedSize);
       if (AllocatedSize > InlineConstants::MaxSimplifiedDynamicAllocaToInline) {
         HasDynamicAlloca = true;
@@ -881,7 +881,7 @@ bool CallAnalyzer::visitAlloca(AllocaInst &I) {
   if (I.isStaticAlloca()) {
     Type *Ty = I.getAllocatedType();
     AllocatedSize =
-        SaturatingAdd(DL.getTypeAllocSize(Ty).getFixedSize(), AllocatedSize);
+        SaturatingAdd(DL.getTypeAllocSize(Ty).getKnownMinSize(), AllocatedSize);
   }
 
   // We will happily inline static alloca instructions.

diff  --git a/llvm/test/Transforms/Inline/inline-scalable.ll b/llvm/test/Transforms/Inline/inline-scalable.ll
new file mode 100644
index 000000000000..756f556a9d2d
--- /dev/null
+++ b/llvm/test/Transforms/Inline/inline-scalable.ll
@@ -0,0 +1,11 @@
+; RUN: opt -S -inline < %s | FileCheck %s
+
+define void @func() {
+; CHECK-LABEL: func
+; CHECK-NEXT:    [[VEC_ADDR:%.*]] = alloca <vscale x 4 x i32>
+; CHECK-NEXT:    call void @func()
+; CHECK-NEXT:    ret void
+  %vec.addr = alloca <vscale x 4 x i32>
+  call void @func();
+  ret void
+}


        


More information about the llvm-commits mailing list