Commit da52b9c1 authored by Florian Hahn's avatar Florian Hahn
Browse files

[DSE] Add tests for MemorySSA based DSE.

This copies the DSE tests into a MSSA subdirectory to test the MemorySSA
backed DSE implementation, without disturbing the original tests.

Differential Revision: https://reviews.llvm.org/D72145
parent a248fa90
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -87,6 +87,11 @@ EnablePartialStoreMerging("enable-dse-partial-store-merging",
  cl::init(true), cl::Hidden,
  cl::desc("Enable partial store merging in DSE"));

// Temporary dummy option for tests.
static cl::opt<bool>
    EnableMemorySSA("enable-dse-memoryssa", cl::init(false), cl::Hidden,
                    cl::desc("Use the new MemorySSA-backed DSE."));

//===----------------------------------------------------------------------===//
// Helper functions
//===----------------------------------------------------------------------===//
+23 −0
Original line number Diff line number Diff line
; RUN: opt < %s -basicaa -dse -enable-dse-memoryssa -S | FileCheck %s
; PR9561
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32"
target triple = "i386-apple-darwin9.8"

@A = external global [0 x i32]

declare ghccc void @Func2(i32*, i32*, i32*, i32)

define ghccc void @Func1(i32* noalias %Arg1, i32* noalias %Arg2, i32* %Arg3, i32 %Arg4) {
entry:
  store i32 add (i32 ptrtoint ([0 x i32]* @A to i32), i32 1), i32* %Arg2
; CHECK: store i32 add (i32 ptrtoint ([0 x i32]* @A to i32), i32 1), i32* %Arg2
  %ln2gz = getelementptr i32, i32* %Arg1, i32 14
  %ln2gA = bitcast i32* %ln2gz to double*
  %ln2gB = load double, double* %ln2gA
  %ln2gD = getelementptr i32, i32* %Arg2, i32 -3
  %ln2gE = bitcast i32* %ln2gD to double*
  store double %ln2gB, double* %ln2gE
; CHECK: store double %ln2gB, double* %ln2gE
  tail call ghccc void @Func2(i32* %Arg1, i32* %Arg2, i32* %Arg3, i32 %Arg4) nounwind
  ret void
}
+23 −0
Original line number Diff line number Diff line
; RUN: opt -dse -enable-dse-memoryssa -S < %s | FileCheck %s

target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-apple-darwin"

%"class.std::auto_ptr" = type { i32* }

; CHECK-LABEL: @_Z3foov(
define void @_Z3foov(%"class.std::auto_ptr"* noalias nocapture sret %agg.result) uwtable ssp {
_ZNSt8auto_ptrIiED1Ev.exit:
  %temp.lvalue = alloca %"class.std::auto_ptr", align 8
  call void @_Z3barv(%"class.std::auto_ptr"* sret %temp.lvalue)
  %_M_ptr.i.i = getelementptr inbounds %"class.std::auto_ptr", %"class.std::auto_ptr"* %temp.lvalue, i64 0, i32 0
  %tmp.i.i = load i32*, i32** %_M_ptr.i.i, align 8
; CHECK-NOT: store i32* null
  store i32* null, i32** %_M_ptr.i.i, align 8
  %_M_ptr.i.i4 = getelementptr inbounds %"class.std::auto_ptr", %"class.std::auto_ptr"* %agg.result, i64 0, i32 0
  store i32* %tmp.i.i, i32** %_M_ptr.i.i4, align 8
; CHECK: ret void
  ret void
}

declare void @_Z3barv(%"class.std::auto_ptr"* sret)
+85 −0
Original line number Diff line number Diff line
; RUN: opt -dse -enable-dse-memoryssa -S < %s | FileCheck %s
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-f128:128:128-n8:16:32:64"
target triple = "x86_64-unknown-linux-gnu"

%struct.pair.162 = type { %struct.BasicBlock*, i32, [4 x i8] }
%struct.BasicBlock = type { %struct.Value, %struct.ilist_node.24, %struct.iplist.22, %struct.Function* }
%struct.Value = type { i32 (...)**, i8, i8, i16, %struct.Type*, %struct.Use*, %struct.StringMapEntry* }
%struct.Type = type { %struct.LLVMContext*, i8, [3 x i8], i32, {}* }
%struct.LLVMContext = type { %struct.LLVMContextImpl* }
%struct.LLVMContextImpl = type opaque
%struct.Use = type { %struct.Value*, %struct.Use*, %struct.PointerIntPair }
%struct.PointerIntPair = type { i64 }
%struct.StringMapEntry = type opaque
%struct.ilist_node.24 = type { %struct.ilist_half_node.23, %struct.BasicBlock* }
%struct.ilist_half_node.23 = type { %struct.BasicBlock* }
%struct.iplist.22 = type { %struct.ilist_traits.21, %struct.Instruction* }
%struct.ilist_traits.21 = type { %struct.ilist_half_node.25 }
%struct.ilist_half_node.25 = type { %struct.Instruction* }
%struct.Instruction = type { [52 x i8], %struct.ilist_node.26, %struct.BasicBlock*, %struct.DebugLoc }
%struct.ilist_node.26 = type { %struct.ilist_half_node.25, %struct.Instruction* }
%struct.DebugLoc = type { i32, i32 }
%struct.Function = type { %struct.GlobalValue, %struct.ilist_node.14, %struct.iplist.4, %struct.iplist, %struct.ValueSymbolTable*, %struct.AttrListPtr }
%struct.GlobalValue = type <{ [52 x i8], [4 x i8], %struct.Module*, i8, i16, [5 x i8], %struct.basic_string }>
%struct.Module = type { %struct.LLVMContext*, %struct.iplist.20, %struct.iplist.16, %struct.iplist.12, %struct.vector.2, %struct.ilist, %struct.basic_string, %struct.ValueSymbolTable*, %struct.OwningPtr, %struct.basic_string, %struct.basic_string, %struct.basic_string, i8* }
%struct.iplist.20 = type { %struct.ilist_traits.19, %struct.GlobalVariable* }
%struct.ilist_traits.19 = type { %struct.ilist_node.18 }
%struct.ilist_node.18 = type { %struct.ilist_half_node.17, %struct.GlobalVariable* }
%struct.ilist_half_node.17 = type { %struct.GlobalVariable* }
%struct.GlobalVariable = type { %struct.GlobalValue, %struct.ilist_node.18, i8, [7 x i8] }
%struct.iplist.16 = type { %struct.ilist_traits.15, %struct.Function* }
%struct.ilist_traits.15 = type { %struct.ilist_node.14 }
%struct.ilist_node.14 = type { %struct.ilist_half_node.13, %struct.Function* }
%struct.ilist_half_node.13 = type { %struct.Function* }
%struct.iplist.12 = type { %struct.ilist_traits.11, %struct.GlobalAlias* }
%struct.ilist_traits.11 = type { %struct.ilist_node.10 }
%struct.ilist_node.10 = type { %struct.ilist_half_node.9, %struct.GlobalAlias* }
%struct.ilist_half_node.9 = type { %struct.GlobalAlias* }
%struct.GlobalAlias = type { %struct.GlobalValue, %struct.ilist_node.10 }
%struct.vector.2 = type { %struct._Vector_base.1 }
%struct._Vector_base.1 = type { %struct._Vector_impl.0 }
%struct._Vector_impl.0 = type { %struct.basic_string*, %struct.basic_string*, %struct.basic_string* }
%struct.basic_string = type { %struct._Alloc_hider }
%struct._Alloc_hider = type { i8* }
%struct.ilist = type { %struct.iplist.8 }
%struct.iplist.8 = type { %struct.ilist_traits.7, %struct.NamedMDNode* }
%struct.ilist_traits.7 = type { %struct.ilist_node.6 }
%struct.ilist_node.6 = type { %struct.ilist_half_node.5, %struct.NamedMDNode* }
%struct.ilist_half_node.5 = type { %struct.NamedMDNode* }
%struct.NamedMDNode = type { %struct.ilist_node.6, %struct.basic_string, %struct.Module*, i8* }
%struct.ValueSymbolTable = type opaque
%struct.OwningPtr = type { %struct.GVMaterializer* }
%struct.GVMaterializer = type opaque
%struct.iplist.4 = type { %struct.ilist_traits.3, %struct.BasicBlock* }
%struct.ilist_traits.3 = type { %struct.ilist_half_node.23 }
%struct.iplist = type { %struct.ilist_traits, %struct.Argument* }
%struct.ilist_traits = type { %struct.ilist_half_node }
%struct.ilist_half_node = type { %struct.Argument* }
%struct.Argument = type { %struct.Value, %struct.ilist_node, %struct.Function* }
%struct.ilist_node = type { %struct.ilist_half_node, %struct.Argument* }
%struct.AttrListPtr = type { %struct.AttributeListImpl* }
%struct.AttributeListImpl = type opaque

declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i1) nounwind

; CHECK: _ZSt9iter_swapIPSt4pairIPN4llvm10BasicBlockEjES5_EvT_T0_
; CHECK: store
; CHECK: ret void
define void @_ZSt9iter_swapIPSt4pairIPN4llvm10BasicBlockEjES5_EvT_T0_(%struct.pair.162* %__a, %struct.pair.162* %__b) nounwind uwtable inlinehint {
entry:
  %memtmp = alloca %struct.pair.162, align 8
  %0 = getelementptr inbounds %struct.pair.162, %struct.pair.162* %memtmp, i64 0, i32 0
  %1 = getelementptr inbounds %struct.pair.162, %struct.pair.162* %__a, i64 0, i32 0
  %2 = load %struct.BasicBlock*, %struct.BasicBlock** %1, align 8
  store %struct.BasicBlock* %2, %struct.BasicBlock** %0, align 8
  %3 = getelementptr inbounds %struct.pair.162, %struct.pair.162* %memtmp, i64 0, i32 1
  %4 = getelementptr inbounds %struct.pair.162, %struct.pair.162* %__a, i64 0, i32 1
  %5 = load i32, i32* %4, align 4
  store i32 %5, i32* %3, align 8
  %6 = bitcast %struct.pair.162* %__a to i8*
  %7 = bitcast %struct.pair.162* %__b to i8*
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %6, i8* %7, i64 12, i1 false)
  %8 = bitcast %struct.pair.162* %memtmp to i8*
  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %7, i8* %8, i64 12, i1 false)
  ret void
}
+33 −0
Original line number Diff line number Diff line
; XFAIL: *
; RUN: opt < %s -basicaa -dse-enable-dse-memoryssa  -S -enable-dse-partial-overwrite-tracking | FileCheck %s
; PR28588

target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: nounwind
define void @_UPT_destroy(i8* nocapture %ptr) local_unnamed_addr #0 {
entry:
  %edi = getelementptr inbounds i8, i8* %ptr, i64 8

; CHECK-NOT: tail call void @llvm.memset.p0i8.i64(i8* align 8 %edi, i8 0, i64 176, i1 false)
; CHECK-NOT: store i32 -1, i32* %addr

  tail call void @llvm.memset.p0i8.i64(i8* align 8 %edi, i8 0, i64 176, i1 false)
  %format4.i = getelementptr inbounds i8, i8* %ptr, i64 144
  %addr = bitcast i8* %format4.i to i32*
  store i32 -1, i32* %addr, align 8

; CHECK: tail call void @free
  tail call void @free(i8* nonnull %ptr)
  ret void
}

; Function Attrs: nounwind
declare void @free(i8* nocapture) local_unnamed_addr #0

; Function Attrs: argmemonly nounwind
declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1) #1

attributes #0 = { nounwind }
attributes #1 = { argmemonly nounwind }
Loading