[llvm-dev] Unable to conversion in Expected<unique_ptr<Module>> to Module

Ratnesh Tiwari via llvm-dev llvm-dev at lists.llvm.org
Wed Aug 15 02:13:00 PDT 2018


Hi, I am new to llvm , writing the program "main.cpp" of
https://github.com/davidar/lljvm/blob/master/backend/main.cpp.

I stuck at the error while executing the command : "pm.run(m)"
error: no matching function for call to
‘llvm::legacy::PassManager::run(llvm::Expected<std::unique_ptr<llvm::Module>
>&)

Here is my source code:
---------
#include "backened.h"
#include <iostream>
#include "llvm/Bitcode/BitcodeReader.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/IR/PassManager.h"
#include "llvm/CodeGen/Passes.h"
#include "llvm/IR/DataLayout.h"
#include <llvm/Transforms/Scalar.h>
#include "llvm/IR/LegacyPassManager.h"

using namespace llvm;
using namespace std;

static cl::opt<string> input(cl::Positional, cl::desc("Bitcode
File.."),cl::Required);
static cl::opt<string> classname("classname",cl::desc("Binary name of the
generated class..."));

int main(int argc, char** argv)
{
        cl::ParseCommandLineOptions(argc, argv, "Hi..");
        LLVMContext context;

        ErrorOr<unique_ptr<MemoryBuffer>>  mb =
MemoryBuffer::getFile(input);
        if(error_code ec = mb.getError()) {
                errs() << ec.message();
                return 1;
        }

        Expected<unique_ptr<Module>> m = parseBitcodeFile(mb->get()->
getMemBufferRef(),context);
        if(error_code ec= errorToErrorCode(m.takeError()) )
        {
           errs() <<"Unable to read bitcode file.." <<ec.message() ;
        }
        PassManager<Module> PM;

    pm.add(createVerifierPass());

    pm.add(createGCLoweringPass());


    pm.add(createLowerSwitchPass());

    pm.add(createCFGSimplificationPass());

    pm.add(new JVMWriter(fouts(), classname, debugLevel));

    pm.add(createGCInfoDeleter());

    pm.run(*m);
        return 0;
}
------------------
Please help me.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180815/c0487015/attachment.html>


More information about the llvm-dev mailing list