Commit 38d32bb9 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Make some things forwards-compatible with newer LLVM revisions

parent 2254da9f
......@@ -155,20 +155,17 @@ public:
continue;
llvm::StringRef name;
uint64_t addr, size, offset;
uint64_t addr, size;
code = I->getName(name);
assert(!code);
code = I->getAddress(addr);
assert(!code);
code = I->getSize(size);
assert(!code);
code = I->getFileOffset(offset);
assert(!code);
if (name == ".text")
continue;
// printf("%lx %lx %lx %s\n", addr, addr + size, offset, name.data());
g.func_addr_registry.registerFunction(name.data(), (void*)addr, size, NULL);
}
}
......
......@@ -85,7 +85,11 @@ PystonJITEventListener::PystonJITEventListener() {
assert(CE);
bool verbose = false;
#if LLVMREV < 208205
llvm::MCStreamer* streamer = target->createAsmStreamer(*Ctx, llvm::ferrs(), verbose, true, true, IP, CE, TAB, true);
#else
llvm::MCStreamer* streamer = target->createAsmStreamer(*Ctx, llvm::ferrs(), verbose, true, IP, CE, TAB, true);
#endif
assert(streamer);
streamer->InitSections();
streamer->SwitchSection(Ctx->getObjectFileInfo()->getTextSection());
......@@ -178,16 +182,14 @@ void PystonJITEventListener::NotifyObjectEmitted(const llvm::ObjectImage& Obj) {
for (llvm::object::symbol_iterator I = Obj.begin_symbols(), E = Obj.end_symbols(); I != E;) {
llvm::StringRef name;
uint64_t addr, size, offset = 0;
uint64_t addr, size;
code = I->getName(name);
assert(!code);
code = I->getAddress(addr);
assert(!code);
code = I->getSize(size);
assert(!code);
code = I->getFileOffset(offset);
assert(!code);
printf("%lx %lx %lx %s\n", addr, addr + size, offset, name.data());
printf("%lx %lx %s\n", addr, addr + size, name.data());
#if LLVMREV < 200442
I = I.increment(code);
#else
......
......@@ -58,7 +58,11 @@ public:
assert(gv->getLinkage() != llvm::GlobalVariable::PrivateLinkage);
r = new_module->getOrInsertGlobal(gv->getName(), gv->getType()->getElementType());
} else if (llvm::GlobalAlias* alias = llvm::dyn_cast<llvm::GlobalAlias>(v)) {
#if LLVMREV < 209040
llvm::Value* addressee = llvm::cast<llvm::Constant>(materializeValueFor(alias->getAliasedGlobal()));
#else
llvm::Value* addressee = llvm::cast<llvm::Constant>(materializeValueFor(alias->getAliasee()));
#endif
assert(addressee);
assert(alias->getType() == addressee->getType());
r = addressee;
......
......@@ -68,14 +68,14 @@ void StackmapJITEventListener::NotifyObjectEmitted(const llvm::ObjectImage& Obj)
assert(!code);
if (name == "__LLVM_StackMaps") {
uint64_t stackmap_offset = 0;
code = I->getFileOffset(stackmap_offset);
uint64_t stackmap_address = 0;
code = I->getAddress(stackmap_address);
assert(!code);
// code = I->getSize(stackmap_size);
// assert(stackmap_size > 0);
// assert(!code);
if (VERBOSITY() >= 2)
printf("Found the stackmaps at stackmap_offset 0x%lx\n", stackmap_offset);
printf("Found the stackmaps at stackmap_address 0x%lx\n", stackmap_address);
assert(cur_map == NULL);
cur_map = new StackMap();
......@@ -93,7 +93,7 @@ void StackmapJITEventListener::NotifyObjectEmitted(const llvm::ObjectImage& Obj)
const StackMap::Record::LiveOut* record_liveout;
const StackMap::StackSizeRecord* size_record;
} ptr;
const int8_t* start_ptr = ptr.i8 = (const int8_t*)Obj.getData().data() + stackmap_offset;
const int8_t* start_ptr = ptr.i8 = (const int8_t*)stackmap_address;
cur_map->header = *ptr.u32++; // header
......
......@@ -78,8 +78,6 @@ public:
llvm::error_code ec;
for (llvm::object::symbol_iterator I = Obj.begin_symbols(), E = Obj.end_symbols(); I != E && !ec; ++I) {
std::string SourceFileName;
llvm::object::SymbolRef::Type SymType;
if (I->getType(SymType))
continue;
......@@ -94,8 +92,14 @@ public:
if (I->getSize(Size))
continue;
#if LLVMREV < 208921
llvm::DILineInfoTable lines = Context->getLineInfoForAddressRange(
Addr, Size, llvm::DILineInfoSpecifier::FunctionName | llvm::DILineInfoSpecifier::FileLineInfo | llvm::DILineInfoSpecifier::AbsoluteFilePath);
#else
llvm::DILineInfoTable lines = Context->getLineInfoForAddressRange(
Addr, Size, llvm::DILineInfoSpecifier::FunctionName | llvm::DILineInfoSpecifier::FileLineInfo);
Addr, Size, llvm::DILineInfoSpecifier(llvm::DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath,
llvm::DILineInfoSpecifier::FunctionNameKind::LinkageName));
#endif
for (int i = 0; i < lines.size(); i++) {
// printf("%s:%d, %s: %lx\n", lines[i].second.getFileName(), lines[i].second.getLine(),
// lines[i].second.getFunctionName(), lines[i].first);
......
......@@ -13,6 +13,7 @@
// limitations under the License.
#include <algorithm>
#include <cstddef>
#include "codegen/compvars.h"
#include "core/ast.h"
......
......@@ -79,6 +79,8 @@ if __name__ == "__main__":
continue
if patch_fn.startswith("LICENSE"):
continue
if "Update-TailCallElim" in patch_fn and svn_rev >= 208017:
continue
patch_fn = os.path.abspath(os.path.join(patch_dir, patch_fn))
code = subprocess.call(["git", "am", patch_fn], cwd=repo)
......
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