[LLVMdev] dense maps

Preston Briggs preston.briggs at gmail.com
Wed Jan 25 21:44:08 PST 2012


Reading the LLVM Programmer's Manual, the description of DenseSet mentions:

*Note that DenseSet has the same requirements for the value type that
DenseMap <http://llvm.org/docs/ProgrammersManual.html#dss_densemap> has.*


But when I read about DenseMap, I don't really see any requirements for the
values, just a warning about space.  On the other hand, the *keys* have
special requirements, which aren't entirely clear to me.  It says


*Finally, you must implement a partial specialization of DenseMapInfo for
the key that you want, if it isn't already supported. This is required to
tell DenseMap about two special marker values (which can never be inserted
into the map) that it needs internally.*

Will my code fail to compile if the required specialization of DenseMapInfo
is not present?

I wonder all these things because I've tripped across a problem where a
method hangs repeatably, and I don't see the problem.

typedef SmallVector<BasicBlock *, 4> Frontier;
DenseMap<BasicBlock *, Frontier> frontier(blocks*3/2);

BasicBlock *Xblock = ...

errs() << "start\n";
Frontier &f = frontier[Xblock];    // Xblock is not yet represented in
frontier
errs() << "finish\n";


It compiles fine (as part of a function-level pass), but the call
frontier[Xblock] fails (hangs) after several successful calls.  I tried
replacing the declaration of frontier with

DenseMap<BasicBlock *, Frontier *> frontier(blocks*3/2);


but trip over the same problem in the same place.

I've used the DenseMap successfully in several other places, so I'm not
sure that's gone wrong here.

Any ideas?

Thanks,
Preston
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120125/854da6bb/attachment.html>


More information about the llvm-dev mailing list