<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On May 13, 2013, at 7:12 AM, Jeremy Lakeman <<a href="mailto:Jeremy.Lakeman@gmail.com">Jeremy.Lakeman@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><div><div><div>A: When the types are created in different contexts.<br><br></div><div>I've been running into a module validation error related to phi nodes produced by the GVN pass, where the types of the incoming values aren't the same instance of IntegerType i1.<br>
<br></div>I'm not certain I've found the root cause of the problem yet, it's probably due to my handling of LLVMContext & Module life cycles, and this is my first real look at llvm's source. <br><br>This patch at least makes my problem go away;<br>
<br>@@ -2195,11 +2200,11 @@ bool GVN::processInstruction(Instruction *I) {<br> BasicBlock *Parent = BI->getParent();<br> bool Changed = false;<br><br>- Value *TrueVal = ConstantInt::getTrue(TrueSucc->getContext());<br>
+ Value *TrueVal = ConstantInt::getTrue(BranchCond->getContext());<br> BasicBlockEdge TrueE(Parent, TrueSucc);<br> Changed |= propagateEquality(BranchCond, TrueVal, TrueE);<br><br>- Value *FalseVal = ConstantInt::getFalse(FalseSucc->getContext());<br>
+ Value *FalseVal = ConstantInt::getFalse(BranchCond->getContext());<br> BasicBlockEdge FalseE(Parent, FalseSucc);<br> Changed |= propagateEquality(BranchCond, FalseVal, FalseE);<br><br></div>Any other ideas about where I should look for the root problem? Is there any better documentation on how to deal with multiple LLVMContext instances?<br>
<br></div>I'm primarily creating multiple contexts to make sure my named structures aren't renamed during linking.</div></blockquote><br></div><div>You're going to get weird breakage doing that. Types and constants are uniqued per-context, and optimization passes depend on that to perform shallow equality comparisons on them. The <i>only</i> valid way to use multiple contexts is to have multiple completely independent copies of LLVM operating within the same address space.</div><div><br></div><div>--Owen</div></body></html>