Skip to content

Commit

Permalink
[Analysis] Use BitVector::test in areInlineCompatible (NFC) (#98776)
Browse files Browse the repository at this point in the history
areInlineCompatible checks to see if CalleeTLI.OverrideAsUnavailable
is a subset of OverrideAsUnavailable by computing a union of the two
and comparing the union and OverrideAsUnavailable.

The problem is that computing a union involves memory allocations.
This patch removes the need for memory allocations by switching to
BitVector::test.  Note that A.test(B) returns true if A - B is
non-empty.  That is, !A.test(B) is true if A if a subset of B.

The use of BitVector::test here saves 0.20% of heap allocations during
the compilation of X86ISelLowering.cpp.ii, a preprocessed version of
X86ISelLowering.cpp.
  • Loading branch information
kazutakahirata authored Jul 14, 2024
1 parent 181e4c6 commit c28ddf9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions llvm/include/llvm/Analysis/TargetLibraryInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,9 @@ class TargetLibraryInfo {
bool AllowCallerSuperset) const {
if (!AllowCallerSuperset)
return OverrideAsUnavailable == CalleeTLI.OverrideAsUnavailable;
BitVector B = OverrideAsUnavailable;
B |= CalleeTLI.OverrideAsUnavailable;
// We can inline if the union of the caller and callee's nobuiltin
// attributes is no stricter than the caller's nobuiltin attributes.
return B == OverrideAsUnavailable;
// We can inline if the callee's nobuiltin attributes are no stricter than
// the caller's.
return !CalleeTLI.OverrideAsUnavailable.test(OverrideAsUnavailable);
}

/// Return true if the function type FTy is valid for the library function
Expand Down

0 comments on commit c28ddf9

Please sign in to comment.