<div dir="ltr">
<span style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Yes, I did that. Now the error is comming: </span><div style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial"><br></div><div style="font-size:12.8px;text-decoration-style:initial;text-decoration-color:initial"><div>error: no matching function for call to ‘llvm::legacy::PassManager::<wbr>add(llvm::DataLayout*)’</div><div> PM.add(new DataLayout(td));</div><div> ^</div><div>In file included from main_test.cpp:15:0:</div><div>/tmp/llvm/include/llvm/IR/<wbr>LegacyPassManager.h:55:8: note: candidate: virtual void llvm::legacy::PassManager::<wbr>add(llvm::Pass*)</div><div> void add(Pass *P) override;</div><div> ^</div><div>/tmp/llvm/include/llvm/IR/<wbr>LegacyPassManager.h:55:8: note: no known conversion for argument 1 from ‘llvm::DataLayout*’ to ‘llvm::Pass*’</div></div>
<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 14, 2018 at 10:41 AM, David Wiberg <span dir="ltr"><<a href="mailto:dwiberg@gmail.com" target="_blank">dwiberg@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Ratnesh,<br>
<br>
Did you change your variable declaration to "legacy::PassManager PM;"<br>
after adding the include for the legacy pass manager?<br>
<br>
Best regards<br>
David<br>
David<br>
Den tis 14 aug. 2018 kl 04:10 skrev Ratnesh Tiwari via llvm-dev<br>
<<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>>:<br>
<div class="HOEnZb"><div class="h5">><br>
> Hi Philip,<br>
> I also tried that including file:<br>
> #include "llvm/IR/LegacyPassManager.h"<br>
> but error remain same. Please help.<br>
><br>
> On Tue, Aug 14, 2018, 2:58 AM Philip Pfaffe <<a href="mailto:philip.pfaffe@gmail.com">philip.pfaffe@gmail.com</a>> wrote:<br>
>><br>
>> Hi Ratnesh,<br>
>><br>
>> the PassManager used in that example has moved into the legacy namespace: <a href="http://llvm.org/doxygen/classllvm_1_1legacy_1_1PassManager.html" rel="noreferrer" target="_blank">http://llvm.org/doxygen/<wbr>classllvm_1_1legacy_1_<wbr>1PassManager.html</a><br>
>><br>
>> Cheers,<br>
>> Philip<br>
>><br>
>> On Mon, Aug 13, 2018 at 8:49 PM Ratnesh Tiwari via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
>>><br>
>>> Hi, I am begineer to llvm, implementing a main.cpp from <a href="https://github.com/davidar/lljvm/blob/master/backend/main.cpp" rel="noreferrer" target="_blank">https://github.com/davidar/<wbr>lljvm/blob/master/backend/<wbr>main.cpp</a><br>
>>><br>
>>> A) : When I am declaring a command:<br>
>>> PassManager PM<br>
>>> PM.add(new DataLayout td)<br>
>>><br>
>>> It shows error:<br>
>>> >error: missing template arguments before ‘PM’<br>
>>> PassManager PM;<br>
>>> ^<br>
>>> >main_test.cpp:48:2: error: ‘PM’ was not declared in this scope<br>
>>> PM.add(new DataLayout(td));<br>
>>><br>
>>> Keeping in mind the above error, I changed the code as:<br>
>>> PassManager<Module> PM<br>
>>> PM.add(new DataLayout td)<br>
>>><br>
>>> I dont know, whether the above change is the correct one or not. But the error is changed to:<br>
>>><br>
>>> >error: ‘class llvm::PassManager<llvm::<wbr>Module>’ has no member named ‘add’<br>
>>> PM.add(new DataLayout(td));<br>
>>><br>
>>> Here is mine source code:<br>
>>> ------------------------------<wbr>-----------------<br>
>>> #include "backened.h"<br>
>>> #include <iostream><br>
>>> #include "llvm/Bitcode/BitcodeReader.h"<br>
>>> #include "llvm/IR/Function.h"<br>
>>> #include "llvm/IR/LLVMContext.h"<br>
>>> #include "llvm/IR/Module.h"<br>
>>> #include "llvm/Support/CommandLine.h"<br>
>>> #include "llvm/Support/ErrorOr.h"<br>
>>> #include "llvm/Support/MemoryBuffer.h"<br>
>>> #include "llvm/Support/raw_ostream.h"<br>
>>> #include "llvm/IR/PassManager.h"<br>
>>> #include "llvm/CodeGen/Passes.h"<br>
>>> #include "llvm/IR/DataLayout.h"<br>
>>> #include <llvm/Transforms/Scalar.h><br>
>>> #include "llvm/IR/LegacyPassManager.h"<br>
>>><br>
>>> using namespace llvm;<br>
>>> using namespace std;<br>
>>><br>
>>> static cl::opt<string> input(cl::Positional, cl::desc("Bitcode File.."),cl::Required);<br>
>>> static cl::opt<string> classname("classname",cl::<wbr>desc("Binary name of the generated class..."));<br>
>>><br>
>>> int main(int argc, char** argv)<br>
>>> {<br>
>>> cl::ParseCommandLineOptions(<wbr>argc, argv, "Hi..");<br>
>>> LLVMContext context;<br>
>>><br>
>>><br>
>>> ErrorOr<unique_ptr<<wbr>MemoryBuffer>> mb = MemoryBuffer::getFile(input);<br>
>>> if(error_code ec = mb.getError())<br>
>>> {<br>
>>> errs() << ec.message();<br>
>>> return 1;<br>
>>> }<br>
>>><br>
>>> Expected<unique_ptr<Module>> m = parseBitcodeFile(mb->get()-><wbr>getMemBufferRef(),context);<br>
>>> if(error_code ec= errorToErrorCode(m.takeError()<wbr>) )<br>
>>> {<br>
>>> PassManager<Module> PM;<br>
>>> DataLayout td("e-p:32:32:32"<br>
>>> "-i1:8:8-i8:8:8-i16:16:16-i32:<wbr>32:32-i64:64:64"<br>
>>> "-f32:32:32-f64:64:64");<br>
>>> PM.add(new DataLayout(td));<br>
>>> return 0;<br>
>>> }<br>
>>> ------------------------------<wbr>------------<br>
>>><br>
>>> 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.<br>
>>> ______________________________<wbr>_________________<br>
>>> LLVM Developers mailing list<br>
>>> <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
>>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
><br>
> ______________________________<wbr>_________________<br>
> LLVM Developers mailing list<br>
> <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
</div></div></blockquote></div><br></div>