47 lines · c
1// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s2// RUN: %clang_cc1 -triple i386-mingw32 -fms-extensions -emit-llvm -o - %s | FileCheck %s3 4int nonconst(void);5int isconst(void) __attribute__((const));6int ispure(void) __attribute__((pure));7 8// CHECK-LABEL: @test19int test1(int *a, int i) {10// CHECK: store ptr %a, ptr [[A_ADDR:%.+]], align11// CHECK: [[A:%.+]] = load ptr, ptr [[A_ADDR]]12// CHECK: [[CMP:%.+]] = icmp ne ptr [[A]], null13// CHECK: call void @llvm.assume(i1 [[CMP]])14 15// CHECK: [[CALL:%.+]] = call i32 @isconst()16// CHECK: [[BOOL:%.+]] = icmp ne i32 [[CALL]], 017// CHECK: call void @llvm.assume(i1 [[BOOL]])18 19// CHECK: [[CALLPURE:%.+]] = call i32 @ispure()20// CHECK: [[BOOLPURE:%.+]] = icmp ne i32 [[CALLPURE]], 021// CHECK: call void @llvm.assume(i1 [[BOOLPURE]])22#ifdef _MSC_VER23 __assume(a != 0)24 __assume(isconst());25 __assume(ispure());26#else27 __builtin_assume(a != 0);28 __builtin_assume(isconst());29 __builtin_assume(ispure());30#endif31 32// Nothing is generated for an assume with side effects...33// CHECK-NOT: load ptr, ptr %i.addr34// CHECK-NOT: call void @llvm.assume35// CHECK-NOT: call i32 @nonconst()36#ifdef _MSC_VER37 __assume(++i != 0)38 __assume(nonconst());39#else40 __builtin_assume(++i != 0);41 __builtin_assume(nonconst());42#endif43 44 return a[0];45}46 47