|
| 1 | +// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5 |
| 2 | +// RUN: %clang_cc1 -O1 -triple=x86_64-unknown-linux %s -emit-llvm -o - | FileCheck %s |
| 3 | + |
| 4 | +typedef unsigned char uint8_t; |
| 5 | +typedef unsigned long long uint64_t; |
| 6 | + |
| 7 | +struct a { |
| 8 | + uint64_t b; |
| 9 | + uint8_t block[16]; |
| 10 | +}; |
| 11 | + |
| 12 | +// CHECK-LABEL: define dso_local void @ptradd_0( |
| 13 | +// CHECK-SAME: ptr noundef writeonly captures(none) initializes((8, 9)) [[CTX:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] { |
| 14 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 15 | +// CHECK-NEXT: [[BLOCK:%.*]] = getelementptr inbounds nuw i8, ptr [[CTX]], i64 8 |
| 16 | +// CHECK-NEXT: store i8 0, ptr [[BLOCK]], align 1, !tbaa [[TBAA2:![0-9]+]] |
| 17 | +// CHECK-NEXT: ret void |
| 18 | +// |
| 19 | +void ptradd_0(struct a *ctx) { |
| 20 | + *(ctx->block + 0) = 0; |
| 21 | +} |
| 22 | + |
| 23 | +// CHECK-LABEL: define dso_local void @ptradd_4( |
| 24 | +// CHECK-SAME: ptr noundef writeonly captures(none) initializes((12, 13)) [[CTX:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 25 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 26 | +// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds nuw i8, ptr [[CTX]], i64 12 |
| 27 | +// CHECK-NEXT: store i8 0, ptr [[ADD_PTR]], align 1, !tbaa [[TBAA2]] |
| 28 | +// CHECK-NEXT: ret void |
| 29 | +// |
| 30 | +void ptradd_4(struct a *ctx) { |
| 31 | + *(ctx->block + 4) = 0; |
| 32 | +} |
| 33 | + |
| 34 | +// CHECK-LABEL: define dso_local void @ptradd_8( |
| 35 | +// CHECK-SAME: ptr noundef writeonly captures(none) initializes((16, 17)) [[CTX:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 36 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 37 | +// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds nuw i8, ptr [[CTX]], i64 16 |
| 38 | +// CHECK-NEXT: store i8 0, ptr [[ADD_PTR]], align 1, !tbaa [[TBAA2]] |
| 39 | +// CHECK-NEXT: ret void |
| 40 | +// |
| 41 | +void ptradd_8(struct a *ctx) { |
| 42 | + *(ctx->block + 8) = 0; |
| 43 | +} |
| 44 | + |
| 45 | +// CHECK-LABEL: define dso_local void @ptradd_8_commuted( |
| 46 | +// CHECK-SAME: ptr noundef writeonly captures(none) initializes((16, 17)) [[CTX:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 47 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 48 | +// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds nuw i8, ptr [[CTX]], i64 16 |
| 49 | +// CHECK-NEXT: store i8 0, ptr [[ADD_PTR]], align 1, !tbaa [[TBAA2]] |
| 50 | +// CHECK-NEXT: ret void |
| 51 | +// |
| 52 | +void ptradd_8_commuted(struct a *ctx) { |
| 53 | + *(8 + ctx->block) = 0; |
| 54 | +} |
| 55 | + |
| 56 | +// CHECK-LABEL: define dso_local void @ptrsub_4( |
| 57 | +// CHECK-SAME: ptr noundef writeonly captures(none) initializes((8, 9)) [[CTX:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 58 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 59 | +// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds nuw i8, ptr [[CTX]], i64 8 |
| 60 | +// CHECK-NEXT: store i8 0, ptr [[ADD_PTR]], align 1, !tbaa [[TBAA2]] |
| 61 | +// CHECK-NEXT: ret void |
| 62 | +// |
| 63 | +void ptrsub_4(struct a *ctx) { |
| 64 | + *(&ctx->block[4] - 4) = 0; |
| 65 | +} |
| 66 | + |
| 67 | +// CHECK-LABEL: define dso_local void @neg_ptradd_var_index( |
| 68 | +// CHECK-SAME: ptr noundef writeonly captures(none) [[CTX:%.*]], i8 noundef zeroext [[IDX:%.*]]) local_unnamed_addr #[[ATTR0]] { |
| 69 | +// CHECK-NEXT: [[ENTRY:.*:]] |
| 70 | +// CHECK-NEXT: [[BLOCK:%.*]] = getelementptr inbounds nuw i8, ptr [[CTX]], i64 8 |
| 71 | +// CHECK-NEXT: [[IDX_EXT:%.*]] = zext i8 [[IDX]] to i64 |
| 72 | +// CHECK-NEXT: [[ADD_PTR:%.*]] = getelementptr inbounds nuw i8, ptr [[BLOCK]], i64 [[IDX_EXT]] |
| 73 | +// CHECK-NEXT: store i8 0, ptr [[ADD_PTR]], align 1, !tbaa [[TBAA2]] |
| 74 | +// CHECK-NEXT: ret void |
| 75 | +// |
| 76 | +void neg_ptradd_var_index(struct a *ctx, uint8_t idx) { |
| 77 | + *(ctx->block + idx) = 0; |
| 78 | +} |
| 79 | +//. |
| 80 | +// CHECK: [[TBAA2]] = !{[[META3:![0-9]+]], [[META3]], i64 0} |
| 81 | +// CHECK: [[META3]] = !{!"omnipotent char", [[META4:![0-9]+]], i64 0} |
| 82 | +// CHECK: [[META4]] = !{!"Simple C/C++ TBAA"} |
| 83 | +//. |
0 commit comments