@@ -157,8 +157,7 @@ static const std::pair<LibFunc, AllocFnsTy> AllocationFnData[] = {
157
157
};
158
158
// clang-format on
159
159
160
- static const Function *getCalledFunction (const Value *V,
161
- bool &IsNoBuiltin) {
160
+ static const Function *getCalledFunction (const Value *V) {
162
161
// Don't care about intrinsics in this case.
163
162
if (isa<IntrinsicInst>(V))
164
163
return nullptr ;
@@ -167,11 +166,10 @@ static const Function *getCalledFunction(const Value *V,
167
166
if (!CB)
168
167
return nullptr ;
169
168
170
- IsNoBuiltin = CB->isNoBuiltin ();
169
+ if (CB->isNoBuiltin ())
170
+ return nullptr ;
171
171
172
- if (const Function *Callee = CB->getCalledFunction ())
173
- return Callee;
174
- return nullptr ;
172
+ return CB->getCalledFunction ();
175
173
}
176
174
177
175
// / 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,
221
219
static std::optional<AllocFnsTy>
222
220
getAllocationData (const Value *V, AllocType AllocTy,
223
221
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);
228
224
return std::nullopt;
229
225
}
230
226
231
227
static std::optional<AllocFnsTy>
232
228
getAllocationData (const Value *V, AllocType AllocTy,
233
229
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)));
239
233
return std::nullopt;
240
234
}
241
235
242
236
static std::optional<AllocFnsTy>
243
237
getAllocationSize (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)) {
247
239
// Prefer to use existing information over allocsize. This will give us an
248
240
// accurate AllocTy.
249
241
if (std::optional<AllocFnsTy> Data =
@@ -507,9 +499,7 @@ std::optional<FreeFnsTy> getFreeFunctionDataForFunction(const Function *Callee,
507
499
508
500
std::optional<StringRef>
509
501
llvm::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)) {
513
503
LibFunc TLIFn;
514
504
if (TLI && TLI->getLibFunc (*Callee, TLIFn) && TLI->has (TLIFn)) {
515
505
// Callee is some known library function.
@@ -554,9 +544,7 @@ bool llvm::isLibFreeFunction(const Function *F, const LibFunc TLIFn) {
554
544
}
555
545
556
546
Value *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)) {
560
548
LibFunc TLIFn;
561
549
if (TLI && TLI->getLibFunc (*Callee, TLIFn) && TLI->has (TLIFn) &&
562
550
isLibFreeFunction (Callee, TLIFn)) {
0 commit comments