Skip to content

Commit c28ddf9

Browse files
[Analysis] Use BitVector::test in areInlineCompatible (NFC) (#98776)
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.
1 parent 181e4c6 commit c28ddf9

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

llvm/include/llvm/Analysis/TargetLibraryInfo.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,11 +327,9 @@ class TargetLibraryInfo {
327327
bool AllowCallerSuperset) const {
328328
if (!AllowCallerSuperset)
329329
return OverrideAsUnavailable == CalleeTLI.OverrideAsUnavailable;
330-
BitVector B = OverrideAsUnavailable;
331-
B |= CalleeTLI.OverrideAsUnavailable;
332-
// We can inline if the union of the caller and callee's nobuiltin
333-
// attributes is no stricter than the caller's nobuiltin attributes.
334-
return B == OverrideAsUnavailable;
330+
// We can inline if the callee's nobuiltin attributes are no stricter than
331+
// the caller's.
332+
return !CalleeTLI.OverrideAsUnavailable.test(OverrideAsUnavailable);
335333
}
336334

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

0 commit comments

Comments
 (0)