summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorManman Ren <manman.ren@gmail.com>2016-02-11 19:19:18 +0000
committerManman Ren <manman.ren@gmail.com>2016-02-11 19:19:18 +0000
commit37dec10dbc58f0da9b90861aa04d11ae0ed39935 (patch)
tree08bb97d574090074c90e770e40f94df0ac540cd5 /clang
parentbde158cbc7fabe7b6d4cad12a6884a98623948b9 (diff)
downloadbcm5719-llvm-37dec10dbc58f0da9b90861aa04d11ae0ed39935.tar.gz
bcm5719-llvm-37dec10dbc58f0da9b90861aa04d11ae0ed39935.zip
[PR26550] Use a different TBAA root for C++ vs C.
This commit changes the root from "Simple C/C++ TBAA" to "Simple C++ TBAA" for C++. The problem is that the type name in the TBAA nodes is generated differently for C vs C++. If we link an IR file for C with an IR file for C++, since they have the same root and the type names are different, accesses to the two type nodes will be considered no-alias, even though the two type nodes are from the same type in a header file. The fix is to use different roots for C and C++. Types from C will be treated conservatively in respect to types from C++. Follow-up commits will change the C root to "Simple C TBAA" plus some mangling change for C types to make it a little more aggresive. llvm-svn: 260567
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CodeGenTBAA.cpp8
-rw-r--r--clang/test/CodeGen/tbaa-class.cpp2
-rw-r--r--clang/test/CodeGen/tbaa-for-vptr.cpp2
-rw-r--r--clang/test/CodeGen/tbaa.cpp2
4 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CodeGenTBAA.cpp b/clang/lib/CodeGen/CodeGenTBAA.cpp
index c3c925cde2f..04224e72679 100644
--- a/clang/lib/CodeGen/CodeGenTBAA.cpp
+++ b/clang/lib/CodeGen/CodeGenTBAA.cpp
@@ -44,8 +44,12 @@ llvm::MDNode *CodeGenTBAA::getRoot() {
// if our LLVM IR is linked with LLVM IR from a different front-end
// (or a different version of this front-end), their TBAA trees will
// remain distinct, and the optimizer will treat them conservatively.
- if (!Root)
- Root = MDHelper.createTBAARoot("Simple C/C++ TBAA");
+ if (!Root) {
+ if (Features.CPlusPlus)
+ Root = MDHelper.createTBAARoot("Simple C++ TBAA");
+ else
+ Root = MDHelper.createTBAARoot("Simple C/C++ TBAA");
+ }
return Root;
}
diff --git a/clang/test/CodeGen/tbaa-class.cpp b/clang/test/CodeGen/tbaa-class.cpp
index f611ae5abb8..7172e05d9e3 100644
--- a/clang/test/CodeGen/tbaa-class.cpp
+++ b/clang/test/CodeGen/tbaa-class.cpp
@@ -199,7 +199,7 @@ uint32_t g12(StructC *C, StructD *D, uint64_t count) {
}
// CHECK: [[TYPE_char:!.*]] = !{!"omnipotent char", [[TAG_cxx_tbaa:!.*]],
-// CHECK: [[TAG_cxx_tbaa]] = !{!"Simple C/C++ TBAA"}
+// CHECK: [[TAG_cxx_tbaa]] = !{!"Simple C++ TBAA"}
// CHECK: [[TAG_i32]] = !{[[TYPE_i32:!.*]], [[TYPE_i32]], i64 0}
// CHECK: [[TYPE_i32]] = !{!"int", [[TYPE_char]],
// CHECK: [[TAG_i16]] = !{[[TYPE_i16:!.*]], [[TYPE_i16]], i64 0}
diff --git a/clang/test/CodeGen/tbaa-for-vptr.cpp b/clang/test/CodeGen/tbaa-for-vptr.cpp
index 35e95a54dab..7b8ae2099e4 100644
--- a/clang/test/CodeGen/tbaa-for-vptr.cpp
+++ b/clang/test/CodeGen/tbaa-for-vptr.cpp
@@ -32,4 +32,4 @@ void CallFoo(A *a, int (A::*fp)() const) {
//
// CHECK: [[NUM]] = !{[[TYPE:!.*]], [[TYPE]], i64 0}
// CHECK: [[TYPE]] = !{!"vtable pointer", !{{.*}}
-// NOTBAA-NOT: = !{!"Simple C/C++ TBAA"}
+// NOTBAA-NOT: = !{!"Simple C++ TBAA"}
diff --git a/clang/test/CodeGen/tbaa.cpp b/clang/test/CodeGen/tbaa.cpp
index c43ca58bc3f..f98c46f1497 100644
--- a/clang/test/CodeGen/tbaa.cpp
+++ b/clang/test/CodeGen/tbaa.cpp
@@ -237,7 +237,7 @@ uint32_t g15(StructS *S, StructS3 *S3, uint64_t count) {
}
// CHECK: [[TYPE_char:!.*]] = !{!"omnipotent char", [[TAG_cxx_tbaa:!.*]],
-// CHECK: [[TAG_cxx_tbaa]] = !{!"Simple C/C++ TBAA"}
+// CHECK: [[TAG_cxx_tbaa]] = !{!"Simple C++ TBAA"}
// CHECK: [[TAG_i32]] = !{[[TYPE_i32:!.*]], [[TYPE_i32]], i64 0}
// CHECK: [[TYPE_i32]] = !{!"int", [[TYPE_char]],
// CHECK: [[TAG_i16]] = !{[[TYPE_i16:!.*]], [[TYPE_i16]], i64 0}
OpenPOWER on IntegriCloud