[MemoryBuiltins] Drop ReallocLike type (NFC)
authorNikita Popov <npopov@redhat.com>
Fri, 9 Dec 2022 10:35:20 +0000 (11:35 +0100)
committerNikita Popov <npopov@redhat.com>
Fri, 9 Dec 2022 10:35:20 +0000 (11:35 +0100)
All realloc style functions have been migrated to use allocator
attributes, so we no longer need to check for this.

llvm/lib/Analysis/MemoryBuiltins.cpp

index c251f92..b205da1 100644 (file)
@@ -56,12 +56,11 @@ enum AllocType : uint8_t {
   MallocLike         = 1<<1, // allocates; may return null
   AlignedAllocLike   = 1<<2, // allocates with alignment; may return null
   CallocLike         = 1<<3, // allocates + bzero
-  ReallocLike        = 1<<4, // reallocates
-  StrDupLike         = 1<<5,
+  StrDupLike         = 1<<4,
   MallocOrOpNewLike  = MallocLike | OpNewLike,
   MallocOrCallocLike = MallocLike | OpNewLike | CallocLike | AlignedAllocLike,
   AllocLike          = MallocOrCallocLike | StrDupLike,
-  AnyAlloc           = AllocLike | ReallocLike
+  AnyAlloc           = AllocLike
 };
 
 enum class MallocFamily {
@@ -339,16 +338,11 @@ bool llvm::isAllocLikeFn(const Value *V, const TargetLibraryInfo *TLI) {
 /// Tests if a functions is a call or invoke to a library function that
 /// reallocates memory (e.g., realloc).
 bool llvm::isReallocLikeFn(const Function *F, const TargetLibraryInfo *TLI) {
-  return getAllocationDataForFunction(F, ReallocLike, TLI).has_value() ||
-         checkFnAllocKind(F, AllocFnKind::Realloc);
+  return checkFnAllocKind(F, AllocFnKind::Realloc);
 }
 
 Value *llvm::getReallocatedOperand(const CallBase *CB,
                                    const TargetLibraryInfo *TLI) {
-  if (getAllocationData(CB, ReallocLike, TLI).has_value()) {
-    // All currently supported realloc functions reallocate the first argument.
-    return CB->getArgOperand(0);
-  }
   if (checkFnAllocKind(CB, AllocFnKind::Realloc))
     return CB->getArgOperandWithAttribute(Attribute::AllocatedPointer);
   return nullptr;