11; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2- ; RUN: opt < %s -S -passes=gvn 2>&1 | FileCheck %s
2+ ; RUN: opt < %s -S -passes=gvn 2>&1 | FileCheck %s --check-prefixes=CHECK,MDEP
3+ ; RUN: opt < %s -S -passes='gvn<memoryssa;no-memdep>' 2>&1 | FileCheck --check-prefixes=CHECK,MSSA %s
34
45target 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"
56
@@ -9,10 +10,18 @@ declare noalias ptr @_Znwm(i64)
910declare void @escape (ptr )
1011
1112define i8 @test_malloc (ptr %p ) {
12- ; CHECK-LABEL: @test_malloc(
13- ; CHECK-NEXT: [[OBJ:%.*]] = call ptr @malloc(i64 16)
14- ; CHECK-NEXT: call void @escape(ptr [[OBJ]])
15- ; CHECK-NEXT: ret i8 0
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 0
17+ ;
18+ ; MSSA-LABEL: @test_malloc(
19+ ; MSSA-NEXT: [[V1:%.*]] = load i8, ptr [[P:%.*]], align 1
20+ ; MSSA-NEXT: [[OBJ:%.*]] = call ptr @malloc(i64 16)
21+ ; MSSA-NEXT: [[V2:%.*]] = load i8, ptr [[P]], align 1
22+ ; MSSA-NEXT: [[SUB:%.*]] = sub i8 [[V1]], [[V2]]
23+ ; MSSA-NEXT: call void @escape(ptr [[OBJ]])
24+ ; MSSA-NEXT: ret i8 [[SUB]]
1625;
1726 %v1 = load i8 , ptr %p
1827 %obj = call ptr @malloc (i64 16 )
@@ -23,10 +32,18 @@ define i8 @test_malloc(ptr %p) {
2332}
2433
2534define i8 @test_calloc (ptr %p ) {
26- ; CHECK-LABEL: @test_calloc(
27- ; CHECK-NEXT: [[OBJ:%.*]] = call ptr @calloc(i64 1, i64 16)
28- ; CHECK-NEXT: call void @escape(ptr [[OBJ]])
29- ; CHECK-NEXT: ret i8 0
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 0
39+ ;
40+ ; MSSA-LABEL: @test_calloc(
41+ ; MSSA-NEXT: [[V1:%.*]] = load i8, ptr [[P:%.*]], align 1
42+ ; MSSA-NEXT: [[OBJ:%.*]] = call ptr @calloc(i64 1, i64 16)
43+ ; MSSA-NEXT: [[V2:%.*]] = load i8, ptr [[P]], align 1
44+ ; MSSA-NEXT: [[SUB:%.*]] = sub i8 [[V1]], [[V2]]
45+ ; MSSA-NEXT: call void @escape(ptr [[OBJ]])
46+ ; MSSA-NEXT: ret i8 [[SUB]]
3047;
3148 %v1 = load i8 , ptr %p
3249 %obj = call ptr @calloc (i64 1 , i64 16 )
@@ -37,10 +54,18 @@ define i8 @test_calloc(ptr %p) {
3754}
3855
3956define i8 @test_opnew (ptr %p ) {
40- ; CHECK-LABEL: @test_opnew(
41- ; CHECK-NEXT: [[OBJ:%.*]] = call ptr @_Znwm(i64 16)
42- ; CHECK-NEXT: call void @escape(ptr [[OBJ]])
43- ; CHECK-NEXT: ret i8 0
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 0
61+ ;
62+ ; MSSA-LABEL: @test_opnew(
63+ ; MSSA-NEXT: [[V1:%.*]] = load i8, ptr [[P:%.*]], align 1
64+ ; MSSA-NEXT: [[OBJ:%.*]] = call ptr @_Znwm(i64 16)
65+ ; MSSA-NEXT: [[V2:%.*]] = load i8, ptr [[P]], align 1
66+ ; MSSA-NEXT: [[SUB:%.*]] = sub i8 [[V1]], [[V2]]
67+ ; MSSA-NEXT: call void @escape(ptr [[OBJ]])
68+ ; MSSA-NEXT: ret i8 [[SUB]]
4469;
4570 %v1 = load i8 , ptr %p
4671 %obj = call ptr @_Znwm (i64 16 )
@@ -49,5 +74,5 @@ define i8 @test_opnew(ptr %p) {
4974 call void @escape (ptr %obj )
5075 ret i8 %sub
5176}
52-
53-
77+ ;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
78+ ; CHECK: {{.*}}
0 commit comments