From: Cullen Rhodes Date: Wed, 12 Aug 2020 18:03:46 +0000 (+0000) Subject: [InlineCost] Fix scalable vectors in visitAlloca X-Git-Tag: llvmorg-13-init~14563 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2ccde3c96b784f74370beff5dab5fbf3e70fae8b;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index 33d7144..0a2de5d 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 0000000..756f556 --- /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 +; CHECK-NEXT: call void @func() +; CHECK-NEXT: ret void + %vec.addr = alloca + call void @func(); + ret void +}