@@ -157,8 +157,7 @@ static const std::pair<LibFunc, AllocFnsTy> AllocationFnData[] = {
157157};
158158// clang-format on
159159
160- static const Function *getCalledFunction (const Value *V,
161- bool &IsNoBuiltin) {
160+ static const Function *getCalledFunction (const Value *V) {
162161 // Don't care about intrinsics in this case.
163162 if (isa<IntrinsicInst>(V))
164163 return nullptr ;
@@ -167,11 +166,10 @@ static const Function *getCalledFunction(const Value *V,
167166 if (!CB)
168167 return nullptr ;
169168
170- IsNoBuiltin = CB->isNoBuiltin ();
169+ if (CB->isNoBuiltin ())
170+ return nullptr ;
171171
172- if (const Function *Callee = CB->getCalledFunction ())
173- return Callee;
174- return nullptr ;
172+ return CB->getCalledFunction ();
175173}
176174
177175// / Returns the allocation data for the given value if it's a call to a known
@@ -221,29 +219,23 @@ getAllocationDataForFunction(const Function *Callee, AllocType AllocTy,
221219static std::optional<AllocFnsTy>
222220getAllocationData (const Value *V, AllocType AllocTy,
223221 const TargetLibraryInfo *TLI) {
224- bool IsNoBuiltinCall;
225- if (const Function *Callee = getCalledFunction (V, IsNoBuiltinCall))
226- if (!IsNoBuiltinCall)
227- return getAllocationDataForFunction (Callee, AllocTy, TLI);
222+ if (const Function *Callee = getCalledFunction (V))
223+ return getAllocationDataForFunction (Callee, AllocTy, TLI);
228224 return std::nullopt ;
229225}
230226
231227static std::optional<AllocFnsTy>
232228getAllocationData (const Value *V, AllocType AllocTy,
233229 function_ref<const TargetLibraryInfo &(Function &)> GetTLI) {
234- bool IsNoBuiltinCall;
235- if (const Function *Callee = getCalledFunction (V, IsNoBuiltinCall))
236- if (!IsNoBuiltinCall)
237- return getAllocationDataForFunction (
238- Callee, AllocTy, &GetTLI (const_cast <Function &>(*Callee)));
230+ if (const Function *Callee = getCalledFunction (V))
231+ return getAllocationDataForFunction (
232+ Callee, AllocTy, &GetTLI (const_cast <Function &>(*Callee)));
239233 return std::nullopt ;
240234}
241235
242236static std::optional<AllocFnsTy>
243237getAllocationSize (const CallBase *CB, const TargetLibraryInfo *TLI) {
244- bool IsNoBuiltinCall;
245- const Function *Callee = getCalledFunction (CB, IsNoBuiltinCall);
246- if (Callee && !IsNoBuiltinCall) {
238+ if (const Function *Callee = getCalledFunction (CB)) {
247239 // Prefer to use existing information over allocsize. This will give us an
248240 // accurate AllocTy.
249241 if (std::optional<AllocFnsTy> Data =
@@ -507,9 +499,7 @@ std::optional<FreeFnsTy> getFreeFunctionDataForFunction(const Function *Callee,
507499
508500std::optional<StringRef>
509501llvm::getAllocationFamily (const Value *I, const TargetLibraryInfo *TLI) {
510- bool IsNoBuiltin;
511- const Function *Callee = getCalledFunction (I, IsNoBuiltin);
512- if (Callee && !IsNoBuiltin) {
502+ if (const Function *Callee = getCalledFunction (I)) {
513503 LibFunc TLIFn;
514504 if (TLI && TLI->getLibFunc (*Callee, TLIFn) && TLI->has (TLIFn)) {
515505 // Callee is some known library function.
@@ -554,9 +544,7 @@ bool llvm::isLibFreeFunction(const Function *F, const LibFunc TLIFn) {
554544}
555545
556546Value *llvm::getFreedOperand (const CallBase *CB, const TargetLibraryInfo *TLI) {
557- bool IsNoBuiltinCall;
558- const Function *Callee = getCalledFunction (CB, IsNoBuiltinCall);
559- if (Callee && !IsNoBuiltinCall) {
547+ if (const Function *Callee = getCalledFunction (CB)) {
560548 LibFunc TLIFn;
561549 if (TLI && TLI->getLibFunc (*Callee, TLIFn) && TLI->has (TLIFn) &&
562550 isLibFreeFunction (Callee, TLIFn)) {
0 commit comments