[llvm] r228200 - IR: Define MDNode uniquing sets automatically, NFC

Duncan P. N. Exon Smith dexonsmith at apple.com
Wed Feb 4 14:08:52 PST 2015


> On 2015-Feb-04, at 14:07, David Blaikie <dblaikie at gmail.com> wrote:
> 
> 
> 
> On Wed, Feb 4, 2015 at 2:06 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
> 
> > On 2015-Feb-04, at 14:02, David Blaikie <dblaikie at gmail.com> wrote:
> >
> >
> >
> > On Wed, Feb 4, 2015 at 1:46 PM, Duncan P. N. Exon Smith <dexonsmith at apple.com> wrote:
> > Author: dexonsmith
> > Date: Wed Feb  4 15:46:12 2015
> > New Revision: 228200
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=228200&view=rev
> > Log:
> > IR: Define MDNode uniquing sets automatically, NFC
> >
> > Modified:
> >     llvm/trunk/lib/IR/LLVMContextImpl.h
> >
> > Modified: llvm/trunk/lib/IR/LLVMContextImpl.h
> > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContextImpl.h?rev=228200&r1=228199&r2=228200&view=diff
> > ==============================================================================
> > --- llvm/trunk/lib/IR/LLVMContextImpl.h (original)
> > +++ llvm/trunk/lib/IR/LLVMContextImpl.h Wed Feb  4 15:46:12 2015
> > @@ -357,9 +357,8 @@ public:
> >    DenseMap<Value *, ValueAsMetadata *> ValuesAsMetadata;
> >    DenseMap<Metadata *, MetadataAsValue *> MetadataAsValues;
> >
> > -  DenseSet<MDTuple *, MDTupleInfo> MDTuples;
> > -  DenseSet<MDLocation *, MDLocationInfo> MDLocations;
> > -  DenseSet<GenericDebugNode *, GenericDebugNodeInfo> GenericDebugNodes;
> > +#define HANDLE_MDNODE_LEAF(CLASS) DenseSet<CLASS *, CLASS##Info> CLASS##s;
> >
> > I /think/ (but could well be wrong) that the usual style for def file inclusions is to undef the relevant macro immediately after the inclusion, so it doesn't leak into other things, etc.
> >
> > +#include "llvm/IR/Metadata.def"
> 
> Metadata.def ends with:
> 
> #undef HANDLE_METADATA
> #undef HANDLE_METADATA_LEAF
> #undef HANDLE_METADATA_BRANCH
> #undef HANDLE_MDNODE_LEAF
> #undef HANDLE_MDNODE_BRANCH
> 
> Ah, dandy. (maybe that's the common idiom - if not, might be nice to update existing .def files to be so smart - I'll keep it in mind next time I come across a #include .def)

I spotted it somewhere and copied it, although I admit I'm not sure
how widespread it is.  Definitely better than relying on the call-site
to update it :).





More information about the llvm-commits mailing list