我從LLVM 3.6.1遷移到LLVM 3.9.0。在LLVMv3.6這段代碼執行罰款,但在LLVMv3.9我斷言失敗:llvm 3.9 ConstantExpr :: getAsInstruction for Instruction :: GetElementPtr get assertion
... include/llvm/IR/Instructions.h:866: static llvm::GetElementPtrInst* llvm::GetElementPtrInst::Create(llvm::Type*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, const llvm::Twine&, llvm::Instruction*): Assertion `PointeeType == cast<PointerType>(Ptr->getType()->getScalarType())->getElementType()' failed.
我的代碼是:
pOperand = pStore->getValueOperand();
if(!pOperand)
return;
pConstExpr = dyn_cast<ConstantExpr>(pOperand);
if(!pConstExpr)
return;
if(pConstExpr->getOpcode() == Instruction::GetElementPtr)
{
pGEPInst = dyn_cast<GetElementPtrInst>(pConstExpr->getAsInstruction()); // Assertion !!!
if(!pGEPInst)
return;
... other code ...
}
編輯:
這個問題出現的構建,只有當LLVM-3.9.0的類型是DEBUG。 RELEASE-build沒有這個問題!
你能提供IR嗎? – Joky
事實上,它沒有在發佈中抱怨只是隱藏了一個可能的錯誤,你會在某個時候遇到麻煩。 – Joky