brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.9 KiB · 35d977f Raw
138 lines · c
1// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir2// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR3// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -fclangir -emit-llvm %s -o %t-cir.ll4// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM5// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -Wno-unused-value -emit-llvm %s -o %t.ll6// RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG7 8struct S {9  int x;10  int y;11};12 13void f1(struct S);14void f2(void) {15  struct S s;16  f1(s);17}18 19// CIR-LABEL: cir.func{{.*}} @f2(){{.*}} {20// CIR:         %[[S:.+]] = cir.load align(4) %{{.+}} : !cir.ptr<!rec_S>, !rec_S21// CIR-NEXT:    cir.call @f1(%[[S]]) : (!rec_S) -> ()22 23// LLVM-LABEL: define{{.*}} void @f2(){{.*}}24// LLVM:         %[[S:.+]] = load %struct.S, ptr %{{.+}}, align 425// LLVM-NEXT:    call void @f1(%struct.S %[[S]])26 27// OGCG-LABEL: define{{.*}} void @f2()28// OGCG:         %[[S:.+]] = load i64, ptr %{{.+}}, align 429// OGCG-NEXT:    call void @f1(i64 %[[S]])30 31struct S f3(void);32void f4(void) {33  struct S s = f3();34}35 36// CIR-LABEL: cir.func{{.*}} @f4(){{.*}} {37// CIR:         %[[S:.+]] = cir.call @f3() : () -> !rec_S38// CIR-NEXT:    cir.store align(4) %[[S]], %{{.+}} : !rec_S, !cir.ptr<!rec_S>39 40// LLVM-LABEL: define{{.*}} void @f4(){{.*}} {41// LLVM:         %[[S:.+]] = call %struct.S @f3()42// LLVM-NEXT:    store %struct.S %[[S]], ptr %{{.+}}, align 443 44// OGCG-LABEL: define{{.*}} void @f4() #0 {45// OGCG:         %[[S:.+]] = call i64 @f3()46// OGCG-NEXT:    store i64 %[[S]], ptr %{{.+}}, align 447 48struct Big {49  int data[10];50};51 52void f5(struct Big);53struct Big f6(void);54 55void f7(void) {56  struct Big b;57  f5(b);58}59 60// CIR-LABEL: cir.func{{.*}} @f7(){{.*}} {61// CIR:         %[[B:.+]] = cir.load align(4) %{{.+}} : !cir.ptr<!rec_Big>, !rec_Big62// CIR-NEXT:    cir.call @f5(%[[B]]) : (!rec_Big) -> ()63 64// LLVM-LABEL: define{{.*}} void @f7(){{.*}} {65// LLVM:         %[[B:.+]] = load %struct.Big, ptr %{{.+}}, align 466// LLVM-NEXT:    call void @f5(%struct.Big %[[B]])67 68// OGCG-LABEL: define{{.*}} void @f7() #0 {69// OGCG:         %[[B:.+]] = alloca %struct.Big, align 870// OGCG-NEXT:    call void @f5(ptr noundef byval(%struct.Big) align 8 %[[B]])71 72void f8(void) {73  struct Big b = f6();74}75 76// CIR-LABEL: cir.func{{.*}} @f8(){{.*}} {77// CIR:         %[[B:.+]] = cir.call @f6() : () -> !rec_Big78// CIR:         cir.store align(4) %[[B]], %{{.+}} : !rec_Big, !cir.ptr<!rec_Big>79 80// LLVM-LABEL: define{{.*}} void @f8(){{.*}} {81// LLVM:        %[[B:.+]] = call %struct.Big @f6()82// LLVM-NEXT:   store %struct.Big %[[B]], ptr %{{.+}}, align 483 84// OGCG-LABEL: define{{.*}} void @f8() #0 {85// OGCG:         %[[B:.+]] = alloca %struct.Big, align 486// OGCG-NEXT:    call void @f6(ptr dead_on_unwind writable sret(%struct.Big) align 4 %[[B]])87 88void f9(void) {89  f1(f3());90}91 92// CIR-LABEL: cir.func{{.*}} @f9(){{.*}} {93// CIR:         %[[SLOT:.+]] = cir.alloca !rec_S, !cir.ptr<!rec_S>, ["agg.tmp0"] {alignment = 4 : i64}94// CIR-NEXT:    %[[RET:.+]] = cir.call @f3() : () -> !rec_S95// CIR-NEXT:    cir.store align(4) %[[RET]], %[[SLOT]] : !rec_S, !cir.ptr<!rec_S>96// CIR-NEXT:    %[[ARG:.+]] = cir.load align(4) %[[SLOT]] : !cir.ptr<!rec_S>, !rec_S97// CIR-NEXT:    cir.call @f1(%[[ARG]]) : (!rec_S) -> ()98 99// LLVM-LABEL: define{{.*}} void @f9(){{.*}} {100// LLVM:         %[[SLOT:.+]] = alloca %struct.S, i64 1, align 4101// LLVM-NEXT:    %[[RET:.+]] = call %struct.S @f3()102// LLVM-NEXT:    store %struct.S %[[RET]], ptr %[[SLOT]], align 4103// LLVM-NEXT:    %[[ARG:.+]] = load %struct.S, ptr %[[SLOT]], align 4104// LLVM-NEXT:    call void @f1(%struct.S %[[ARG]])105 106// OGCG-LABEL: define{{.*}} void @f9() #0 {107// OGCG:         %[[SLOT:.+]] = alloca %struct.S, align 4108// OGCG-NEXT:    %[[RET:.+]] = call i64 @f3()109// OGCG-NEXT:    store i64 %[[RET]], ptr %[[SLOT]], align 4110// OGCG-NEXT:    %[[ARG:.+]] = load i64, ptr %[[SLOT]], align 4111// OGCG-NEXT:    call void @f1(i64 %[[ARG]])112 113__attribute__((pure)) int f10(int);114__attribute__((const)) int f11(int);115int f12(void) {116  return f10(1) + f11(2);117}118 119// CIR-LABEL: cir.func{{.*}} @f12() -> !s32i{{.*}} {120// CIR:         %[[A:.+]] = cir.const #cir.int<1> : !s32i121// CIR-NEXT:    %{{.+}} = cir.call @f10(%[[A]]) side_effect(pure) : (!s32i) -> !s32i122// CIR-NEXT:    %[[B:.+]] = cir.const #cir.int<2> : !s32i123// CIR-NEXT:    %{{.+}} = cir.call @f11(%[[B]]) side_effect(const) : (!s32i) -> !s32i124 125// LLVM-LABEL: define{{.*}} i32 @f12(){{.*}}126// LLVM:         %{{.+}} = call i32 @f10(i32 1) #[[ATTR0:.+]]127// LLVM-NEXT:    %{{.+}} = call i32 @f11(i32 2) #[[ATTR1:.+]]128 129// OGCG-LABEL: define{{.*}} i32 @f12()130// OGCG:         %{{.+}} = call i32 @f10(i32 noundef 1) #[[ATTR0:.+]]131// OGCG-NEXT:    %{{.+}} = call i32 @f11(i32 noundef 2) #[[ATTR1:.+]]132 133// LLVM: attributes #[[ATTR0]] = { nounwind willreturn memory(read) }134// LLVM: attributes #[[ATTR1]] = { nounwind willreturn memory(none) }135 136// OGCG: attributes #[[ATTR0]] = { nounwind willreturn memory(read) }137// OGCG: attributes #[[ATTR1]] = { nounwind willreturn memory(none) }138