I think that after splitting, instructions are located in different basic blocks. If I split the block into 10-15 instructions, all is OK. How can I predict/check and avoid this errors?
asked Nov 7, 2013 at 9:53 301 1 1 gold badge 3 3 silver badges 9 9 bronze badgesIf your pass just splits basicblocks, and takes as input a correct IR file, then there is no reason to be errors of dominations in the resulting IR. There are some reason that could induce this kind of error : * you moved or created new instructions * you added transitions between basicblocks that did not exist before
Commented Nov 7, 2013 at 12:50It would help if you provided more details. A minimal LLVM IR snippet of the code before splitting, and then after splitting. In general what @JulienH. said makes sense.
Commented Nov 7, 2013 at 13:02I'm sorry, i have other passes and one of them add/modifies instructions via llvm::InlineAsm and llvm::ReplaceInstWithInst
Commented Nov 8, 2013 at 6:15 What checks contained in LLVM may be added to avoid such errors? Commented Nov 8, 2013 at 6:45Your post still misses details, it would help if I could see the full IR, or at least a larger subset of it. Anyway, each time you delete an instruction, you should check that this instruction has no later use (in your error message, you see there exist some use_empty() function in LLVM)
Commented Nov 12, 2013 at 8:59In your first version, you had instruction after a terminator instruction, which was incorrect since this instruction is never executed.
In your second version (not mentioned here, please use stackoverflow instead of private emails. ) are using %call (in the store inst) before defining it (%call = . ), so clearly your definition does not precede every use. But as I said, the store should not be after the invoke, because invoke is a terminatorinst.
The solution is to put your store in the next basic block (you can create a new one) :
%invoke.cont %call = invoke i8* @_ZNKSs5c_strEv(%"class.std::basic_string"* @loadedFile) to label %invoke.cont2_before unwind label %lpad1 invoke.cont2_before: ; preds = %invoke.cont store i8* %call, i8** %reduced_var br label %invoke.cont2 invoke.cont2: ; preds = %main_block, %invoke.cont2_before %call4 = invoke i32 @_ZStorSt13_Ios_OpenmodeS_(i32 8, i32 16) to label %invoke.cont3_before unwind label %lpad1