[PATCH] D30285: [ubsan] Don't check alignment if the alignment is 1
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 14 15:16:33 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL300371: [ubsan] Don't check alignment if the alignment is 1 (authored by vedantk).
Changed prior to commit:
https://reviews.llvm.org/D30285?vs=89458&id=95353#toc
Repository:
rL LLVM
https://reviews.llvm.org/D30285
Files:
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/test/CodeGenCXX/ubsan-suppress-checks.cpp
cfe/trunk/test/CodeGenCXX/ubsan-type-checks.cpp
Index: cfe/trunk/test/CodeGenCXX/ubsan-suppress-checks.cpp
===================================================================
--- cfe/trunk/test/CodeGenCXX/ubsan-suppress-checks.cpp
+++ cfe/trunk/test/CodeGenCXX/ubsan-suppress-checks.cpp
@@ -133,7 +133,7 @@
// CHECK: call void @__ubsan_handle_type_mismatch
//
// Check the result of the conversion before using it.
- // CHECK: call void @__ubsan_handle_type_mismatch
+ // NULL: call void @__ubsan_handle_type_mismatch
//
// CHECK-NOT: call void @__ubsan_handle_type_mismatch
B b;
Index: cfe/trunk/test/CodeGenCXX/ubsan-type-checks.cpp
===================================================================
--- cfe/trunk/test/CodeGenCXX/ubsan-type-checks.cpp
+++ cfe/trunk/test/CodeGenCXX/ubsan-type-checks.cpp
@@ -5,16 +5,32 @@
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
// OBJSIZE-NOT: call i64 @llvm.objectsize
}
};
+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();
}
Index: cfe/trunk/lib/CodeGen/CGExpr.cpp
===================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp
@@ -599,7 +599,7 @@
AlignVal = getContext().getTypeAlignInChars(Ty).getQuantity();
// The glvalue must be suitably aligned.
- if (AlignVal) {
+ if (AlignVal > 1) {
llvm::Value *Align =
Builder.CreateAnd(Builder.CreatePtrToInt(Ptr, IntPtrTy),
llvm::ConstantInt::get(IntPtrTy, AlignVal - 1));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30285.95353.patch
Type: text/x-patch
Size: 2181 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170414/b2398153/attachment.bin>
More information about the cfe-commits
mailing list