brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.7 KiB · 5351878 Raw
114 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 52; RUN: opt -S -passes=gvn < %s | FileCheck --check-prefixes=CHECK,MDEP %s3; RUN: opt -S -passes='gvn<memoryssa>' -verify-analysis-invalidation < %s | FileCheck --check-prefixes=CHECK,MSSA %s4declare i32 @setjmp() returns_twice5declare void @longjmp()6declare ptr @malloc(i64)7 8define i32 @test() {9; CHECK-LABEL: define i32 @test() {10; CHECK-NEXT:    [[MALLOC:%.*]] = call noalias ptr @malloc(i64 4)11; CHECK-NEXT:    store i32 10, ptr [[MALLOC]], align 412; CHECK-NEXT:    [[SJ:%.*]] = call i32 @setjmp()13; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i32 [[SJ]], 014; CHECK-NEXT:    br i1 [[CMP]], label %[[IF_THEN:.*]], label %[[IF_END:.*]]15; CHECK:       [[IF_THEN]]:16; CHECK-NEXT:    store i32 20, ptr [[MALLOC]], align 417; CHECK-NEXT:    call void @longjmp()18; CHECK-NEXT:    unreachable19; CHECK:       [[IF_END]]:20; CHECK-NEXT:    [[RES:%.*]] = load i32, ptr [[MALLOC]], align 421; CHECK-NEXT:    ret i32 [[RES]]22;23  %malloc = call noalias ptr @malloc(i64 4)24  store i32 10, ptr %malloc, align 425  %sj = call i32 @setjmp()26  %cmp = icmp eq i32 %sj, 027  br i1 %cmp, label %if.then, label %if.end28 29if.then:30  store i32 20, ptr %malloc31  call void @longjmp()32  unreachable33 34if.end:35  %res = load i32, ptr %malloc36  ret i32 %res37}38 39; We are still allowed to optimize non-volatile accesses to allocas.40define i32 @test_alloca() {41; MDEP-LABEL: define i32 @test_alloca() {42; MDEP-NEXT:    [[ALLOC:%.*]] = alloca i43, align 843; MDEP-NEXT:    store i32 10, ptr [[ALLOC]], align 444; MDEP-NEXT:    [[SJ:%.*]] = call i32 @setjmp()45; MDEP-NEXT:    [[CMP:%.*]] = icmp eq i32 [[SJ]], 046; MDEP-NEXT:    br i1 [[CMP]], label %[[IF_THEN:.*]], label %[[IF_END:.*]]47; MDEP:       [[IF_THEN]]:48; MDEP-NEXT:    store i32 20, ptr [[ALLOC]], align 449; MDEP-NEXT:    call void @longjmp()50; MDEP-NEXT:    unreachable51; MDEP:       [[IF_END]]:52; MDEP-NEXT:    ret i32 1053;54; MSSA-LABEL: define i32 @test_alloca() {55; MSSA-NEXT:    [[ALLOC:%.*]] = alloca i43, align 856; MSSA-NEXT:    store i32 10, ptr [[ALLOC]], align 457; MSSA-NEXT:    [[SJ:%.*]] = call i32 @setjmp()58; MSSA-NEXT:    [[CMP:%.*]] = icmp eq i32 [[SJ]], 059; MSSA-NEXT:    br i1 [[CMP]], label %[[IF_THEN:.*]], label %[[IF_END:.*]]60; MSSA:       [[IF_THEN]]:61; MSSA-NEXT:    store i32 20, ptr [[ALLOC]], align 462; MSSA-NEXT:    call void @longjmp()63; MSSA-NEXT:    unreachable64; MSSA:       [[IF_END]]:65; MSSA-NEXT:    [[RES:%.*]] = load i32, ptr [[ALLOC]], align 466; MSSA-NEXT:    ret i32 [[RES]]67;68  %alloc = alloca i4369  store i32 10, ptr %alloc, align 470  %sj = call i32 @setjmp()71  %cmp = icmp eq i32 %sj, 072  br i1 %cmp, label %if.then, label %if.end73 74if.then:75  store i32 20, ptr %alloc76  call void @longjmp()77  unreachable78 79if.end:80  %res = load i32, ptr %alloc81  ret i32 %res82}83 84define i32 @test_alloca_volatile() {85; CHECK-LABEL: define i32 @test_alloca_volatile() {86; CHECK-NEXT:    [[ALLOC:%.*]] = alloca i43, align 887; CHECK-NEXT:    store volatile i32 10, ptr [[ALLOC]], align 488; CHECK-NEXT:    [[SJ:%.*]] = call i32 @setjmp()89; CHECK-NEXT:    [[CMP:%.*]] = icmp eq i32 [[SJ]], 090; CHECK-NEXT:    br i1 [[CMP]], label %[[IF_THEN:.*]], label %[[IF_END:.*]]91; CHECK:       [[IF_THEN]]:92; CHECK-NEXT:    store volatile i32 20, ptr [[ALLOC]], align 493; CHECK-NEXT:    call void @longjmp()94; CHECK-NEXT:    unreachable95; CHECK:       [[IF_END]]:96; CHECK-NEXT:    [[RES:%.*]] = load volatile i32, ptr [[ALLOC]], align 497; CHECK-NEXT:    ret i32 [[RES]]98;99  %alloc = alloca i43100  store volatile i32 10, ptr %alloc, align 4101  %sj = call i32 @setjmp()102  %cmp = icmp eq i32 %sj, 0103  br i1 %cmp, label %if.then, label %if.end104 105if.then:106  store volatile i32 20, ptr %alloc107  call void @longjmp()108  unreachable109 110if.end:111  %res = load volatile i32, ptr %alloc112  ret i32 %res113}114