diff options
author | Kostya Serebryany <kcc@google.com> | 2012-04-27 10:04:53 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2012-04-27 10:04:53 +0000 |
commit | 3f119989c3839c98b20bf6ea00c2ccc95aacff69 (patch) | |
tree | ddf1e4e6ed64fcfd39892380fd0f57c022e6ecb0 | |
parent | 4d2f077df1b46a126b5595d983f233ec896b757e (diff) | |
download | llvm-3f119989c3839c98b20bf6ea00c2ccc95aacff69.tar.gz llvm-3f119989c3839c98b20bf6ea00c2ccc95aacff69.tar.bz2 llvm-3f119989c3839c98b20bf6ea00c2ccc95aacff69.tar.xz |
[asan] small optimization: do not emit "x+0" instructions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155701 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Instrumentation/AddressSanitizer.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 33b56d5036..b01cdbf680 100644 --- a/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -363,11 +363,12 @@ void AddressSanitizer::instrumentAddress(Instruction *OrigIns, 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); |