[llvm] [IR][TLI] Cache getLibFunc() result on Function (NFC) (PR #72867)
Dhruv Chawla via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 21 00:44:19 PST 2023
================
@@ -120,6 +122,13 @@ class LLVM_EXTERNAL_VISIBILITY Function : public GlobalObject,
void setIsNewDbgInfoFormat(bool NewVal);
private:
+ friend class TargetLibraryInfoImpl;
+
+ /// Cache for TLI::getLibFunc() result without prototype validation.
+ /// -1 if uninitialized. NotLibFunc if definitely not lib func.
+ /// Otherwise may be libfunc if prototype validation passes.
+ mutable LibFunc LibFuncCache = LibFunc(-1);
----------------
dc03 wrote:
`LibFunc(-1)` seems like a slight code smell to me, because of the implicit unsigned wrap-around and it being reused multiple times as well. I think it would be better to have a constant `UnsetLibFuncValue` or something similar.
https://github.com/llvm/llvm-project/pull/72867
More information about the llvm-commits
mailing list