From 78c0ea54a22aea5c3ff9030b66d2e1c50ca2c1a3 Mon Sep 17 00:00:00 2001 From: Joe Ellis Date: Wed, 2 Dec 2020 14:02:47 +0000 Subject: [PATCH] [DAGCombine] Fix TypeSize warning in DAGCombine::visitLIFETIME_END Bail out early if we encounter a scalable store. Reviewed By: peterwaller-arm Differential Revision: https://reviews.llvm.org/D92392 --- llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 7 ++++++- .../dag-combine-lifetime-end-store-typesize.ll | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 llvm/test/CodeGen/AArch64/dag-combine-lifetime-end-store-typesize.ll diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 661e05b..6ce6e10 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -17607,11 +17607,16 @@ SDValue DAGCombiner::visitLIFETIME_END(SDNode *N) { // TODO: Can relax for unordered atomics (see D66309) if (!ST->isSimple() || ST->isIndexed()) continue; + const TypeSize StoreSize = ST->getMemoryVT().getStoreSize(); + // The bounds of a scalable store are not known until runtime, so this + // store cannot be elided. + if (StoreSize.isScalable()) + continue; const BaseIndexOffset StoreBase = BaseIndexOffset::match(ST, DAG); // If we store purely within object bounds just before its lifetime ends, // we can remove the store. if (LifetimeEndBase.contains(DAG, LifetimeEnd->getSize() * 8, StoreBase, - ST->getMemoryVT().getStoreSizeInBits())) { + StoreSize.getFixedSize() * 8)) { LLVM_DEBUG(dbgs() << "\nRemoving store:"; StoreBase.dump(); dbgs() << "\nwithin LIFETIME_END of : "; LifetimeEndBase.dump(); dbgs() << "\n"); diff --git a/llvm/test/CodeGen/AArch64/dag-combine-lifetime-end-store-typesize.ll b/llvm/test/CodeGen/AArch64/dag-combine-lifetime-end-store-typesize.ll new file mode 100644 index 0000000..fd5b85a --- /dev/null +++ b/llvm/test/CodeGen/AArch64/dag-combine-lifetime-end-store-typesize.ll @@ -0,0 +1,21 @@ +; RUN: llc -mtriple=aarch64-- < %s 2>&1 | FileCheck --allow-empty %s + +; This regression test is defending against a TypeSize warning 'assumption that TypeSize is not +; scalable'. This warning appeared in DAGCombiner::visitLIFETIME_END when visiting a LIFETIME_END +; node linked to a scalable store. + +; If this check fails please read test/CodeGen/AArch64/README for instructions on how to resolve it. +; CHECK-NOT: warning: {{.*}}TypeSize is not scalable + +declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) +declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) + +define void @foo(* nocapture dereferenceable(16) %ptr) { +entry: + %tmp = alloca , align 8 + %tmp_ptr = bitcast * %tmp to i8* + call void @llvm.lifetime.start.p0i8(i64 32, i8* %tmp_ptr) + store undef, * %ptr + call void @llvm.lifetime.end.p0i8(i64 32, i8* %tmp_ptr) + ret void +} -- 2.7.4