[llvm-branch-commits] [llvm] 78c0ea5 - [DAGCombine] Fix TypeSize warning in DAGCombine::visitLIFETIME_END

Joe Ellis via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Dec 3 04:17:22 PST 2020


Author: Joe Ellis
Date: 2020-12-03T12:12:41Z
New Revision: 78c0ea54a22aea5c3ff9030b66d2e1c50ca2c1a3

URL: https://github.com/llvm/llvm-project/commit/78c0ea54a22aea5c3ff9030b66d2e1c50ca2c1a3
DIFF: https://github.com/llvm/llvm-project/commit/78c0ea54a22aea5c3ff9030b66d2e1c50ca2c1a3.diff

LOG: [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

Added: 
    llvm/test/CodeGen/AArch64/dag-combine-lifetime-end-store-typesize.ll

Modified: 
    llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 661e05bdd579..6ce6e1093dc6 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 000000000000..fd5b85a57de1
--- /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(<vscale x 4 x i32>* nocapture dereferenceable(16) %ptr) {
+entry:
+  %tmp = alloca <vscale x 4 x i32>, align 8
+  %tmp_ptr = bitcast <vscale x 4 x i32>* %tmp to i8*
+  call void @llvm.lifetime.start.p0i8(i64 32, i8* %tmp_ptr)
+  store <vscale x 4 x i32> undef, <vscale x 4 x i32>* %ptr
+  call void @llvm.lifetime.end.p0i8(i64 32, i8* %tmp_ptr)
+  ret void
+}


        


More information about the llvm-branch-commits mailing list