[PATCH] Fix for CodeGenPrepare wrongly updating the map of sunk addresses

Nick Lewycky nicholas at mxc.ca
Sun May 5 15:53:55 PDT 2013


Andrea_DiBiagio at sn.scee.net wrote:
> Hi Nick,
>
>
> Nick Lewycky<nicholas at mxc.ca>  wrote on 03/05/2013 16:23:15:
>> Instead of building your own CallbackVH, would using a ValueMap work? If
>
>> not, I'd really like to see a generalized way to create the equivalent
>> of DenseMap<WeakVH<...>, ...>.
>
> Yes it definitely work! Thanks for the advice.
> Actually a ValueMap does exactly what I wanted to do using my custom
> CallbackVH.
> Also, using ValueMap makes the patch simpler and definitely less verbose.
>
> You can find the updated patch in attachment.
>
> P.s.: As a side note,
> the reason why I intially adopted that solution is because there are other
> places in LLVM
> (not many to be honest) where custom CallbackVH are used as key of
> DenseMap to solve my same problem
> but in different contexts.
> An example is class AliasSetTracker (llvm/Analysis/AliasSetTracker.h)
> which defines a
> nested class ASTCallbackVH as extension of CallbackVH.
> Probably it would be a good idea if in the future we clean some old code
> where we use DenseMap + custom CallbackVH
> in place of ValueMap. But that is clearly out of the scope of this patch
> :).

Great!

-    DenseMap<Value*, Value*> SunkAddrs;
+    ValueMap<Value*,Value*> SunkAddrs;

Should be a space between the template arguments.

Thanks for the patch, please commit it!

Nick



More information about the llvm-commits mailing list