[LLVMdev] Q: When is a boolean not a boolean?

Jeremy Lakeman Jeremy.Lakeman at gmail.com
Mon May 13 07:12:19 PDT 2013


A: When the types are created in different contexts.

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.

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.

This patch at least makes my problem go away;

@@ -2195,11 +2200,11 @@ bool GVN::processInstruction(Instruction *I) {
     BasicBlock *Parent = BI->getParent();
     bool Changed = false;

-    Value *TrueVal = ConstantInt::getTrue(TrueSucc->getContext());
+    Value *TrueVal = ConstantInt::getTrue(BranchCond->getContext());
     BasicBlockEdge TrueE(Parent, TrueSucc);
     Changed |= propagateEquality(BranchCond, TrueVal, TrueE);

-    Value *FalseVal = ConstantInt::getFalse(FalseSucc->getContext());
+    Value *FalseVal = ConstantInt::getFalse(BranchCond->getContext());
     BasicBlockEdge FalseE(Parent, FalseSucc);
     Changed |= propagateEquality(BranchCond, FalseVal, FalseE);

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?

I'm primarily creating multiple contexts to make sure my named structures
aren't renamed during linking.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130513/285316c0/attachment.html>


More information about the llvm-dev mailing list