Commit dc2ac2de authored by Kevin Modzelewski's avatar Kevin Modzelewski

Laying some groundwork for rebasing to LLVM trunk

Bunch of fairly-simple API changes to contend with.

Main problem is we're still running into those debuginfo issues.
parent ce37a0e4
...@@ -12,9 +12,7 @@ diff --git a/tools/scan-build/ccc-analyzer b/tools/scan-build/ccc-analyzer ...@@ -12,9 +12,7 @@ diff --git a/tools/scan-build/ccc-analyzer b/tools/scan-build/ccc-analyzer
index b5445e6..65f8455 100755 index b5445e6..65f8455 100755
--- a/tools/scan-build/ccc-analyzer --- a/tools/scan-build/ccc-analyzer
+++ b/tools/scan-build/ccc-analyzer +++ b/tools/scan-build/ccc-analyzer
@@ -43,7 +43,7 @@ if ($FindBin::Script =~ /c\+\+-analyzer/) { @@ -43,5 +43,5 @@ if ($FindBin::Script =~ /c\+\+-analyzer/) {
$Compiler = $ENV{'CCC_CXX'};
if (!defined $Compiler || ! -x $Compiler) { $Compiler = $DefaultCXXCompiler; }
- $Clang = $ENV{'CLANG_CXX'}; - $Clang = $ENV{'CLANG_CXX'};
+ $Clang = $ENV{'CCC_CLANG_CXX'}; + $Clang = $ENV{'CCC_CLANG_CXX'};
......
...@@ -12,25 +12,6 @@ Subject: [PATCH] Support emitting stackmap sections for ELF object files as ...@@ -12,25 +12,6 @@ Subject: [PATCH] Support emitting stackmap sections for ELF object files as
4 files changed, 138 insertions(+), 1 deletion(-) 4 files changed, 138 insertions(+), 1 deletion(-)
create mode 100644 test/CodeGen/X86/stackmap-elf.ll create mode 100644 test/CodeGen/X86/stackmap-elf.ll
diff --git a/lib/IR/Function.cpp b/lib/IR/Function.cpp
index c1fa372..d11727d 100644
--- a/lib/IR/Function.cpp
+++ b/lib/IR/Function.cpp
@@ -681,7 +681,13 @@ FunctionType *Intrinsic::getType(LLVMContext &Context,
while (!TableRef.empty())
ArgTys.push_back(DecodeFixedType(TableRef, Tys, Context));
- return FunctionType::get(ResultTy, ArgTys, false);
+ bool variadic = false;
+ if (ArgTys.size() && ArgTys.back() == Type::getVoidTy(Context)) {
+ variadic = true;
+ ArgTys.pop_back();
+ }
+
+ return FunctionType::get(ResultTy, ArgTys, variadic);
}
bool Intrinsic::isOverloaded(ID id) {
diff --git a/lib/MC/MCObjectFileInfo.cpp b/lib/MC/MCObjectFileInfo.cpp diff --git a/lib/MC/MCObjectFileInfo.cpp b/lib/MC/MCObjectFileInfo.cpp
index 931b354..40899c1 100644 index 931b354..40899c1 100644
--- a/lib/MC/MCObjectFileInfo.cpp --- a/lib/MC/MCObjectFileInfo.cpp
......
From b370f4621298ec557e356e21fa0fa675a21d2331 Mon Sep 17 00:00:00 2001
From: Kevin Modzelewski <kmod@dropbox.com>
Date: Fri, 21 Mar 2014 16:06:58 -0700
Subject: [PATCH] Support varargs intrinsics
diff --git a/lib/IR/Function.cpp b/lib/IR/Function.cpp
index c1fa372..d11727d 100644
--- a/lib/IR/Function.cpp
+++ b/lib/IR/Function.cpp
@@ -681,7 +681,13 @@ FunctionType *Intrinsic::getType(LLVMContext &Context,
while (!TableRef.empty())
ArgTys.push_back(DecodeFixedType(TableRef, Tys, Context));
- return FunctionType::get(ResultTy, ArgTys, false);
+ bool variadic = false;
+ if (ArgTys.size() && ArgTys.back() == Type::getVoidTy(Context)) {
+ variadic = true;
+ ArgTys.pop_back();
+ }
+
+ return FunctionType::get(ResultTy, ArgTys, variadic);
}
bool Intrinsic::isOverloaded(ID id) {
--
1.7.9.5
...@@ -41,7 +41,7 @@ void FunctionAddressRegistry::dumpPerfMap() { ...@@ -41,7 +41,7 @@ void FunctionAddressRegistry::dumpPerfMap() {
std::string out_path = "perf_map"; std::string out_path = "perf_map";
removeDirectoryIfExists(out_path); removeDirectoryIfExists(out_path);
llvm::error_code code; llvm_error_code code;
code = llvm::sys::fs::create_directory(out_path, false); code = llvm::sys::fs::create_directory(out_path, false);
assert(!code); assert(!code);
...@@ -139,7 +139,7 @@ public: ...@@ -139,7 +139,7 @@ public:
static StatCounter code_bytes("code_bytes"); static StatCounter code_bytes("code_bytes");
code_bytes.log(Obj.getData().size()); code_bytes.log(Obj.getData().size());
llvm::error_code code; llvm_error_code code;
for (llvm::object::symbol_iterator I = Obj.begin_symbols(), E = Obj.end_symbols(); I != E; for (llvm::object::symbol_iterator I = Obj.begin_symbols(), E = Obj.end_symbols(); I != E;
#if LLVMREV < 200442 #if LLVMREV < 200442
I = I.increment(code) I = I.increment(code)
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include "codegen/dis.h" #include "codegen/dis.h"
#if LLVMREV < 216983
#include <cstdio> #include <cstdio>
#include <iostream> #include <iostream>
#include <unordered_map> #include <unordered_map>
...@@ -225,3 +227,5 @@ void PystonJITEventListener::NotifyObjectEmitted(const llvm::ObjectImage& Obj) { ...@@ -225,3 +227,5 @@ void PystonJITEventListener::NotifyObjectEmitted(const llvm::ObjectImage& Obj) {
llvm::outs().flush(); llvm::outs().flush();
} }
} }
#endif
...@@ -92,10 +92,14 @@ static llvm::Module* loadStdlib() { ...@@ -92,10 +92,14 @@ static llvm::Module* loadStdlib() {
data = llvm::StringRef(STRIPPED_STDLIB_BC_START, size); data = llvm::StringRef(STRIPPED_STDLIB_BC_START, size);
} }
#if LLVMREV < 216583
llvm::MemoryBuffer* buffer = llvm::MemoryBuffer::getMemBuffer(data, "", false); llvm::MemoryBuffer* buffer = llvm::MemoryBuffer::getMemBuffer(data, "", false);
#else
std::unique_ptr<llvm::MemoryBuffer> buffer = llvm::MemoryBuffer::getMemBuffer(data, "", false);
#endif
// llvm::ErrorOr<llvm::Module*> m_or = llvm::parseBitcodeFile(buffer, g.context); // llvm::ErrorOr<llvm::Module*> m_or = llvm::parseBitcodeFile(buffer, g.context);
llvm::ErrorOr<llvm::Module*> m_or = llvm::getLazyBitcodeModule(buffer, g.context); llvm::ErrorOr<llvm::Module*> m_or = llvm::getLazyBitcodeModule(std::move(buffer), g.context);
RELEASE_ASSERT(m_or, ""); RELEASE_ASSERT(m_or, "");
llvm::Module* m = m_or.get(); llvm::Module* m = m_or.get();
assert(m); assert(m);
...@@ -115,9 +119,17 @@ private: ...@@ -115,9 +119,17 @@ private:
public: public:
MyObjectCache() : loaded(false) {} MyObjectCache() : loaded(false) {}
#if LLVMREV < 216002
virtual void notifyObjectCompiled(const llvm::Module* M, const llvm::MemoryBuffer* Obj) {} virtual void notifyObjectCompiled(const llvm::Module* M, const llvm::MemoryBuffer* Obj) {}
#else
virtual void notifyObjectCompiled(const llvm::Module* M, llvm::MemoryBufferRef Obj) {}
#endif
#if LLVMREV < 215566
virtual llvm::MemoryBuffer* getObject(const llvm::Module* M) { virtual llvm::MemoryBuffer* getObject(const llvm::Module* M) {
#else
virtual std::unique_ptr<llvm::MemoryBuffer> getObject(const llvm::Module* M) {
#endif
assert(!loaded); assert(!loaded);
loaded = true; loaded = true;
g.engine->setObjectCache(NULL); g.engine->setObjectCache(NULL);
...@@ -147,7 +159,7 @@ public: ...@@ -147,7 +159,7 @@ public:
llvm::StringRef data(start, size); llvm::StringRef data(start, size);
return llvm::MemoryBuffer::getMemBufferCopy(data, ""); return llvm::MemoryBuffer::getMemBufferCopy(data, "");
} }
}; };
static void handle_sigfpe(int signum) { static void handle_sigfpe(int signum) {
...@@ -171,9 +183,17 @@ void initCodegen() { ...@@ -171,9 +183,17 @@ void initCodegen() {
g.stdlib_module = loadStdlib(); g.stdlib_module = loadStdlib();
#if LLVMREV < 215967
llvm::EngineBuilder eb(new llvm::Module("empty_initial_module", g.context)); llvm::EngineBuilder eb(new llvm::Module("empty_initial_module", g.context));
eb.setEngineKind(llvm::EngineKind::JIT); // specify we only want the JIT, and not the interpreter fallback #else
jlvm::EngineBuilder eb(std::unique_ptr<llvm::Module>(new llvm::Module("empty_initial_module", g.context)));
#endif
#if LLVMREV < 216982
eb.setUseMCJIT(true); eb.setUseMCJIT(true);
#endif
eb.setEngineKind(llvm::EngineKind::JIT); // specify we only want the JIT, and not the interpreter fallback
eb.setMCJITMemoryManager(createMemoryManager()); eb.setMCJITMemoryManager(createMemoryManager());
// eb.setOptLevel(llvm::CodeGenOpt::None); // -O0 // eb.setOptLevel(llvm::CodeGenOpt::None); // -O0
// eb.setOptLevel(llvm::CodeGenOpt::Less); // -O1 // eb.setOptLevel(llvm::CodeGenOpt::Less); // -O1
...@@ -225,9 +245,14 @@ void initCodegen() { ...@@ -225,9 +245,14 @@ void initCodegen() {
g.engine->RegisterJITEventListener(tracebacks_listener); g.engine->RegisterJITEventListener(tracebacks_listener);
if (SHOW_DISASM) { if (SHOW_DISASM) {
#if LLVMREV < 216983
llvm::JITEventListener* listener = new PystonJITEventListener(); llvm::JITEventListener* listener = new PystonJITEventListener();
g.jit_listeners.push_back(listener); g.jit_listeners.push_back(listener);
g.engine->RegisterJITEventListener(listener); g.engine->RegisterJITEventListener(listener);
#else
fprintf(stderr, "The LLVM disassembler has been removed\n");
abort();
#endif
} }
initGlobalFuncs(g); initGlobalFuncs(g);
...@@ -240,7 +265,7 @@ void initCodegen() { ...@@ -240,7 +265,7 @@ void initCodegen() {
// There are some parts of llvm that are only configurable through command line args, // There are some parts of llvm that are only configurable through command line args,
// so construct a fake argc/argv pair and pass it to the llvm command line machinery: // so construct a fake argc/argv pair and pass it to the llvm command line machinery:
const char* llvm_args[] = { const char* llvm_args[] = {
"fake_name", "--enable-stackmap-liveness", "--enable-patchpoint-liveness", "fake_name", "--enable-patchpoint-liveness",
// Enabling and debugging fast-isel: // Enabling and debugging fast-isel:
//"--fast-isel", //"--fast-isel",
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "llvm/PassManager.h" #include "llvm/PassManager.h"
#include "llvm/Support/FileSystem.h" #include "llvm/Support/FileSystem.h"
#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetSubtargetInfo.h"
#include "llvm/Transforms/Instrumentation.h" #include "llvm/Transforms/Instrumentation.h"
#include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Scalar.h"
...@@ -65,7 +66,7 @@ void MyInserter::InsertHelper(llvm::Instruction* I, const llvm::Twine& Name, llv ...@@ -65,7 +66,7 @@ void MyInserter::InsertHelper(llvm::Instruction* I, const llvm::Twine& Name, llv
static void addIRDebugSymbols(llvm::Function* f) { static void addIRDebugSymbols(llvm::Function* f) {
llvm::legacy::PassManager mpm; llvm::legacy::PassManager mpm;
llvm::error_code code = llvm::sys::fs::create_directory(".debug_ir", true); llvm_error_code code = llvm::sys::fs::create_directory(".debug_ir", true);
assert(!code); assert(!code);
mpm.add(llvm::createDebugIRPass(false, false, ".debug_ir", f->getName())); mpm.add(llvm::createDebugIRPass(false, false, ".debug_ir", f->getName()));
...@@ -83,8 +84,11 @@ static void optimizeIR(llvm::Function* f, EffortLevel::EffortLevel effort) { ...@@ -83,8 +84,11 @@ static void optimizeIR(llvm::Function* f, EffortLevel::EffortLevel effort) {
llvm::FunctionPassManager fpm(g.cur_module); llvm::FunctionPassManager fpm(g.cur_module);
// TODO: using this as a pass is a legacy cludge that shouldn't be necessary any more; can it be updated? #if LLVMREV < 217548
fpm.add(new llvm::DataLayoutPass(*g.tm->getDataLayout())); fpm.add(new llvm::DataLayoutPass(*g.tm->getDataLayout()));
#else
fpm.add(new llvm::DataLayoutPass());
#endif
if (ENABLE_INLINING && effort >= EffortLevel::MAXIMAL) if (ENABLE_INLINING && effort >= EffortLevel::MAXIMAL)
fpm.add(makeFPInliner(275)); fpm.add(makeFPInliner(275));
...@@ -918,7 +922,11 @@ static llvm::MDNode* setupDebugInfo(SourceInfo* source, llvm::Function* f, std:: ...@@ -918,7 +922,11 @@ static llvm::MDNode* setupDebugInfo(SourceInfo* source, llvm::Function* f, std::
std::string producer = "pyston; git rev " STRINGIFY(GITREV); std::string producer = "pyston; git rev " STRINGIFY(GITREV);
llvm::DIFile file = builder.createFile(fn, dir); llvm::DIFile file = builder.createFile(fn, dir);
#if LLVMREV < 214132
llvm::DIArray param_types = builder.getOrCreateArray(llvm::None); 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::DICompositeType func_type = builder.createSubroutineType(file, param_types);
llvm::DISubprogram func_info = builder.createFunction(file, f->getName(), f->getName(), file, lineno, func_type, llvm::DISubprogram func_info = builder.createFunction(file, f->getName(), f->getName(), file, lineno, func_type,
false, true, lineno + 1, 0, true, f); false, true, lineno + 1, 0, true, f);
...@@ -967,7 +975,11 @@ CompiledFunction* doCompile(SourceInfo* source, const OSREntryDescriptor* entry_ ...@@ -967,7 +975,11 @@ CompiledFunction* doCompile(SourceInfo* source, const OSREntryDescriptor* entry_
assert(g.cur_module == NULL); assert(g.cur_module == NULL);
std::string name = getUniqueFunctionName(nameprefix, effort, entry_descriptor); std::string name = getUniqueFunctionName(nameprefix, effort, entry_descriptor);
g.cur_module = new llvm::Module(name, g.context); g.cur_module = new llvm::Module(name, g.context);
#if LLVMREV < 217070 // not sure if this is the right rev
g.cur_module->setDataLayout(g.tm->getDataLayout()->getStringRepresentation()); g.cur_module->setDataLayout(g.tm->getDataLayout()->getStringRepresentation());
#else
g.cur_module->setDataLayout(g.tm->getSubtargetImpl()->getDataLayout());
#endif
// g.engine->addModule(g.cur_module); // g.engine->addModule(g.cur_module);
//// ////
......
...@@ -102,7 +102,11 @@ static void compileIR(CompiledFunction* cf, EffortLevel::EffortLevel effort) { ...@@ -102,7 +102,11 @@ static void compileIR(CompiledFunction* cf, EffortLevel::EffortLevel effort) {
void* compiled = NULL; void* compiled = NULL;
if (effort > EffortLevel::INTERPRETED) { if (effort > EffortLevel::INTERPRETED) {
Timer _t("to jit the IR"); Timer _t("to jit the IR");
#if LLVMREV < 215967
g.engine->addModule(cf->func->getParent()); g.engine->addModule(cf->func->getParent());
#else
g.engine->addModule(std::unique_ptr<llvm::Module>(cf->func->getParent()));
#endif
compiled = (void*)g.engine->getFunctionAddress(cf->func->getName()); compiled = (void*)g.engine->getFunctionAddress(cf->func->getName());
assert(compiled); assert(compiled);
cf->llvm_code = embedConstantPtr(compiled, cf->func->getType()); cf->llvm_code = embedConstantPtr(compiled, cf->func->getType());
......
...@@ -53,7 +53,7 @@ private: ...@@ -53,7 +53,7 @@ private:
uint8_t* allocateSection(MemoryGroup& MemGroup, uintptr_t Size, unsigned Alignment); uint8_t* allocateSection(MemoryGroup& MemGroup, uintptr_t Size, unsigned Alignment);
error_code applyMemoryGroupPermissions(MemoryGroup& MemGroup, unsigned Permissions); llvm_error_code applyMemoryGroupPermissions(MemoryGroup& MemGroup, unsigned Permissions);
virtual uint64_t getSymbolAddress(const std::string& Name); virtual uint64_t getSymbolAddress(const std::string& Name);
...@@ -110,7 +110,7 @@ uint8_t* PystonMemoryManager::allocateSection(MemoryGroup& MemGroup, uintptr_t S ...@@ -110,7 +110,7 @@ uint8_t* PystonMemoryManager::allocateSection(MemoryGroup& MemGroup, uintptr_t S
// //
// FIXME: Initialize the Near member for each memory group to avoid // FIXME: Initialize the Near member for each memory group to avoid
// interleaving. // interleaving.
error_code ec; llvm_error_code ec;
sys::MemoryBlock MB = sys::Memory::allocateMappedMemory(RequiredSize, &MemGroup.Near, sys::MemoryBlock MB = sys::Memory::allocateMappedMemory(RequiredSize, &MemGroup.Near,
sys::Memory::MF_READ | sys::Memory::MF_WRITE, ec); sys::Memory::MF_READ | sys::Memory::MF_WRITE, ec);
if (ec) { if (ec) {
...@@ -140,7 +140,7 @@ uint8_t* PystonMemoryManager::allocateSection(MemoryGroup& MemGroup, uintptr_t S ...@@ -140,7 +140,7 @@ uint8_t* PystonMemoryManager::allocateSection(MemoryGroup& MemGroup, uintptr_t S
bool PystonMemoryManager::finalizeMemory(std::string* ErrMsg) { bool PystonMemoryManager::finalizeMemory(std::string* ErrMsg) {
// FIXME: Should in-progress permissions be reverted if an error occurs? // FIXME: Should in-progress permissions be reverted if an error occurs?
error_code ec; llvm_error_code ec;
// Don't allow free memory blocks to be used after setting protection flags. // Don't allow free memory blocks to be used after setting protection flags.
CodeMem.FreeMem.clear(); CodeMem.FreeMem.clear();
...@@ -177,10 +177,10 @@ bool PystonMemoryManager::finalizeMemory(std::string* ErrMsg) { ...@@ -177,10 +177,10 @@ bool PystonMemoryManager::finalizeMemory(std::string* ErrMsg) {
return false; return false;
} }
error_code PystonMemoryManager::applyMemoryGroupPermissions(MemoryGroup& MemGroup, unsigned Permissions) { llvm_error_code PystonMemoryManager::applyMemoryGroupPermissions(MemoryGroup& MemGroup, unsigned Permissions) {
for (int i = 0, e = MemGroup.AllocatedMem.size(); i != e; ++i) { for (int i = 0, e = MemGroup.AllocatedMem.size(); i != e; ++i) {
error_code ec; llvm_error_code ec;
ec = sys::Memory::protectMappedMemory(MemGroup.AllocatedMem[i], Permissions); ec = sys::Memory::protectMappedMemory(MemGroup.AllocatedMem[i], Permissions);
if (ec) { if (ec) {
return ec; return ec;
...@@ -188,9 +188,9 @@ error_code PystonMemoryManager::applyMemoryGroupPermissions(MemoryGroup& MemGrou ...@@ -188,9 +188,9 @@ error_code PystonMemoryManager::applyMemoryGroupPermissions(MemoryGroup& MemGrou
} }
#if LLVMREV < 209952 #if LLVMREV < 209952
return error_code::success(); return llvm_error_code::success();
#else #else
return error_code(); return llvm_error_code();
#endif #endif
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "llvm/Support/Debug.h" #include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h" #include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetSubtargetInfo.h"
#include "codegen/codegen.h" #include "codegen/codegen.h"
#include "codegen/irgen/util.h" #include "codegen/irgen/util.h"
...@@ -104,7 +105,11 @@ private: ...@@ -104,7 +105,11 @@ private:
} }
APInt ap_offset(64, 0, true); APInt ap_offset(64, 0, true);
#if LLVMREV < 214781
bool success = gep->accumulateConstantOffset(*g.tm->getDataLayout(), ap_offset); bool success = gep->accumulateConstantOffset(*g.tm->getDataLayout(), ap_offset);
#else
bool success = gep->accumulateConstantOffset(*g.tm->getSubtargetImpl()->getDataLayout(), ap_offset);
#endif
assert(success); assert(success);
int64_t offset = ap_offset.getSExtValue(); int64_t offset = ap_offset.getSExtValue();
......
...@@ -31,7 +31,7 @@ public: ...@@ -31,7 +31,7 @@ public:
static int num = 0; static int num = 0;
void DumpJITEventListener::NotifyObjectEmitted(const llvm::ObjectImage& Obj) { void DumpJITEventListener::NotifyObjectEmitted(const llvm::ObjectImage& Obj) {
llvm::error_code code; llvm_error_code code;
std::ostringstream os(""); std::ostringstream os("");
os << "jit" << ++num << ".o"; os << "jit" << ++num << ".o";
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "llvm/Analysis/Passes.h" #include "llvm/Analysis/Passes.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/IR/Module.h" #include "llvm/IR/Module.h"
#include "llvm/PassManager.h" #include "llvm/PassManager.h"
#include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/DynamicLibrary.h"
......
...@@ -60,7 +60,7 @@ extern void _force_link() { ...@@ -60,7 +60,7 @@ extern void _force_link() {
void StackmapJITEventListener::NotifyObjectEmitted(const llvm::ObjectImage& Obj) { void StackmapJITEventListener::NotifyObjectEmitted(const llvm::ObjectImage& Obj) {
// llvm::outs() << "An object has been emitted:\n"; // llvm::outs() << "An object has been emitted:\n";
llvm::error_code code; llvm_error_code code;
for (llvm::object::symbol_iterator I = Obj.begin_symbols(), E = Obj.end_symbols(); I != E;) { for (llvm::object::symbol_iterator I = Obj.begin_symbols(), E = Obj.end_symbols(); I != E;) {
llvm::StringRef name; llvm::StringRef name;
......
...@@ -111,9 +111,13 @@ const LineInfo* getLineInfoFor(uint64_t addr) { ...@@ -111,9 +111,13 @@ const LineInfo* getLineInfoFor(uint64_t addr) {
class TracebacksEventListener : public llvm::JITEventListener { class TracebacksEventListener : public llvm::JITEventListener {
public: public:
void NotifyObjectEmitted(const llvm::ObjectImage& Obj) { void NotifyObjectEmitted(const llvm::ObjectImage& Obj) {
#if LLVMREV < 214433
llvm::DIContext* Context = llvm::DIContext::getDWARFContext(Obj.getObjectFile()); llvm::DIContext* Context = llvm::DIContext::getDWARFContext(Obj.getObjectFile());
#else
llvm::DIContext* Context = llvm::DIContext::getDWARFContext(*Obj.getObjectFile());
#endif
llvm::error_code ec; llvm_error_code ec;
for (llvm::object::symbol_iterator I = Obj.begin_symbols(), E = Obj.end_symbols(); I != E && !ec; ++I) { for (llvm::object::symbol_iterator I = Obj.begin_symbols(), E = Obj.end_symbols(); I != E && !ec; ++I) {
llvm::object::SymbolRef::Type SymType; llvm::object::SymbolRef::Type SymType;
if (I->getType(SymType)) if (I->getType(SymType))
...@@ -151,7 +155,7 @@ public: ...@@ -151,7 +155,7 @@ public:
delete Context; delete Context;
// Currently-unused libunwind support: // Currently-unused libunwind support:
llvm::error_code code; llvm_error_code code;
bool found_text = false, found_eh_frame = false; bool found_text = false, found_eh_frame = false;
uint64_t text_addr, text_size; uint64_t text_addr, text_size;
uint64_t eh_frame_addr, eh_frame_size; uint64_t eh_frame_addr, eh_frame_size;
......
...@@ -47,6 +47,12 @@ ...@@ -47,6 +47,12 @@
#define NOINLINE #define NOINLINE
#endif #endif
#if LLVMREV < 210783
#define llvm_error_code llvm::error_code
#else
#define llvm_error_code std::error_code
#endif
// From http://stackoverflow.com/questions/3767869/adding-message-to-assert, modified to use fprintf and give a Python // From http://stackoverflow.com/questions/3767869/adding-message-to-assert, modified to use fprintf and give a Python
// stacktrace // stacktrace
#define RELEASE_ASSERT(condition, fmt, ...) \ #define RELEASE_ASSERT(condition, fmt, ...) \
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "core/common.h" #include "core/common.h"
#include "core/options.h" #include "core/options.h"
#include "core/types.h"
namespace pyston { namespace pyston {
...@@ -92,7 +93,7 @@ bool endswith(const std::string& s, const std::string& pattern) { ...@@ -92,7 +93,7 @@ bool endswith(const std::string& s, const std::string& pattern) {
} }
void removeDirectoryIfExists(const std::string& path) { void removeDirectoryIfExists(const std::string& path) {
llvm::error_code code; llvm_error_code code;
llvm::sys::fs::file_status status; llvm::sys::fs::file_status status;
code = llvm::sys::fs::status(path, status); code = llvm::sys::fs::status(path, status);
......
...@@ -586,13 +586,20 @@ Box* execfile(Box* _fn) { ...@@ -586,13 +586,20 @@ Box* execfile(Box* _fn) {
BoxedString* fn = static_cast<BoxedString*>(_fn); BoxedString* fn = static_cast<BoxedString*>(_fn);
#if LLVMREV < 217625
bool exists; bool exists;
llvm::error_code code = llvm::sys::fs::exists(fn->s, exists); llvm_error_code code = llvm::sys::fs::exists(fn->s, exists);
#if LLVMREV < 210072 #if LLVMREV < 210072
ASSERT(code == 0, "%s: %s", code.message().c_str(), fn->s.c_str()); ASSERT(code == 0, "%s: %s", code.message().c_str(), fn->s.c_str());
#else #else
assert(!code); assert(!code);
#endif #endif
#else
bool exists = llvm::sys::fs::exists(fn->s);
#endif
if (!exists) if (!exists)
raiseExcHelper(IOError, "No such file or directory: '%s'", fn->s.c_str()); raiseExcHelper(IOError, "No such file or directory: '%s'", fn->s.c_str());
......
...@@ -66,9 +66,13 @@ static Box* importSub(const std::string* name, Box* parent_module) { ...@@ -66,9 +66,13 @@ static Box* importSub(const std::string* name, Box* parent_module) {
if (VERBOSITY() >= 2) if (VERBOSITY() >= 2)
printf("Searching for %s at %s...\n", name->c_str(), fn.c_str()); printf("Searching for %s at %s...\n", name->c_str(), fn.c_str());
#if LLVMREV < 217625
bool exists; bool exists;
llvm::error_code code = llvm::sys::fs::exists(joined_path.str(), exists); llvm_error_code code = llvm::sys::fs::exists(joined_path.str(), exists);
assert(LLVM_SYS_FS_EXISTS_CODE_OKAY(code)); assert(LLVM_SYS_FS_EXISTS_CODE_OKAY(code));
#else
bool exists = llvm::sys::fs::exists(joined_path.str());
#endif
if (!exists) if (!exists)
continue; continue;
......
...@@ -81,6 +81,10 @@ if __name__ == "__main__": ...@@ -81,6 +81,10 @@ if __name__ == "__main__":
continue continue
if "Update-TailCallElim" in patch_fn and svn_rev >= 208017: if "Update-TailCallElim" in patch_fn and svn_rev >= 208017:
continue continue
if "Update-IntelJITEvents" in patch_fn and svn_rev >= 209989:
continue
if "stackmap-sections-for-ELF" in patch_fn and svn_rev >= 214538:
continue
patch_fn = os.path.abspath(os.path.join(patch_dir, patch_fn)) patch_fn = os.path.abspath(os.path.join(patch_dir, patch_fn))
code = subprocess.call(["git", "am", patch_fn], cwd=repo) code = subprocess.call(["git", "am", patch_fn], cwd=repo)
......
...@@ -165,7 +165,11 @@ int main(int argc, char **argv) { ...@@ -165,7 +165,11 @@ int main(int argc, char **argv) {
SMDiagnostic Err; SMDiagnostic Err;
#if LLVMREV < 216466
std::unique_ptr<Module> M(ParseIRFile(InputFilename, Err, Context)); std::unique_ptr<Module> M(ParseIRFile(InputFilename, Err, Context));
#else
std::unique_ptr<Module> M(parseIRFile(InputFilename, Err, Context));
#endif
if (M.get() == 0) { if (M.get() == 0) {
Err.print(argv[0], errs()); Err.print(argv[0], errs());
...@@ -187,12 +191,21 @@ int main(int argc, char **argv) { ...@@ -187,12 +191,21 @@ int main(int argc, char **argv) {
if (OutputFilename.empty()) if (OutputFilename.empty())
OutputFilename = "-"; OutputFilename = "-";
#if LLVMREV < 216393
std::string ErrorInfo; std::string ErrorInfo;
tool_output_file out(OutputFilename.c_str(), ErrorInfo, sys::fs::F_None); tool_output_file out(OutputFilename.c_str(), ErrorInfo, sys::fs::F_None);
if (!ErrorInfo.empty()) { if (!ErrorInfo.empty()) {
errs() << ErrorInfo << '\n'; errs() << ErrorInfo << '\n';
return 1; return 1;
} }
#else
std::error_code EC;
tool_output_file out(OutputFilename, EC, sys::fs::F_None);
if (EC) {
errs() << "error opening file for writing\n";
return 1;
}
#endif
WriteBitcodeToFile(M.get(), out.os()); WriteBitcodeToFile(M.get(), out.os());
......
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