1
我调试了两天!搜索官方文档和谷歌后,找不到任何原因或信息。在LLVM中调用CreatePHI()时出错
是LLVM的bug吗?请帮帮我。
(LLVM版本:3.7.1)
错误信息:
Assertion failed: HasHungOffUses && "alloc must have hung off uses", , file I:\GitHub\Def\llvm\lib\IR\User.cpp, line 44
代码:
see the screenshot of call stack:
Value* ASTIf::codegen(Gen & gen)
{
// if
Value *v_ret(nullptr);
auto *thefunc = gen.builder.GetInsertBlock()->getParent();
Value *v_cond = cond->codegen(gen);
auto *b_then = BasicBlock::Create(gen.context, "then", thefunc);
auto *b_else = BasicBlock::Create(gen.context, "else", thefunc);
auto *b_merge = BasicBlock::Create(gen.context, "ifcont", thefunc);
// 跳转分支
gen.builder.CreateCondBr(v_cond, b_then, b_else);
// then block
gen.builder.SetInsertPoint(b_then);
Value *v_then = pthen->codegen(gen);
gen.builder.CreateBr(b_merge);
b_then = gen.builder.GetInsertBlock();
// else block
gen.builder.SetInsertPoint(b_else);
Value *v_else = pelse ? pelse->codegen(gen) : nullptr;
gen.builder.CreateBr(b_merge);
b_else = gen.builder.GetInsertBlock();
// merge block
gen.builder.SetInsertPoint(b_merge);
// if error: HasHungOffUses
if (canphi) {
PHINode *phi = gen.builder.CreatePHI( ////////// error line /////////
v_then->getType(), 2, "iftmp");
phi->addIncoming(v_then, b_then);
phi->addIncoming(v_else, b_else);
v_ret = phi;
}
return v_ret;
}
征求意见的通知加调用堆栈
我想我们需要知道触发该断言的条件是什么?什么是callstack? –
什么是你的情况下的'pelse'?我认为给addIncoming一个nullptr不是一个好主意。 –
看着代码使用强大的接缝我,也许你有堆腐败在你的非llvm代码的某处。 –