[llvm] f361777 - [NFC] use Optional instead of separate bool
Florian Mayer via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 19 15:52:35 PST 2022
Author: Florian Mayer
Date: 2022-12-19T15:52:24-08:00
New Revision: f361777168047389ea4c9949b1a4574a9c87a768
URL: https://github.com/llvm/llvm-project/commit/f361777168047389ea4c9949b1a4574a9c87a768
DIFF: https://github.com/llvm/llvm-project/commit/f361777168047389ea4c9949b1a4574a9c87a768.diff
LOG: [NFC] use Optional instead of separate bool
Added:
Modified:
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index e6209f52b27bd..58a565db8ff20 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -13,6 +13,7 @@
#include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
#include "llvm/ADT/MapVector.h"
+#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
@@ -387,8 +388,7 @@ class HWAddressSanitizer {
bool DetectUseAfterScope;
bool UsePageAliases;
- bool HasMatchAllTag = false;
- uint8_t MatchAllTag = 0;
+ llvm::Optional<uint8_t> MatchAllTag;
unsigned PointerTagShift;
uint64_t TagMaskByte;
@@ -589,11 +589,9 @@ void HWAddressSanitizer::initializeModule() {
if (ClMatchAllTag.getNumOccurrences()) {
if (ClMatchAllTag != -1) {
- HasMatchAllTag = true;
MatchAllTag = ClMatchAllTag & 0xFF;
}
} else if (CompileKernel) {
- HasMatchAllTag = true;
MatchAllTag = 0xFF;
}
@@ -819,8 +817,8 @@ Value *HWAddressSanitizer::memToShadow(Value *Mem, IRBuilder<> &IRB) {
int64_t HWAddressSanitizer::getAccessInfo(bool IsWrite,
unsigned AccessSizeIndex) {
return (CompileKernel << HWASanAccessInfo::CompileKernelShift) |
- (HasMatchAllTag << HWASanAccessInfo::HasMatchAllShift) |
- (MatchAllTag << HWASanAccessInfo::MatchAllShift) |
+ (MatchAllTag.has_value() << HWASanAccessInfo::HasMatchAllShift) |
+ (MatchAllTag.value_or(0) << HWASanAccessInfo::MatchAllShift) |
(Recover << HWASanAccessInfo::RecoverShift) |
(IsWrite << HWASanAccessInfo::IsWriteShift) |
(AccessSizeIndex << HWASanAccessInfo::AccessSizeShift);
@@ -856,9 +854,9 @@ void HWAddressSanitizer::instrumentMemAccessInline(Value *Ptr, bool IsWrite,
Value *MemTag = IRB.CreateLoad(Int8Ty, Shadow);
Value *TagMismatch = IRB.CreateICmpNE(PtrTag, MemTag);
- if (HasMatchAllTag) {
+ if (MatchAllTag.has_value()) {
Value *TagNotIgnored = IRB.CreateICmpNE(
- PtrTag, ConstantInt::get(PtrTag->getType(), MatchAllTag));
+ PtrTag, ConstantInt::get(PtrTag->getType(), *MatchAllTag));
TagMismatch = IRB.CreateAnd(TagMismatch, TagNotIgnored);
}
More information about the llvm-commits
mailing list