我用最少的指令(通常 3-5)分割所有基本块:
llvm::SplitBlock(BasicBlock, &*BasicBlockiter, Pass);
并尝试从 IR 获取目标文件
llc -filetype=obj 2.ll
我收到以下错误:
Instruction does not dominate all uses!
%1 = alloca i32
%mul = load i32* %1
Instruction does not dominate all uses!
%1 = alloca i32
%99 = load i32* %1
and
While deleting: i32 %
Use still stuck around after Def is destroyed: %var = alloca i32
Assertion failed: use_empty() && "Uses remain when a value is destroyed!"
and
error: expected instruction opcode
invoke.cont2: ; preds = %main_block, %invoke
.cont
IR:
invoke.cont2: ; preds = %main_block, %invoke.cont
%call4 = invoke i32 @_ZStorSt13_Ios_OpenmodeS_(i32 8, i32 16)
to label %invoke.cont3 unwind label %lpad1
store i32 %call4, i32* %var4
我认为拆分后,指令位于不同的基本块中。
如果我将块拆分为 10-15 条指令,则一切正常。
我如何预测/检查并避免这种错误?
在您的第一个版本中,您在终止符指令之后有指令,这是不正确的,因为该指令从未执行。
在您的第二个版本中(此处未提及,请使用 stackoverflow 而不是私人电子邮件...)在定义它之前使用 %call (在商店实例中)(%call = ...),所以显然您的定义并不先于每个使用...
但正如我所说,存储不应该在调用之后,因为调用是一个终止符。
解决方案是将您的商店放在下一个基本块中(您可以创建一个新的):
%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
etc...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)