From e8ab2bd39a62691d84bc64428c1da11e38e21838 Mon Sep 17 00:00:00 2001 From: Simon Wagner Date: Sun, 21 Dec 2014 17:15:22 +0100 Subject: [PATCH 1/3] Update llvm-config-3.1 to llvm-config-3.5 --- run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.sh b/run.sh index 9a53657..789b171 100755 --- a/run.sh +++ b/run.sh @@ -8,7 +8,7 @@ if which ccache >/dev/null 2>&1; then ccache=ccache fi -llvm_config=llvm-config-3.1 +llvm_config=llvm-config-3.5 # Filter out -O2 to reduce compile time cflags="$( From 7547970858466efb93e643e44e1406e11dc047ca Mon Sep 17 00:00:00 2001 From: Simon Wagner Date: Sun, 21 Dec 2014 18:39:56 +0100 Subject: [PATCH 2/3] Also link against the system libraries which LLVM needs --- run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run.sh b/run.sh index 789b171..80bc439 100755 --- a/run.sh +++ b/run.sh @@ -52,12 +52,12 @@ g++ -m32 $lib \ codegen_test.o \ gen_arithmetic_test_c.o \ gen_arithmetic_test_ll.o \ - $($llvm_config --ldflags --libs) -ldl \ + $($llvm_config --ldflags --libs --system-libs) -ldl \ -o codegen_test g++ -m32 $lib \ run_program.o \ - $($llvm_config --ldflags --libs) -ldl \ + $($llvm_config --ldflags --libs --system-libs) -ldl \ -o run_program $ccache clang -m32 -O2 -c -emit-llvm hellow_minimal_irt.c \ From 6b22d42ad09fde8d324e416de6240c61f07e2648 Mon Sep 17 00:00:00 2001 From: Simon Wagner Date: Sun, 21 Dec 2014 18:32:44 +0100 Subject: [PATCH 3/3] Port to LLVM 3.5 --- codegen.cc | 27 +++++++++++++-------------- codegen.h | 2 +- codegen_test.cc | 5 +++-- expand_constantexpr.cc | 14 +++++++------- expand_getelementptr.cc | 18 ++++++++---------- expand_varargs.cc | 22 ++++++++++------------ run_program.cc | 5 +++-- 7 files changed, 45 insertions(+), 48 deletions(-) diff --git a/codegen.cc b/codegen.cc index b36c762..c12f9b4 100644 --- a/codegen.cc +++ b/codegen.cc @@ -15,15 +15,13 @@ #include -#include -#include -#include -#include -#include -#include - -// In LLVM 3.2, this becomes -#include +#include +#include +#include +#include +#include +#include +#include #include "expand_constantexpr.h" #include "expand_getelementptr.h" @@ -70,7 +68,7 @@ bool is_i64(llvm::Type *ty) { return false; } -void expand_constant(llvm::Constant *val, llvm::TargetData *data_layout, +void expand_constant(llvm::Constant *val, llvm::DataLayout *data_layout, llvm::GlobalValue **result_global, uint64_t *result_offset, const char **result_unhandled) { @@ -181,11 +179,12 @@ class DataBuffer { void put_uint32(uint32_t val) { *(uint32_t *) put_alloc_space(sizeof(val)) = val; } + }; class CodeBuf : public DataBuffer { public: - CodeBuf(llvm::TargetData *data_layout_arg, CodeGenOptions *options_arg): + CodeBuf(llvm::DataLayout *data_layout_arg, CodeGenOptions *options_arg): DataBuffer(PROT_READ | PROT_WRITE | PROT_EXEC), data_segment(PROT_READ | PROT_WRITE), data_layout(data_layout_arg), @@ -487,7 +486,7 @@ class CodeBuf : public DataBuffer { int frame_vars_size; int frame_callees_args_size; - llvm::TargetData *data_layout; + llvm::DataLayout *data_layout; CodeGenOptions *options; typedef std::pair JumpReloc; @@ -556,7 +555,7 @@ const char *get_instruction_type(llvm::Instruction *inst) { switch (inst->getOpcode()) { #define HANDLE_INST(NUM, OPCODE, CLASS) \ case llvm::Instruction::OPCODE: return #OPCODE; -#include "llvm/Instruction.def" +#include #undef HANDLE_INST default: return ""; } @@ -1298,7 +1297,7 @@ void translate_function(llvm::Function *func, CodeBuf &codebuf) { void translate(llvm::Module *module, std::map *globals, CodeGenOptions *options) { - llvm::TargetData data_layout(module); + llvm::DataLayout data_layout(module); CodeBuf codebuf(&data_layout, options); llvm::ModulePass *expand_varargs = createExpandVarArgsPass(); diff --git a/codegen.h b/codegen.h index 373817f..3a9c39d 100644 --- a/codegen.h +++ b/codegen.h @@ -12,7 +12,7 @@ #include -#include +#include class CodeGenOptions { public: diff --git a/codegen_test.cc b/codegen_test.cc index 6dac74a..94d7b84 100644 --- a/codegen_test.cc +++ b/codegen_test.cc @@ -11,8 +11,9 @@ #include #include -#include -#include +#include +#include +#include #include "arithmetic_test.h" #include "codegen.h" diff --git a/expand_constantexpr.cc b/expand_constantexpr.cc index a29e71d..40ca032 100644 --- a/expand_constantexpr.cc +++ b/expand_constantexpr.cc @@ -9,13 +9,13 @@ #include "expand_constantexpr.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include using namespace llvm; diff --git a/expand_getelementptr.cc b/expand_getelementptr.cc index 0f92779..3d901c0 100644 --- a/expand_getelementptr.cc +++ b/expand_getelementptr.cc @@ -9,16 +9,14 @@ #include "expand_getelementptr.h" -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include - -// In LLVM 3.2, this becomes -#include +#include using namespace llvm; @@ -39,7 +37,7 @@ bool ExpandGetElementPtr::runOnBasicBlock(BasicBlock &bb) { bool modified = false; Module *module = bb.getParent()->getParent(); Type *ptrtype = Type::getInt32Ty(module->getContext()); - TargetData data_layout(module); + DataLayout data_layout(module); for (BasicBlock::InstListType::iterator iter = bb.begin(); iter != bb.end(); ) { diff --git a/expand_varargs.cc b/expand_varargs.cc index 66bb550..8ca4770 100644 --- a/expand_varargs.cc +++ b/expand_varargs.cc @@ -9,17 +9,15 @@ #include "expand_varargs.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include - -// In LLVM 3.2, this becomes -#include +#include using namespace llvm; @@ -91,7 +89,7 @@ static void ExpandVarArgFunc(Function *Func) { // TODO: Update debug information too. } -static void ExpandVAArgInst(VAArgInst *Inst, TargetData *DataLayout) { +static void ExpandVAArgInst(VAArgInst *Inst, DataLayout *DataLayout) { Module *Module = Inst->getParent()->getParent()->getParent(); Type *I8 = Type::getInt8Ty(Module->getContext()); Type *I32 = Type::getInt32Ty(Module->getContext()); @@ -195,7 +193,7 @@ static bool ExpandVarArgCall(CallInst *Call) { bool ExpandVarArgs::runOnModule(Module &M) { bool Changed = false; - TargetData DataLayout(&M); + DataLayout DataLayout(&M); for (Module::iterator Iter = M.begin(), E = M.end(); Iter != E; ) { Function *Func = Iter++; diff --git a/run_program.cc b/run_program.cc index 6059ca9..aa5d140 100644 --- a/run_program.cc +++ b/run_program.cc @@ -11,8 +11,9 @@ #include #include -#include -#include +#include +#include +#include #include "codegen.h" #include "nacl_irt_interfaces.h"