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代碼的某處。 –