<div dir="ltr">Hi Ratnesh,<div><br></div><div>the PassManager used in that example has moved into the legacy namespace: <a href="http://llvm.org/doxygen/classllvm_1_1legacy_1_1PassManager.html">http://llvm.org/doxygen/classllvm_1_1legacy_1_1PassManager.html</a></div><div><br></div><div>Cheers,</div><div>Philip</div></div><br><div class="gmail_quote"><div dir="ltr">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></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">
<div class="m_6146228440860735067gmail-votecell m_6146228440860735067gmail-post-layout--left" style="margin:0px;padding:0px 15px 0px 0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;vertical-align:top;box-sizing:inherit;width:auto;text-align:left;text-decoration-style:initial;text-decoration-color:initial">Hi, I am begineer to llvm, implementing a main.cpp from <a href="https://github.com/davidar/lljvm/blob/master/backend/main.cpp" target="_blank">https://github.com/davidar/lljvm/blob/master/backend/main.cpp</a></div><div class="m_6146228440860735067gmail-votecell m_6146228440860735067gmail-post-layout--left" style="margin:0px;padding:0px 15px 0px 0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;vertical-align:top;box-sizing:inherit;width:auto;text-align:left;text-decoration-style:initial;text-decoration-color:initial"><br></div><div class="m_6146228440860735067gmail-votecell m_6146228440860735067gmail-post-layout--left" style="margin:0px;padding:0px 15px 0px 0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;vertical-align:top;box-sizing:inherit;width:auto;text-align:left;text-decoration-style:initial;text-decoration-color:initial">A) : When I am declaring a command:</div><div class="m_6146228440860735067gmail-votecell m_6146228440860735067gmail-post-layout--left" style="margin:0px;padding:0px 15px 0px 0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;vertical-align:top;box-sizing:inherit;width:auto;text-align:left;text-decoration-style:initial;text-decoration-color:initial"><i> <b>PassManager PM</b></i></div><div class="m_6146228440860735067gmail-votecell m_6146228440860735067gmail-post-layout--left" style="margin:0px;padding:0px 15px 0px 0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;vertical-align:top;box-sizing:inherit;width:auto;text-align:left;text-decoration-style:initial;text-decoration-color:initial"><i><b> PM.add(new DataLayout td)</b></i></div><div class="m_6146228440860735067gmail-votecell m_6146228440860735067gmail-post-layout--left" style="margin:0px;padding:0px 15px 0px 0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;vertical-align:top;box-sizing:inherit;width:auto;text-align:left;text-decoration-style:initial;text-decoration-color:initial"><i><br></i></div><div class="m_6146228440860735067gmail-votecell m_6146228440860735067gmail-post-layout--left" style="margin:0px;padding:0px 15px 0px 0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;vertical-align:top;box-sizing:inherit;width:auto;text-align:left;text-decoration-style:initial;text-decoration-color:initial">It shows error:</div><div class="m_6146228440860735067gmail-votecell m_6146228440860735067gmail-post-layout--left" style="margin:0px;padding:0px 15px 0px 0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;vertical-align:top;box-sizing:inherit;width:auto;text-align:left;text-decoration-style:initial;text-decoration-color:initial">><b>error: missing template arguments before ‘PM’<br></b></div><div class="m_6146228440860735067gmail-votecell m_6146228440860735067gmail-post-layout--left" style="margin:0px;padding:0px 15px 0px 0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;vertical-align:top;box-sizing:inherit;width:auto"><b> PassManager PM;</b></div><div class="m_6146228440860735067gmail-votecell m_6146228440860735067gmail-post-layout--left" style="margin:0px;padding:0px 15px 0px 0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;vertical-align:top;box-sizing:inherit;width:auto"> ^</div><div class="m_6146228440860735067gmail-votecell m_6146228440860735067gmail-post-layout--left" style="margin:0px;padding:0px 15px 0px 0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;vertical-align:top;box-sizing:inherit;width:auto">><b>main_test.cpp:48:2: error: ‘PM’ was not declared in this scope</b></div><div class="m_6146228440860735067gmail-votecell m_6146228440860735067gmail-post-layout--left" style="margin:0px;padding:0px 15px 0px 0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;vertical-align:top;box-sizing:inherit;width:auto"><b> PM.add(new DataLayout(td));</b></div><div class="m_6146228440860735067gmail-votecell m_6146228440860735067gmail-post-layout--left" style="margin:0px;padding:0px 15px 0px 0px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;vertical-align:top;box-sizing:inherit;width:auto"><br></div>
Keeping in mind the above error, I changed the code as:<div><i><b>PassManager<Module> PM</b></i></div><div><i><b>PM.add(new DataLayout td)</b></i></div><div><i><br></i></div><div>I dont know, whether the above change is the correct one or not. But the error is changed to:</div><div><br></div><div>><b>error: ‘class llvm::PassManager<llvm::Module>’ has no member named ‘add’</b></div><div><b> PM.add(new DataLayout(td));</b></div><div><br></div><div>Here is mine source code:</div><div>-----------------------------------------------</div><div><div>#include "backened.h"</div><div>#include <iostream></div><div>#include "llvm/Bitcode/BitcodeReader.h"</div><div>#include "llvm/IR/Function.h"</div><div>#include "llvm/IR/LLVMContext.h"</div><div>#include "llvm/IR/Module.h"</div><div>#include "llvm/Support/CommandLine.h"</div><div>#include "llvm/Support/ErrorOr.h"</div><div>#include "llvm/Support/MemoryBuffer.h"</div><div>#include "llvm/Support/raw_ostream.h"</div><div>#include "llvm/IR/PassManager.h"</div><div>#include "llvm/CodeGen/Passes.h"</div><div>#include "llvm/IR/DataLayout.h"</div><div>#include <llvm/Transforms/Scalar.h></div><div>#include "llvm/IR/LegacyPassManager.h"</div><div><br></div><div>using namespace llvm;</div><div>using namespace std;</div><div><br></div><div>static cl::opt<string> input(cl::Positional, cl::desc("Bitcode File.."),cl::Required);</div><div>static cl::opt<string> classname("classname",cl::desc("Binary name of the generated class..."));</div><div><br></div><div>int main(int argc, char** argv)</div><div>{</div><div> cl::ParseCommandLineOptions(argc, argv, "Hi..");</div><div> LLVMContext context;</div><div><br></div><div><br></div><div> ErrorOr<unique_ptr<MemoryBuffer>> mb = MemoryBuffer::getFile(input);</div><div> if(error_code ec = mb.getError())</div><div> {</div><div> errs() << ec.message();</div><div> return 1;</div><div> }</div><div><br></div><div> Expected<unique_ptr<Module>> m = parseBitcodeFile(mb->get()->getMemBufferRef(),context);</div><div> if(error_code ec= errorToErrorCode(m.takeError()) )</div><div> {</div></div><div><div> PassManager<Module> PM;</div><div> DataLayout td("e-p:32:32:32"</div><div> "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64"</div><div> "-f32:32:32-f64:64:64");</div><div> PM.add(new DataLayout(td));</div></div><div> return 0;</div><div>}</div><div>------------------------------------------</div><div><br></div><div>B) Also suggest me , whether I am implemented a correct way "<i>DataLayout td ("e-p:32:32:32......")" </i>and "<i>new DataLayout td" </i>in the place of TargetData.h as I found that TargeyData.h is not found in newer version of llvm. Thank you.</div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">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/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>