[llvm-dev] Error: ‘class llvm::PassManager<llvm::Module>’ has no member named ‘add’

Ratnesh Tiwari via llvm-dev llvm-dev at lists.llvm.org
Tue Aug 14 01:57:15 PDT 2018


 Yes, I did that. Now the error is comming:

error: no matching function for call to ‘llvm::legacy::PassManager::
add(llvm::DataLayout*)’
  PM.add(new DataLayout(td));
                           ^
In file included from main_test.cpp:15:0:
/tmp/llvm/include/llvm/IR/LegacyPassManager.h:55:8: note: candidate:
virtual void llvm::legacy::PassManager::add(llvm::Pass*)
   void add(Pass *P) override;
        ^
/tmp/llvm/include/llvm/IR/LegacyPassManager.h:55:8: note:   no known
conversion for argument 1 from ‘llvm::DataLayout*’ to ‘llvm::Pass*’


On Tue, Aug 14, 2018 at 10:41 AM, David Wiberg <dwiberg at gmail.com> wrote:

> Hi Ratnesh,
>
> Did you change your variable declaration to "legacy::PassManager PM;"
> after adding the include for the legacy pass manager?
>
> Best regards
> David
> David
> Den tis 14 aug. 2018 kl 04:10 skrev Ratnesh Tiwari via llvm-dev
> <llvm-dev at lists.llvm.org>:
> >
> > Hi Philip,
> > I also tried that including file:
> > #include "llvm/IR/LegacyPassManager.h"
> > but error remain same. Please help.
> >
> > On Tue, Aug 14, 2018, 2:58 AM Philip Pfaffe <philip.pfaffe at gmail.com>
> wrote:
> >>
> >> Hi Ratnesh,
> >>
> >> the PassManager used in that example has moved into the legacy
> namespace: http://llvm.org/doxygen/classllvm_1_1legacy_1_1PassManager.html
> >>
> >> Cheers,
> >> Philip
> >>
> >> On Mon, Aug 13, 2018 at 8:49 PM Ratnesh Tiwari via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
> >>>
> >>> Hi, I am begineer to llvm, implementing a main.cpp from
> https://github.com/davidar/lljvm/blob/master/backend/main.cpp
> >>>
> >>> A) : When I am declaring a command:
> >>>        PassManager PM
> >>>        PM.add(new DataLayout td)
> >>>
> >>> It shows error:
> >>> >error: missing template arguments before ‘PM’
> >>>   PassManager PM;
> >>>               ^
> >>> >main_test.cpp:48:2: error: ‘PM’ was not declared in this scope
> >>>   PM.add(new DataLayout(td));
> >>>
> >>> Keeping in mind the above error, I changed the code as:
> >>> PassManager<Module> PM
> >>> PM.add(new DataLayout td)
> >>>
> >>> I dont know, whether the above change is the correct one or not. But
> the error is changed to:
> >>>
> >>> >error: ‘class llvm::PassManager<llvm::Module>’ has no member named
> ‘add’
> >>>   PM.add(new DataLayout(td));
> >>>
> >>> Here is mine 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()) )
> >>>         {
> >>>         PassManager<Module> PM;
> >>>         DataLayout td("e-p:32:32:32"
> >>>                  "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64"
> >>>                  "-f32:32:32-f64:64:64");
> >>>         PM.add(new DataLayout(td));
> >>>         return 0;
> >>> }
> >>> ------------------------------------------
> >>>
> >>> B) Also suggest me , whether I am implemented a correct way
> "DataLayout td ("e-p:32:32:32......")" and "new DataLayout td"  in the
> place of TargetData.h as I found that TargeyData.h is not found in  newer
> version of llvm. Thank you.
> >>> _______________________________________________
> >>> LLVM Developers mailing list
> >>> llvm-dev at lists.llvm.org
> >>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
> >
> > _______________________________________________
> > LLVM Developers mailing list
> > llvm-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180814/28f6c573/attachment.html>


More information about the llvm-dev mailing list