From 116aebcae07df3c59bf7fcf03fb5bd2cd519277a Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Fri, 14 Apr 2017 22:03:37 +0000 Subject: [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 llvm-svn: 300371 --- clang/lib/CodeGen/CGExpr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'clang/lib/CodeGen/CGExpr.cpp') diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 428c8ffd2a13..265ef27a46b0 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -599,7 +599,7 @@ void CodeGenFunction::EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc, 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)); -- cgit v1.2.3