From f303e248b92d66d08f135ed5ec06a5b692cda8a7 Mon Sep 17 00:00:00 2001 From: Johannes Doerfert Date: Fri, 16 Jul 2021 14:14:37 -0500 Subject: [PATCH] [Attributor][FIX] Improve call graph updating If we remove a non-intrinsic instruction we need to tell the (old) call graph about it. This caused problems with some features down the line as they allowed to removed calls more aggressively. --- lib/Transforms/IPO/Attributor.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/Transforms/IPO/Attributor.cpp b/lib/Transforms/IPO/Attributor.cpp index c2e755ef29f..97c585ef911 100644 --- a/lib/Transforms/IPO/Attributor.cpp +++ b/lib/Transforms/IPO/Attributor.cpp @@ -31,6 +31,7 @@ #include "llvm/IR/GlobalValue.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Instruction.h" +#include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/NoFolder.h" #include "llvm/IR/ValueHandle.h" #include "llvm/IR/Verifier.h" @@ -1589,9 +1590,12 @@ ChangeStatus Attributor::cleanupIR() { for (auto &V : ToBeDeletedInsts) { if (Instruction *I = dyn_cast_or_null(V)) { - if (auto *CB = dyn_cast(I)) - if (CB->isMustTailCall() && !isRunOn(*I->getFunction())) + if (auto *CB = dyn_cast(I)) { + if (!isRunOn(*I->getFunction())) continue; + if (!isa(CB)) + CGUpdater.removeCallSite(*CB); + } I->dropDroppableUses(); CGModifiedFunctions.insert(I->getFunction()); if (!I->getType()->isVoidTy())