[llvm-commits] [llvm] r155701 - /llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Kostya Serebryany
kcc at google.com
Fri Apr 27 03:04:53 PDT 2012
Author: kcc
Date: Fri Apr 27 05:04:53 2012
New Revision: 155701
URL: http://llvm.org/viewvc/llvm-project?rev=155701&view=rev
Log:
[asan] small optimization: do not emit "x+0" instructions
Modified:
llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
Modified: llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp?rev=155701&r1=155700&r2=155701&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/AddressSanitizer.cpp Fri Apr 27 05:04:53 2012
@@ -363,11 +363,12 @@
size_t Granularity = 1 << MappingScale;
if (TypeSize < 8 * Granularity) {
// Addr & (Granularity - 1)
- Value *Lower3Bits = IRB2.CreateAnd(
+ Value *LastAccessedByte = IRB2.CreateAnd(
AddrLong, ConstantInt::get(IntptrTy, Granularity - 1));
// (Addr & (Granularity - 1)) + size - 1
- Value *LastAccessedByte = IRB2.CreateAdd(
- Lower3Bits, ConstantInt::get(IntptrTy, TypeSize / 8 - 1));
+ if (TypeSize / 8 > 1)
+ LastAccessedByte = IRB2.CreateAdd(
+ LastAccessedByte, ConstantInt::get(IntptrTy, TypeSize / 8 - 1));
// (uint8_t) ((Addr & (Granularity-1)) + size - 1)
LastAccessedByte = IRB2.CreateIntCast(
LastAccessedByte, IRB.getInt8Ty(), false);
More information about the llvm-commits
mailing list