[PATCH] Remove dangling BlockAddresses in GlobalDCE

Rafael EspĂ­ndola rafael.espindola at gmail.com
Fri Aug 22 13:35:27 PDT 2014


On 22 August 2014 16:07, Bruno Cardoso Lopes <bruno.cardoso at gmail.com> wrote:
> Hi Rafael,
>
> I've tried this path before and the problem I found is exactly what you fix with:
>
> +  if (isa<ConstantInt>(C) || isa<ConstantFP>(C)) // why?
> +    return false;
> +
>
> I->setInitializer(nullptr) will actually destroy the constant in ConstantInt and ConstantFP and later on there's nothing there for destroyConstant to destroy.
>
> This is not the case for other underlying constant types - which you can safely keep track by saving the initializer and deleting it later. I prefer your approach, but I suggest we do not change isSafeToDestroyConstant, but check this condition before.

So, the problem is that destroyConstant is not overridden in
ConstantFP and ConstantInt. It is never safe to call it, which is why
I changed isSafeToDestroyConstant.

Cheers,
Rafael



More information about the llvm-commits mailing list