From b5786082568ffca22fc044b79b0e58755c2f931c Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Wed, 15 Apr 2020 15:21:30 +0100 Subject: [PATCH] [DSE,MSSA] Add use of alloca, to guard against removal in the future. Currently the alloca does not escape and all stores and the memset can be removed. Adding a use of the alloca ensures not all stores are eliminated. --- .../Transforms/DeadStoreElimination/MSSA/memset-missing-debugloc.ll | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/llvm/test/Transforms/DeadStoreElimination/MSSA/memset-missing-debugloc.ll b/llvm/test/Transforms/DeadStoreElimination/MSSA/memset-missing-debugloc.ll index 11d155c..80db7f5 100644 --- a/llvm/test/Transforms/DeadStoreElimination/MSSA/memset-missing-debugloc.ll +++ b/llvm/test/Transforms/DeadStoreElimination/MSSA/memset-missing-debugloc.ll @@ -4,6 +4,7 @@ ; RUN: opt -S -march=native -dse -enable-dse-memoryssa < %s| FileCheck %s ; CHECK: bitcast [5 x i64]* %{{[a-zA-Z_][a-zA-Z0-9_]*}} to i8*, !dbg ; CHECK-NEXT: %{{[0-9]+}} = getelementptr inbounds i8, i8* %0, i64 32, !dbg ![[DBG:[0-9]+]] +; CHECK-NEXT: call void @llvm.memset.p0i8.i64(i8* align 16 %1, i8 0, i64 8, i1 false), !dbg ![[DBG:[0-9]+]] ; CHECK: ![[DBG]] = !DILocation(line: 2, ; The test IR is generated by running: @@ -21,6 +22,8 @@ ; } +declare void @use([5 x i64]*) + define dso_local i32 @_Z1av() !dbg !7 { entry: %retval = alloca i32, align 4 @@ -37,6 +40,7 @@ entry: store i64 2, i64* %4, align 16, !dbg !16 %5 = getelementptr inbounds [5 x i64], [5 x i64]* %1, i32 0, i32 3, !dbg !16 store i64 2, i64* %5, align 8, !dbg !16 + call void @use([5 x i64]* %b) %call = call i32 @_Z1av(), !dbg !17 %tobool = icmp ne i32 %call, 0, !dbg !17 br i1 %tobool, label %if.then, label %if.end, !dbg !19 -- 2.7.4