51 lines · cpp
1// RUN: %clang_cc1 -std=c++23 -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 -std=c++23 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll4// RUN: FileCheck --input-file=%t-cir.ll %s --check-prefix=LLVM5// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll6// RUN: FileCheck --input-file=%t.ll %s --check-prefix=OGCG7 8void f() {9 int result = 0;10 11 if consteval {12 result = 10; 13 // CIR-NOT: cir.const #cir.int<10> : !s32i14 // LLVM-NOT: store i32 1015 // OGCG-NOT: store i32 1016 } else {17 result = 20; 18 // CHECK: cir.const #cir.int<20> : !s32i19 // LLVM: store i32 20, ptr %1, align 420 // OGCG: store i32 20, ptr %result, align 421 22 }23 24 if !consteval {25 result = 30; 26 // CIR: cir.const #cir.int<30> : !s32i27 // LLVM: store i32 30, ptr %1, align 428 // OGCG: store i32 30, ptr %result, align 429 } else {30 result = 40; 31 // CIR-NOT: cir.const #cir.int<40> : !s32i32 // LLVM-NOT: store i32 4033 // OGCG-NOT: store i32 4034 }35 36 if consteval {37 result = 50; 38 // CIR-NOT: cir.const #cir.int<50> : !s32i39 // LLVM-NOT: store i32 5040 // OGCG-NOT: store i32 5041 }42 43 if !consteval {44 result = 60; 45 // CIR: cir.const #cir.int<60> : !s32i46 // LLVM: store i32 60, ptr %1, align 447 // OGCG: store i32 60, ptr %result, align 448 }49 50}51