Skip to content

Support for LLVM > 3.4 #102

@florianjacob

Description

@florianjacob

In its current state, gpuocelot won't work with anything above LLVM 3.4. e.g. #99 and #100 are symptoms of that.

LLVM seems to have introduced some quite heavy changes, so this probably won't be trivial to fix, and if one were to do so, one would probably have to drop support for LLVM 3.4 as this would really get you in ifdef hell, not only in the includes, but also inside the code.

Problems I found / fixed so far, but there are many more:

#define HAVE_LLVM 1
#include <llvm/Config/llvm-config.h>

/* PassManager is legacy starting from llvm 3.7 */
#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 7
#define LLVM_37_PLUS 1
#endif

/* llvm/Assembly/Parser.h moved to llvm/AsmParser/Parser.h in llvm 3.5 */
/* llvm/Analysis/Verifier.h moved to llvm/IR/Verifier.h in llvm 3.5 */
#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >= 5
#define LLVM_35_PLUS 1
#endif

#else
#define HAVE_LLVM 0
#endif
#if LLVM_37_PLUS
#include "llvm/IR/LegacyPassManager.h"
using namespace llvm::legacy;
#else
#include <llvm/PassManager.h>
#endif
#if LLVM_35_PLUS
#include <llvm/AsmParser/Parser.h>
#include <llvm/IR/Verifier.h>
#else
#include <llvm/Assembly/Parser.h>
#include <llvm/Analysis/Verifier.h>
#endif

Preview of errors where I gave up, ParseAssemblyString is now parseAssemblyString and freeMachineCodeForFunction doesn't exist anymore at all:

ocelot/ocelot/ir/implementation/ExternalFunctionSet.cpp:320:6: error: 'ParseAssemblyString' is not a member of 'llvm'
  m = llvm::ParseAssemblyString(kernel.code().c_str(),
      ^~~~
ocelot/ocelot/ir/implementation/ExternalFunctionSet.cpp:341:28: error: 'ReturnStatusAction' is not a member of 'llvm'
  if(llvm::verifyModule(*m, llvm::ReturnStatusAction, &verifyError))
                            ^~~~
ocelot/ocelot/ir/implementation/ExternalFunctionSet.cpp: In destructor 'ir::ExternalFunctionSet::~ExternalFunctionSet()':
ocelot/ocelot/ir/implementation/ExternalFunctionSet.cpp:426:33: error: 'class llvm::ExecutionEngine' has no member named 'freeMachineCodeForFunction'
    executive::LLVMState::jit()->freeMachineCodeForFunction(function);
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~
ocelot/ocelot/ir/implementation/ExternalFunctionSet.cpp: In member function 'void ir::ExternalFunctionSet::remove(const string&)':
ocelot/ocelot/ir/implementation/ExternalFunctionSet.cpp:465:32: error: 'class llvm::ExecutionEngine' has no member named 'freeMachineCodeForFunction'
   executive::LLVMState::jit()->freeMachineCodeForFunction(llvmFunction);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions