From 2ac37df5d7f385dbf9c9456aae1cc6d0d98587ef Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Wed, 14 Dec 2022 08:40:17 -0800 Subject: [PATCH] [Attributor][FIX] Try to prevent a potential memory leak We might not have registered an AA allocated via the bump allocator and consequently not deallocated it properly. --- llvm/include/llvm/Transforms/IPO/Attributor.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h index f7c4300..3b56653 100644 --- a/llvm/include/llvm/Transforms/IPO/Attributor.h +++ b/llvm/include/llvm/Transforms/IPO/Attributor.h @@ -1519,14 +1519,16 @@ struct Attributor { // Use the static create method. auto &AA = AAType::createForPosition(IRP, *this); + // Always register a new attribute to make sure we clean up the allocated + // memory properly. + registerAA(AA); + // If we are currenty seeding attributes, enforce seeding rules. if (Phase == AttributorPhase::SEEDING && !shouldSeedAttribute(AA)) { AA.getState().indicatePessimisticFixpoint(); return AA; } - registerAA(AA); - // For now we ignore naked and optnone functions. bool Invalidate = Configuration.Allowed && !Configuration.Allowed->count(&AAType::ID); -- 2.7.4