<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">IIRC, assertions are enabled by default if you're building from SVN, and disabled by default if you're building from a release tarball.<div><br></div><div>--Owen</div><div><br><div><div>On Jan 26, 2012, at 3:11 PM, Preston Briggs wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><br></div>My problem was that the constructor for DenseMap has an undocumented constraint.<blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div><br><font face="'courier new', monospace">explicit DenseMap(unsigned NumInitBuckets = 0) {</font></div>
<div><font face="'courier new', monospace">  init(NumInitBuckets);</font></div><div><font face="'courier new', monospace">}</font></div></div><div><br></div></blockquote><div>if given an explicit argument, requires that the argument be a power of 2.</div>
<div><br></div><div>It's checked by an assert in init(), but for some reason my code didn't trip the assertion.</div><div>Is there a special way I must make to enable asserts?</div><div><br></div><div>Thanks,</div>
<div>Preston</div><div><br><br><div class="gmail_quote">On Wed, Jan 25, 2012 at 9:44 PM, Preston Briggs <span dir="ltr"><<a href="mailto:preston.briggs@gmail.com">preston.briggs@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Reading the LLVM Programmer's Manual, the description of DenseSet mentions:<div><br><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="arial, helvetica, sans-serif"><i><span style="text-align:left">Note that DenseSet has the same requirements for the value type that </span><a href="http://llvm.org/docs/ProgrammersManual.html#dss_densemap" style="text-align:left" target="_blank">DenseMap</a><span style="text-align:left"> has.</span></i></font></div>

</blockquote><font face="Times"><br></font><div><font face="arial, helvetica, sans-serif">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 <i>keys</i> have special requirements, which aren't entirely clear to me.  It says</font></div>

</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="arial, helvetica, sans-serif"><br></font></div><div><span style="text-align:left"><font face="arial, helvetica, sans-serif"><i>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.</i></font></span></div>

<div><span style="text-align:left"><font face="arial, helvetica, sans-serif"><br></font></span></div></blockquote><div style="text-align:left"><font face="arial, helvetica, sans-serif">Will my code fail to compile if the required specialization of DenseMapInfo is not present?</font></div>

<div style="text-align:left"><font face="arial, helvetica, sans-serif"><br></font></div><div style="text-align:left"><font face="arial, helvetica, sans-serif">I wonder all these things because I've tripped across a problem where a method hangs repeatably, and I don't see the problem.</font></div>

<div style="text-align:left"><font face="arial, helvetica, sans-serif"><br></font></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div style="text-align:left"><div><font face="'courier new', monospace">typedef SmallVector<BasicBlock *, 4> Frontier;</font></div>

</div><div style="text-align:left"><div><font face="'courier new', monospace">DenseMap<BasicBlock *, Frontier> frontier(blocks*3/2);</font></div></div><div style="text-align:left"><div><font face="'courier new', monospace"><br>

</font></div><div><font face="'courier new', monospace">BasicBlock *Xblock = ...</font></div><div><font face="'courier new', monospace"><br></font></div></div><div style="text-align:left"><div><font face="'courier new', monospace">errs() << "start\n";</font></div>

</div><div style="text-align:left"><div><font face="'courier new', monospace">Frontier &f = frontier[Xblock];    // Xblock is not yet represented in frontier</font></div></div><div style="text-align:left"><div>

<font face="'courier new', monospace">errs() << "finish\n";</font></div></div></blockquote><div style="text-align:left"><font face="arial, helvetica, sans-serif"><div><br></div><div>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 </div>

<div><br></div></font></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div style="text-align:left"><div><font face="'courier new', monospace">DenseMap<BasicBlock *, Frontier *> frontier(blocks*3/2);</font></div>

</div></blockquote><font face="arial, helvetica, sans-serif"><div><font face="arial, helvetica, sans-serif"><br></font></div>but trip over the same problem in the same place.<br></font><div style="text-align:left"><font face="arial, helvetica, sans-serif"><div>

<br></div><div>I've used the DenseMap successfully in several other places, so I'm not sure that's gone wrong here.</div><div><br></div><div>Any ideas?</div><div><br></div><div>Thanks,</div><div>Preston</div>
<div>
<br></div></font></div>
</blockquote></div><br></div>
_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br></div></body></html>