<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.<br></div>