summaryrefslogtreecommitdiffstats
path: root/test/CodeGenCXX/ubsan-type-checks.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2017-04-14 22:03:37 +0000
committerVedant Kumar <vsk@apple.com>2017-04-14 22:03:37 +0000
commite18e320ef26c82347e9f225bf4d242636af05060 (patch)
treef13a4e4ba108466cd8f3fbd3349062a812b0f702 /test/CodeGenCXX/ubsan-type-checks.cpp
parent779dfcce1ffd44eaa8606418c295d030ea36bc26 (diff)
[ubsan] Don't check alignment if the alignment is 1
If a pointer is 1-byte aligned, there's no use in checking its alignment. Somewhat surprisingly, ubsan can spend a significant amount of time doing just that! This loosely depends on D30283. Testing: check-clang, check-ubsan, and a stage2 ubsan build. Differential Revision: https://reviews.llvm.org/D30285 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@300371 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/ubsan-type-checks.cpp')
-rw-r--r--test/CodeGenCXX/ubsan-type-checks.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/test/CodeGenCXX/ubsan-type-checks.cpp b/test/CodeGenCXX/ubsan-type-checks.cpp
index 150b2fc40c..786d049dfb 100644
--- a/test/CodeGenCXX/ubsan-type-checks.cpp
+++ b/test/CodeGenCXX/ubsan-type-checks.cpp
@@ -5,8 +5,7 @@
struct A {
// COMMON-LABEL: define linkonce_odr void @_ZN1A10do_nothingEv
void do_nothing() {
- // ALIGN: ptrtoint %struct.A* %{{.*}} to i64, !nosanitize
- // ALIGN: and i64 %{{.*}}, 0, !nosanitize
+ // ALIGN-NOT: ptrtoint %struct.A* %{{.*}} to i64, !nosanitize
// NULL: icmp ne %struct.A* %{{.*}}, null, !nosanitize
@@ -14,7 +13,24 @@ struct A {
}
};
+struct B {
+ int x;
+
+ // COMMON-LABEL: define linkonce_odr void @_ZN1B10do_nothingEv
+ void do_nothing() {
+ // ALIGN: ptrtoint %struct.B* %{{.*}} to i64, !nosanitize
+ // ALIGN: and i64 %{{.*}}, 3, !nosanitize
+
+ // NULL: icmp ne %struct.B* %{{.*}}, null, !nosanitize
+
+ // OBJSIZE-NOT: call i64 @llvm.objectsize
+ }
+};
+
void force_irgen() {
A a;
a.do_nothing();
+
+ B b;
+ b.do_nothing();
}