[llvm] ce8cb7c - [Analysis][NFC] Don't use BitVector for nobuiltin overrides
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 14 00:41:07 PDT 2024
Author: Alexis Engelke
Date: 2024-08-14T09:41:04+02:00
New Revision: ce8cb7c389460ef7fa56b521742a58ead647fda6
URL: https://github.com/llvm/llvm-project/commit/ce8cb7c389460ef7fa56b521742a58ead647fda6
DIFF: https://github.com/llvm/llvm-project/commit/ce8cb7c389460ef7fa56b521742a58ead647fda6.diff
LOG: [Analysis][NFC] Don't use BitVector for nobuiltin overrides
Avoid one heap allocation per function per constructed TLI. The
BitVector is never resized, so a bitset is sufficient.
Pull Request: https://github.com/llvm/llvm-project/pull/103411
Added:
Modified:
llvm/include/llvm/Analysis/TargetLibraryInfo.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.h b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
index db5e80ccdbaaba..d0506a89b88ef4 100644
--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.h
+++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.h
@@ -9,12 +9,12 @@
#ifndef LLVM_ANALYSIS_TARGETLIBRARYINFO_H
#define LLVM_ANALYSIS_TARGETLIBRARYINFO_H
-#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/IR/InstrTypes.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Pass.h"
#include "llvm/TargetParser/Triple.h"
+#include <bitset>
#include <optional>
namespace llvm {
@@ -287,12 +287,12 @@ class TargetLibraryInfo {
/// Support for -fno-builtin* options as function attributes, overrides
/// information in global TargetLibraryInfoImpl.
- BitVector OverrideAsUnavailable;
+ std::bitset<NumLibFuncs> OverrideAsUnavailable;
public:
explicit TargetLibraryInfo(const TargetLibraryInfoImpl &Impl,
std::optional<const Function *> F = std::nullopt)
- : Impl(&Impl), OverrideAsUnavailable(NumLibFuncs) {
+ : Impl(&Impl) {
if (!F)
return;
if ((*F)->hasFnAttribute("no-builtins"))
@@ -329,7 +329,7 @@ class TargetLibraryInfo {
return OverrideAsUnavailable == CalleeTLI.OverrideAsUnavailable;
// We can inline if the callee's nobuiltin attributes are no stricter than
// the caller's.
- return !CalleeTLI.OverrideAsUnavailable.test(OverrideAsUnavailable);
+ return (CalleeTLI.OverrideAsUnavailable & ~OverrideAsUnavailable).none();
}
/// Return true if the function type FTy is valid for the library function
@@ -373,10 +373,12 @@ class TargetLibraryInfo {
/// Forces a function to be marked as unavailable.
void setUnavailable(LibFunc F) LLVM_ATTRIBUTE_UNUSED {
+ assert(F < OverrideAsUnavailable.size() && "out-of-bounds LibFunc");
OverrideAsUnavailable.set(F);
}
TargetLibraryInfoImpl::AvailabilityState getState(LibFunc F) const {
+ assert(F < OverrideAsUnavailable.size() && "out-of-bounds LibFunc");
if (OverrideAsUnavailable[F])
return TargetLibraryInfoImpl::Unavailable;
return Impl->getState(F);
More information about the llvm-commits
mailing list