Hi,>> entry: >> .... >> %34 = icmp ne i32 %33, 15 >> br i1 %34, label %then, label %else >> >> then: ; preds = %entry >> %returnValue = or i1 true, false >> .... >> br label %ifmerge >> >> else: ; preds = %entry >> br label %ifmerge >> >> ifmerge: ; preds = %else, %then >> ... >> %41 = icmp ne i32 %40, 15 >> br i1 %41, label %then1, label %else3 >> >> then1: ; preds = %ifmerge >> %returnValue2 = or i1 true, %returnValueif control flow goes: "entry" -> "else" -> "ifmerge" -> "then1", then you will try to use %returnValue in then1 without ever defining it. This is what the error message is trying to tell you. Ciao, Duncan.>> >> else3: ; preds = %ifmerge >> br label %ifmerge4 >> >> ifmerge4: ; preds = %else3, %then1 >> .... >> >> And I'm getting the following error: >> Instruction does not dominate all uses! >> %returnValue = or i1 true, false >> %returnValue2 = or i1 true, %returnValue >> Broken module found, compilation aborted!Ciao, Duncan.
Thank you guys, now I understand the problem. I am trying to avoid using stack memory (or mutable variable is the term used in the tutorial). I am also trying to optimize the code as much as I can before using optimizer passes such as mem2reg (to reduce the compile time as well). With regards, --Cuong Duncan Sands wrote:> > Hi, > >>> entry: >>> .... >>> %34 = icmp ne i32 %33, 15 >>> br i1 %34, label %then, label %else >>> >>> then: ; preds = %entry >>> %returnValue = or i1 true, false >>> .... >>> br label %ifmerge >>> >>> else: ; preds = %entry >>> br label %ifmerge >>> >>> ifmerge: ; preds = %else, %then >>> ... >>> %41 = icmp ne i32 %40, 15 >>> br i1 %41, label %then1, label %else3 >>> >>> then1: ; preds = %ifmerge >>> %returnValue2 = or i1 true, %returnValue > > if control flow goes: "entry" -> "else" -> "ifmerge" -> "then1", then you > will > try to use %returnValue in then1 without ever defining it. This is what > the > error message is trying to tell you. > > Ciao, Duncan. > >>> >>> else3: ; preds = %ifmerge >>> br label %ifmerge4 >>> >>> ifmerge4: ; preds = %else3, >>> %then1 >>> .... >>> >>> And I'm getting the following error: >>> Instruction does not dominate all uses! >>> %returnValue = or i1 true, false >>> %returnValue2 = or i1 true, %returnValue >>> Broken module found, compilation aborted! > > Ciao, Duncan. > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-- View this message in context: http://old.nabble.com/Avoiding-Constant-Folding-tp31838929p31844741.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Hi Cuong,> I am trying to avoid using stack memory (or mutable variable is the term > used in the tutorial). I am also trying to optimize the code as much as I > can before using optimizer passes such as mem2reg (to reduce the compile > time as well).I don't think there is much point in avoiding stack variables (using them makes your life much simpler -> easier to have your front-end be correct; passes like mem2reg will turn your variables into registers if possible anyway). And there's also not much point in trying to keep the bitcode small so as to speed up the optimizers: it will just make your front-end more complicated, while probably the gains (if any) are insignificant. My advice is to keep your front-end as simple as possible. You can run some per-function passes as you output each function, to clean it up and reduce the bitcode size, for example simplifycfg+scalarrepl+instcombine, if memory usage is a problem. Ciao, Duncan.