Commit a9832bf5 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Lots more fixes

parent 30d4579b
......@@ -640,7 +640,6 @@ static ConcreteCompilerVariable* _call(IREmitter& emitter, const OpInfo& info, l
assert(llvm::cast<llvm::FunctionType>(llvm::cast<llvm::PointerType>(func->getType())->getElementType())
->getReturnType() == g.llvm_value_type_ptr);
rtn = emitter.getBuilder()->CreateIntToPtr(uncasted, g.llvm_value_type_ptr);
emitter.setType(rtn, RefType::OWNED);
} else {
// printf("\n");
// func->dump();
......@@ -651,9 +650,10 @@ static ConcreteCompilerVariable* _call(IREmitter& emitter, const OpInfo& info, l
// printf("%ld %ld\n", llvm_args.size(), args.size());
// printf("\n");
rtn = emitter.createCall(info.unw_info, func, llvm_args, target_exception_style);
emitter.setType(rtn, RefType::OWNED);
}
if (rtn_type->getBoxType() == rtn_type)
emitter.setType(rtn, RefType::OWNED);
assert(rtn->getType() == rtn_type->llvmType());
if (target_exception_style == CAPI) {
......
......@@ -523,6 +523,8 @@ public:
}
llvm::Value* setType(llvm::Value* v, RefType reftype) {
assert(llvm::isa<PointerType>(v->getType()));
irstate->getRefcounts()->setType(v, reftype);
return v;
}
......@@ -731,10 +733,16 @@ private:
= emitter.getBuilder()->CreatePHI(g.llvm_value_type_ptr, incoming_exc_state.size());
llvm::PHINode* phi_exc_tb
= emitter.getBuilder()->CreatePHI(g.llvm_value_type_ptr, incoming_exc_state.size());
emitter.setType(phi_exc_type, RefType::OWNED);
emitter.setType(phi_exc_value, RefType::OWNED);
emitter.setType(phi_exc_tb, RefType::OWNED);
for (auto e : this->incoming_exc_state) {
phi_exc_type->addIncoming(e.exc_type->getValue(), e.from_block);
phi_exc_value->addIncoming(e.exc_value->getValue(), e.from_block);
phi_exc_tb->addIncoming(e.exc_tb->getValue(), e.from_block);
emitter.refConsumed(e.exc_type->getValue(), e.from_block->getTerminator());
emitter.refConsumed(e.exc_value->getValue(), e.from_block->getTerminator());
emitter.refConsumed(e.exc_tb->getValue(), e.from_block->getTerminator());
}
exc_type = new ConcreteCompilerVariable(UNKNOWN, phi_exc_type);
exc_value = new ConcreteCompilerVariable(UNKNOWN, phi_exc_value);
......@@ -786,6 +794,7 @@ private:
emitter.setType(name_arg, RefType::BORROWED);
llvm::Value* r
= emitter.createCall2(unw_info, g.funcs.importFrom, converted_module->getValue(), name_arg);
emitter.setType(r, RefType::OWNED);
CompilerVariable* v = new ConcreteCompilerVariable(UNKNOWN, r);
return v;
......@@ -802,6 +811,7 @@ private:
llvm::Value* r = emitter.createCall2(unw_info, g.funcs.importStar, converted_module->getValue(),
irstate->getGlobals());
emitter.setType(r, RefType::OWNED);
CompilerVariable* v = new ConcreteCompilerVariable(UNKNOWN, r);
return v;
}
......@@ -826,6 +836,7 @@ private:
{ getConstantInt(level, g.i32), converted_froms->getValue(),
emitter.setType(embedRelocatablePtr(module_name.c_str(), g.i8_ptr), RefType::BORROWED),
getConstantInt(module_name.size(), g.i64) });
emitter.setType(imported, RefType::OWNED);
ConcreteCompilerVariable* v = new ConcreteCompilerVariable(UNKNOWN, imported);
return v;
}
......@@ -1020,6 +1031,7 @@ private:
CompilerVariable* evalDict(AST_Dict* node, const UnwindInfo& unw_info) {
llvm::Value* v = emitter.getBuilder()->CreateCall(g.funcs.createDict);
emitter.setType(v, RefType::OWNED);
ConcreteCompilerVariable* rtn = new ConcreteCompilerVariable(DICT, v);
if (node->keys.size()) {
static BoxedString* setitem_str = getStaticString("__setitem__");
......@@ -1070,6 +1082,7 @@ private:
}
llvm::Value* v = emitter.getBuilder()->CreateCall(g.funcs.createList);
emitter.setType(v, RefType::OWNED);
ConcreteCompilerVariable* rtn = new ConcreteCompilerVariable(LIST, v);
llvm::Value* f = g.funcs.listAppendInternal;
......@@ -1251,6 +1264,7 @@ private:
std::vector<llvm::Value*> args{ cvar->getValue() };
llvm::Value* rtn = emitter.createCall(unw_info, g.funcs.repr, args);
rtn = emitter.getBuilder()->CreateBitCast(rtn, g.llvm_value_type_ptr);
emitter.setType(rtn, RefType::OWNED);
return new ConcreteCompilerVariable(STR, rtn);
}
......@@ -1263,6 +1277,7 @@ private:
}
llvm::Value* v = emitter.getBuilder()->CreateCall(g.funcs.createSet);
emitter.setType(v, RefType::OWNED);
ConcreteCompilerVariable* rtn = new ConcreteCompilerVariable(SET, v);
static BoxedString* add_str = getStaticString("add");
......@@ -1363,6 +1378,7 @@ private:
llvm::Value* rtn
= emitter.createCall2(unw_info, g.funcs.yield, convertedGenerator->getValue(), convertedValue->getValue());
emitter.setType(rtn, RefType::OWNED);
return new ConcreteCompilerVariable(UNKNOWN, rtn);
}
......@@ -1824,9 +1840,11 @@ private:
// We could patchpoint this or try to avoid the overhead, but this should only
// happen when the assertion is actually thrown so I don't think it will be necessary.
static BoxedString* AssertionError_str = getStaticString("AssertionError");
llvm_args.push_back(emitter.createCall2(
unw_info, g.funcs.getGlobal, irstate->getGlobals(),
emitter.setType(embedRelocatablePtr(AssertionError_str, g.llvm_boxedstring_type_ptr), RefType::BORROWED)));
llvm_args.push_back(emitter.setType(
emitter.createCall2(unw_info, g.funcs.getGlobal, irstate->getGlobals(),
emitter.setType(embedRelocatablePtr(AssertionError_str, g.llvm_boxedstring_type_ptr),
RefType::BORROWED)),
RefType::OWNED));
ConcreteCompilerVariable* converted_msg = NULL;
if (node->msg) {
......
......@@ -1916,7 +1916,7 @@ Box* BoxedCApiFunction::tppCall(Box* _self, CallRewriteArgs* rewrite_args, ArgPa
RELEASE_ASSERT(0, "0x%x", flags);
}
assert(paramspec.totalReceived() < 3);
assert(paramspec.totalReceived() <= 3);
assert(!oargs);
if (rewrite_args) {
......
......@@ -667,7 +667,7 @@ Box* BoxedWrapperDescriptor::tppCall(Box* _self, CallRewriteArgs* rewrite_args,
RELEASE_ASSERT(0, "%d", flags);
}
assert(paramspec.totalReceived() < 3);
assert(paramspec.totalReceived() <= 3);
assert(!oargs);
switch (paramspec.totalReceived()) {
......
......@@ -1673,8 +1673,8 @@ Box* descriptorClsSpecialCases(GetattrRewriteArgs* rewrite_args, BoxedClass* cls
if (rewrite_args) {
// return an unbound instancemethod
RewriterVar* r_cls = rewrite_args->obj;
RewriterVar* r_rtn
= rewrite_args->rewriter->call(true, (void*)boxUnboundInstanceMethod, r_descr, r_cls);
RewriterVar* r_rtn = rewrite_args->rewriter->call(true, (void*)boxUnboundInstanceMethod, r_descr, r_cls)
->setType(RefType::OWNED);
rewrite_args->setReturn(r_rtn, ReturnConvention::HAS_RETURN);
}
return boxUnboundInstanceMethod(descr, cls);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment