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 | 5a464f03d3ef5b298967d750f5200be2d81938f3 (patch) | |
tree | 9e4b5e03be467cd1352d3a0f01790645d35b016c /llvm/lib/Transforms | |
parent | f435b09eafe1a051608b67facd1dd42d1a9760e1 (diff) | |
download | bcm5719-llvm-5a464f03d3ef5b298967d750f5200be2d81938f3.tar.gz bcm5719-llvm-5a464f03d3ef5b298967d750f5200be2d81938f3.zip |
[asan] small optimization: do not emit "x+0" instructions
llvm-svn: 155701
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 33b56d50365..b01cdbf680a 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/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); |