I'm make silly error (swap arguments in llvm::StroreInst constructor call:
llvm::Value* var = genExpr(bb,*varExpr,false);
llvm::Value* val = genExpr(bb,*valExpr,true );
llvm::StoreInst* lStore = new llvm::StoreInst(var,val,bb);
instead
assert(var && var->getType()->getTypeID()==llvm::Type::PointerTyID && "var
side isn't pointer type");
llvm::StoreInst* lStore = new llvm::StoreInst(val,var,bb);
For val with type T* and var with type T** error catched in verifier:
Stored value type does not match pointer operand type!
store "Type10::Class1"** %result, "Type10::Class1"* %1
"Type10::Class1"Broken module found, compilation aborted!
But if val type isn't pointer type error catched only deep in verifier code
with non helpful message:
Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible
type!"), function cast, file
/home/wanderer/pkg/build/llvm/src/llvm/include/Support/Casting.h, line 197.
I propose add assert
assert(Ptr && Ptr->getType()->getTypeID()==llvm::Type::PointerTyID && "Ptr
must have pointer type.")
in
llvm::StroreInst::init and llvm::LoadInst::init functions
This is requared including llvm/Type.h or moving init function definitions
to iMemory.cpp.
I don't known more acceptable variant and then sending as attachment both
versions: iMemory.patch1 and iMemory.patch2 .
Vladimir
iMemory.patch2 (2.02 KB)
iMemory.patch1 (897 Bytes)