79 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -S -passes=gvn 2>&1 | FileCheck %s --check-prefixes=CHECK,MDEP3; RUN: opt < %s -S -passes='gvn<memoryssa>' 2>&1 | FileCheck --check-prefixes=CHECK,MSSA %s4 5target 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"6 7declare noalias ptr @malloc(i64) nounwind allockind("alloc,uninitialized") allocsize(0) inaccessiblememonly8declare noalias ptr @calloc(i64, i64) allockind("alloc,zeroed") allocsize(0,1) inaccessiblememonly9declare noalias ptr @_Znwm(i64)10declare void @escape(ptr)11 12define i8 @test_malloc(ptr %p) {13; MDEP-LABEL: @test_malloc(14; MDEP-NEXT: [[OBJ:%.*]] = call ptr @malloc(i64 16)15; MDEP-NEXT: call void @escape(ptr [[OBJ]])16; MDEP-NEXT: ret i8 017;18; MSSA-LABEL: @test_malloc(19; MSSA-NEXT: [[V1:%.*]] = load i8, ptr [[P:%.*]], align 120; MSSA-NEXT: [[OBJ:%.*]] = call ptr @malloc(i64 16)21; MSSA-NEXT: [[V2:%.*]] = load i8, ptr [[P]], align 122; MSSA-NEXT: [[SUB:%.*]] = sub i8 [[V1]], [[V2]]23; MSSA-NEXT: call void @escape(ptr [[OBJ]])24; MSSA-NEXT: ret i8 [[SUB]]25;26 %v1 = load i8, ptr %p27 %obj = call ptr @malloc(i64 16)28 %v2 = load i8, ptr %p29 %sub = sub i8 %v1, %v230 call void @escape(ptr %obj)31 ret i8 %sub32}33 34define i8 @test_calloc(ptr %p) {35; MDEP-LABEL: @test_calloc(36; MDEP-NEXT: [[OBJ:%.*]] = call ptr @calloc(i64 1, i64 16)37; MDEP-NEXT: call void @escape(ptr [[OBJ]])38; MDEP-NEXT: ret i8 039;40; MSSA-LABEL: @test_calloc(41; MSSA-NEXT: [[V1:%.*]] = load i8, ptr [[P:%.*]], align 142; MSSA-NEXT: [[OBJ:%.*]] = call ptr @calloc(i64 1, i64 16)43; MSSA-NEXT: [[V2:%.*]] = load i8, ptr [[P]], align 144; MSSA-NEXT: [[SUB:%.*]] = sub i8 [[V1]], [[V2]]45; MSSA-NEXT: call void @escape(ptr [[OBJ]])46; MSSA-NEXT: ret i8 [[SUB]]47;48 %v1 = load i8, ptr %p49 %obj = call ptr @calloc(i64 1, i64 16)50 %v2 = load i8, ptr %p51 %sub = sub i8 %v1, %v252 call void @escape(ptr %obj)53 ret i8 %sub54}55 56define i8 @test_opnew(ptr %p) {57; MDEP-LABEL: @test_opnew(58; MDEP-NEXT: [[OBJ:%.*]] = call ptr @_Znwm(i64 16)59; MDEP-NEXT: call void @escape(ptr [[OBJ]])60; MDEP-NEXT: ret i8 061;62; MSSA-LABEL: @test_opnew(63; MSSA-NEXT: [[V1:%.*]] = load i8, ptr [[P:%.*]], align 164; MSSA-NEXT: [[OBJ:%.*]] = call ptr @_Znwm(i64 16)65; MSSA-NEXT: [[V2:%.*]] = load i8, ptr [[P]], align 166; MSSA-NEXT: [[SUB:%.*]] = sub i8 [[V1]], [[V2]]67; MSSA-NEXT: call void @escape(ptr [[OBJ]])68; MSSA-NEXT: ret i8 [[SUB]]69;70 %v1 = load i8, ptr %p71 %obj = call ptr @_Znwm(i64 16)72 %v2 = load i8, ptr %p73 %sub = sub i8 %v1, %v274 call void @escape(ptr %obj)75 ret i8 %sub76}77;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:78; CHECK: {{.*}}79