Commit 83fb05b6 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Rebase to LLVM r225000

Changes here due to the Metadata/Value split.

Had some issues with intermediate commits due to leak
detecting; not seeing them on this later commit.  Hopefully
everything is ok...
parent 3def08b4
......@@ -366,9 +366,14 @@ endef
.PHONY: format check_format
format:
cd src && find \( -name '*.cpp' -o -name '*.h' \) -print0 | xargs -0 $(LLVM_BIN)/clang-format -style=file -i
ifneq ($(USE_CMAKE),1)
check_format:
$(ECHO) checking formatting...
$(VERB) cd src && ../tools/check_format.sh $(LLVM_BIN)/clang-format
else
check_format:
$(NINJA) -C $(HOME)/pyston-build-release check-format
endif
.PHONY: analyze
analyze:
......
......@@ -627,9 +627,10 @@ static void emitBBs(IRGenState* irstate, const char* bb_type, GuardList& out_gua
llvm::Value* reopt_test = emitter->getBuilder()->CreateICmpSGT(
new_call_count, getConstantInt(REOPT_THRESHOLDS[effort], g.i64));
llvm::Value* md_vals[]
= { llvm::MDString::get(g.context, "branch_weights"), getConstantInt(1), getConstantInt(1000) };
llvm::MDNode* branch_weights = llvm::MDNode::get(g.context, llvm::ArrayRef<llvm::Value*>(md_vals));
llvm::Metadata* md_vals[] = { llvm::MDString::get(g.context, "branch_weights"),
llvm::ConstantAsMetadata::get(getConstantInt(1)),
llvm::ConstantAsMetadata::get(getConstantInt(1000)) };
llvm::MDNode* branch_weights = llvm::MDNode::get(g.context, llvm::ArrayRef<llvm::Metadata*>(md_vals));
llvm::BranchInst* guard = emitter->getBuilder()->CreateCondBr(
reopt_test, reopt_bb, llvm_entry_blocks[source->cfg->getStartingBlock()], branch_weights);
......@@ -1055,29 +1056,15 @@ static llvm::MDNode* setupDebugInfo(SourceInfo* source, llvm::Function* f, std::
std::string producer = "pyston; git rev " STRINGIFY(GITREV);
llvm::DIFile file = builder.createFile(fn, dir);
#if LLVMREV < 214132
llvm::DIArray param_types = builder.getOrCreateArray(llvm::None);
#else
llvm::DITypeArray param_types = builder.getOrCreateTypeArray(llvm::None);
#endif
llvm::DICompositeType func_type = builder.createSubroutineType(file, param_types);
llvm::DISubprogram func_info = builder.createFunction(file, f->getName(), f->getName(), file, lineno, func_type,
false, true, lineno + 1, 0, true, f);
// The 'variables' field gets initialized with a tag-prefixed array, but
// a later verifier asserts that there is no tag. Replace it with an empty array:
func_info.getVariables()->replaceAllUsesWith(builder.getOrCreateArray(llvm::ArrayRef<llvm::Value*>()));
llvm::DICompileUnit compile_unit
= builder.createCompileUnit(llvm::dwarf::DW_LANG_Python, fn, dir, producer, true, "", 0);
llvm::DIArray subprograms = builder.getOrCreateArray(&*func_info);
compile_unit.getSubprograms()->replaceAllUsesWith(subprograms);
compile_unit.getEnumTypes()->replaceAllUsesWith(builder.getOrCreateArray(llvm::ArrayRef<llvm::Value*>()));
compile_unit.getRetainedTypes()->replaceAllUsesWith(builder.getOrCreateArray(llvm::ArrayRef<llvm::Value*>()));
compile_unit.getGlobalVariables()->replaceAllUsesWith(builder.getOrCreateArray(llvm::ArrayRef<llvm::Value*>()));
compile_unit.getImportedEntities()->replaceAllUsesWith(builder.getOrCreateArray(llvm::ArrayRef<llvm::Value*>()));
builder.finalize();
return func_info;
}
......
......@@ -320,9 +320,10 @@ private:
void createExprTypeGuard(llvm::Value* check_val, AST_expr* node, CompilerVariable* node_value) {
assert(check_val->getType() == g.i1);
llvm::Value* md_vals[]
= { llvm::MDString::get(g.context, "branch_weights"), getConstantInt(1000), getConstantInt(1) };
llvm::MDNode* branch_weights = llvm::MDNode::get(g.context, llvm::ArrayRef<llvm::Value*>(md_vals));
llvm::Metadata* md_vals[]
= { llvm::MDString::get(g.context, "branch_weights"), llvm::ConstantAsMetadata::get(getConstantInt(1000)),
llvm::ConstantAsMetadata::get(getConstantInt(1)) };
llvm::MDNode* branch_weights = llvm::MDNode::get(g.context, llvm::ArrayRef<llvm::Metadata*>(md_vals));
// For some reason there doesn't seem to be the ability to place the new BB
// right after the current bb (can only place it *before* something else),
......@@ -717,7 +718,7 @@ private:
void _addAnnotation(const char* message) {
llvm::Instruction* inst = emitter.getBuilder()->CreateCall(
llvm::Intrinsic::getDeclaration(g.cur_module, llvm::Intrinsic::donothing));
llvm::Value* md_vals[] = { getConstantInt(0) };
llvm::Metadata* md_vals[] = { llvm::ConstantAsMetadata::get(getConstantInt(0)) };
llvm::MDNode* mdnode = llvm::MDNode::get(g.context, md_vals);
inst->setMetadata(message, mdnode);
}
......@@ -1855,9 +1856,10 @@ private:
OSR_THRESHOLD = 100;
llvm::Value* osr_test = emitter.getBuilder()->CreateICmpSGT(newcount, getConstantInt(OSR_THRESHOLD));
llvm::Value* md_vals[]
= { llvm::MDString::get(g.context, "branch_weights"), getConstantInt(1), getConstantInt(1000) };
llvm::MDNode* branch_weights = llvm::MDNode::get(g.context, llvm::ArrayRef<llvm::Value*>(md_vals));
llvm::Metadata* md_vals[]
= { llvm::MDString::get(g.context, "branch_weights"), llvm::ConstantAsMetadata::get(getConstantInt(1)),
llvm::ConstantAsMetadata::get(getConstantInt(1000)) };
llvm::MDNode* branch_weights = llvm::MDNode::get(g.context, llvm::ArrayRef<llvm::Metadata*>(md_vals));
emitter.getBuilder()->CreateCondBr(osr_test, onramp, normal_target, branch_weights);
// Emitting the actual OSR:
......
......@@ -140,16 +140,16 @@ bool updateTBAA(Function* f) {
assert(tbaa->getNumOperands() == 3);
if (!isConstant(llvm::cast<MDNode>(tbaa->getOperand(0)), llvm::cast<ConstantInt>(tbaa->getOperand(2))->getSExtValue())) {
if (!isConstant(llvm::cast<MDNode>(tbaa->getOperand(0)), llvm::cast<ConstantInt>(llvm::cast<ConstantAsMetadata>(tbaa->getOperand(2))->getValue())->getSExtValue())) {
continue;
}
std::vector<Value*> operands;
std::vector<Metadata*> operands;
for (int i = 0; i < tbaa->getNumOperands(); i++) {
operands.push_back(tbaa->getOperand(i));
}
operands.push_back(ConstantInt::get(Type::getInt64Ty(c), 1));
operands.push_back(ConstantAsMetadata::get(ConstantInt::get(Type::getInt64Ty(c), 1)));
MDNode *new_tbaa = MDNode::get(c, operands);
it->setMetadata(LLVMContext::MD_tbaa, new_tbaa);
......
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