-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CIR][CIRGen][TBAA] Initial TBAA support for union, enum and bitint
- Loading branch information
1 parent
363440c
commit 34dc621
Showing
6 changed files
with
155 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir -O1 | ||
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s | ||
|
||
|
||
// CIR: #tbaa[[tbaa_NYI:.*]] = #cir.tbaa | ||
|
||
_BitInt(33) a; | ||
_BitInt(31) b; | ||
void c() { | ||
// CIR: %{{.*}} = cir.load %{{.*}} : !cir.ptr<!cir.int<s, 33>>, !cir.int<s, 33> tbaa(#tbaa[[tbaa_NYI]]) | ||
// CIR: cir.store %{{.*}}, %{{.*}} : !cir.int<s, 31>, !cir.ptr<!cir.int<s, 31>> tbaa(#tbaa[[tbaa_NYI]]) | ||
b = a; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir -O1 | ||
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll -O1 -disable-llvm-passes | ||
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll -O1 -disable-llvm-passes -relaxed-aliasing | ||
// RUN: FileCheck --check-prefix=NO-TBAA --input-file=%t.ll %s | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll -O0 -disable-llvm-passes | ||
// RUN: FileCheck --check-prefix=NO-TBAA --input-file=%t.ll %s | ||
|
||
// NO-TBAA-NOT: !tbaa | ||
|
||
// CIR: #tbaa[[tbaa_NYI:.*]] = #cir.tbaa | ||
// CIR: #tbaa[[INT:.*]] = #cir.tbaa_scalar<type = !u32i> | ||
// CIR: #tbaa[[INT_PTR:.*]] = #cir.tbaa_scalar<type = !cir.ptr<!u32i>> | ||
|
||
typedef unsigned int uint32_t; | ||
typedef enum { | ||
RED_AUTO_32, | ||
GREEN_AUTO_32, | ||
BLUE_AUTO_32 | ||
} EnumAuto32; | ||
|
||
uint32_t g0(EnumAuto32 *E, uint32_t *val) { | ||
// CIR-LABEL: cir.func @g0 | ||
// CIR: %[[C5:.*]] = cir.const #cir.int<5> : !s32i | ||
// CIR: %[[U_C5:.*]] = cir.cast(integral, %[[C5]] : !s32i), !u32i | ||
// CIR: %[[VAL_PTR:.*]] = cir.load deref %{{.*}} : !cir.ptr<!cir.ptr<!u32i>>, !cir.ptr<!u32i> tbaa(#tbaa[[INT_PTR]]) | ||
// CIR: cir.store %[[U_C5]], %[[VAL_PTR]] : !u32i, !cir.ptr<!u32i> tbaa(#tbaa[[INT]]) | ||
// CIR: %[[C0:.*]] = cir.const #cir.int<0> : !s32i | ||
// CIR: %[[U_C0:.*]] = cir.cast(integral, %[[C0]] : !s32i), !u32i | ||
// CIR: %[[E_PTR:.*]] = cir.load deref %{{.*}} : !cir.ptr<!cir.ptr<!u32i>>, !cir.ptr<!u32i> tbaa(#tbaa[[INT_PTR]]) | ||
// CIR: cir.store %[[U_C0]], %[[E_PTR]] : !u32i, !cir.ptr<!u32i> tbaa(#tbaa[[tbaa_NYI]]) | ||
// CIR: %[[RET_PTR:.*]] = cir.load deref %{{.*}} : !cir.ptr<!cir.ptr<!u32i>>, !cir.ptr<!u32i> tbaa(#tbaa[[INT_PTR]]) | ||
// CIR: %[[RET:.*]] = cir.load %[[RET_PTR]] : !cir.ptr<!u32i>, !u32i tbaa(#tbaa[[INT]]) | ||
// CIR: cir.store %[[RET]], %{{.*}} : !u32i, !cir.ptr<!u32i> | ||
|
||
// LLVM-LABEL: define{{.*}} i32 @g0( | ||
// LLVM: store i32 5, ptr %{{.*}}, align 4, !tbaa [[TAG_i32:!.*]] | ||
// LLVM: store i32 0, ptr %{{.*}}, align 4 | ||
// LLVM: load i32, ptr %{{.*}}, align 4, !tbaa [[TAG_i32]] | ||
*val = 5; | ||
*E = RED_AUTO_32; | ||
return *val; | ||
} | ||
|
||
// LLVM: [[TYPE_char:!.*]] = !{!"omnipotent char", [[TAG_c_tbaa:!.*]], | ||
// LLVM: [[TAG_c_tbaa]] = !{!"Simple C/C++ TBAA"} | ||
// LLVM: [[TAG_i32]] = !{[[TYPE_i32:!.*]], [[TYPE_i32]], i64 0} | ||
// LLVM: [[TYPE_i32]] = !{!"int", [[TYPE_char]], i64 0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir -O1 | ||
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll -O1 | ||
// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll -O1 -relaxed-aliasing | ||
// RUN: FileCheck --check-prefix=NO-TBAA --input-file=%t.ll %s | ||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t.ll -O0 | ||
// RUN: FileCheck --check-prefix=NO-TBAA --input-file=%t.ll %s | ||
|
||
// NO-TBAA-NOT: !tbaa | ||
// CIR: #tbaa[[CHAR:.*]] = #cir.tbaa_scalar<type = !cir.int<s, 1>> | ||
// CIR: #tbaa[[Struct_S_PTR:.*]] = #cir.tbaa_scalar<type = !cir.ptr<!ty_S>> | ||
typedef struct { | ||
union { | ||
int a, b; | ||
}; | ||
int c; | ||
} S; | ||
|
||
void foo(S *s) { | ||
// CIR-LABEL: cir.func @foo | ||
// CIR: %[[C1:.*]] = cir.const #cir.int<1> : !s32i loc(#loc6) | ||
// CIR: %{{.*}} = cir.load %{{.*}} : !cir.ptr<!cir.ptr<!ty_S>>, !cir.ptr<!ty_S> tbaa(#tbaa[[Struct_S_PTR]]) | ||
// CIR: cir.store %[[C1]], %{{.*}} : !s32i, !cir.ptr<!s32i> tbaa(#tbaa[[CHAR]]) | ||
|
||
// LLVM-LABEL: void @foo | ||
// LLVM: store i32 1, ptr %{{.*}}, align 4, !tbaa ![[TBAA_TAG:.*]] | ||
s->a = 1; | ||
} | ||
|
||
// LLVM: ![[TBAA_TAG]] = !{![[CHAR:.*]], ![[CHAR]], i64 0} | ||
// LLVM: ![[CHAR]] = !{!"omnipotent char", ![[ROOT:.*]], i64 0} | ||
// LLVM: ![[ROOT]] = !{!"Simple C/C++ TBAA"} |