projects
/
platform
/
upstream
/
llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
eb438c8
)
[Instrumentation] Use std::clamp (NFC)
author
Kazu Hirata
<kazu@google.com>
Mon, 29 Aug 2022 06:28:57 +0000
(23:28 -0700)
committer
Kazu Hirata
<kazu@google.com>
Mon, 29 Aug 2022 06:28:57 +0000
(23:28 -0700)
The use of std::clamp should be safe here. MinRZ is at most 32, while
kMaxRZ is 1 << 18, so we have MinRZ <= kMaxRZ, avoiding the undefind
behavior of std::clamp.
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
patch
|
blob
|
history
diff --git
a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index
b8d4f68
..
8805d37
100644
(file)
--- a/
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@
-2398,7
+2398,7
@@
ModuleAddressSanitizer::getRedzoneSizeForGlobal(uint64_t SizeInBytes) const {
RZ = MinRZ - SizeInBytes;
} else {
// Calculate RZ, where MinRZ <= RZ <= MaxRZ, and RZ ~ 1/4 * SizeInBytes.
- RZ = std::
max(MinRZ, std::min(kMaxRZ, (SizeInBytes / MinRZ / 4) * MinRZ)
);
+ RZ = std::
clamp((SizeInBytes / MinRZ / 4) * MinRZ, MinRZ, kMaxRZ
);
// Round up to multiple of MinRZ.
if (SizeInBytes % MinRZ)