The MathExtras.h header is included purely for the countPopulation() method - by moving this into Sanitizers.cpp we can remove the use of this costly header.
We only ever use isPowerOf2() / countPopulation() inside asserts so this shouldn't have any performance effects on production code.
Differential Revision: https://reviews.llvm.org/D103953
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/MathExtras.h"
#include "llvm/Transforms/Instrumentation/AddressSanitizerOptions.h"
#include <cassert>
#include <cstdint>
return SanitizerMask(mask1, mask2);
}
- unsigned countPopulation() const {
- unsigned total = 0;
- for (const auto &Val : maskLoToHigh)
- total += llvm::countPopulation(Val);
- return total;
- }
+ unsigned countPopulation() const;
void flipAllBits() {
for (auto &Val : maskLoToHigh)
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Support/MathExtras.h"
using namespace clang;
}
namespace clang {
+unsigned SanitizerMask::countPopulation() const {
+ unsigned total = 0;
+ for (const auto &Val : maskLoToHigh)
+ total += llvm::countPopulation(Val);
+ return total;
+}
+
llvm::hash_code hash_value(const clang::SanitizerMask &Arg) {
return Arg.hash_value();
}