<div dir="ltr">I noticed something else, I just made a change to my x86 wawanalyzer and make it again. And I can't see the change in my output. So the problem is with all my targets. <div>After I ran my first sunctionpass in x86, I needed to crosscopmpile LLVM so I ran the following instructions a couple of days ago:</div><div><div>$ cd <llvm_build_dir></div><div>$ <PATH_TO_SOURCE>/configure --enable-targets=arm --disable-optimized</div><div>--prefix=/usr/local/llvm-arm --target=armv7a-unknown-linux-gnueabi</div><div>$ make && sudo make install</div></div><div>Does my problem have to do something with these instructions?</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 17, 2015 at 11:29 AM, fateme Hoseini <span dir="ltr"><<a href="mailto:hoseini.f@gmail.com" target="_blank">hoseini.f@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Yes, I have done exactly the same. The wawanalyzer is the same. I changed ARM.h and ARMTargetMachine.cpp in the tager/arm folder. then I make tool/llc and lib folder. </div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 17, 2015 at 10:55 AM, John Criswell <span dir="ltr"><<a href="mailto:jtcriswel@gmail.com" target="_blank">jtcriswel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000"><span>
    <div>On 11/17/15 12:16 AM, fateme Hoseini
      via llvm-dev wrote:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr"><span>Hi, </span><br>
        <span>So, I run my pass in X86 target with llc command and it
          printed out "hello****". Now I am trying to do the same pass
          for ARM target. So I did exactly what I did for X86 as
          mentioned in my previous posts. When I run the following
          command: </span><br>
      </div>
    </blockquote>
    <br></span>
    Have you modified the ARM code generator to run your pass (the same
    way that you modified the X86 code generator to run your pass)?<br>
    <br>
    Each backend has code that configures the set of
    MachineFunctionPass'es to run when that code generator is used.  For
    each backend, you must modify that code to run your
    MachineFunctionPass.<br>
    <br>
    Regards,<br>
    <br>
    John Criswell<div><div><br>
    <br>
    <blockquote type="cite">
      <div dir="ltr"><span>llc -march=arm test.ll -o test </span><br>
        <span>nothing prints out. I did the same for MIPS target too and
          I got no result. Can anyone tell me what I'm doing wrong. Is
          there any difference between writing machinefunction passes in
          x86 and other targets? </span><br>
        <span>Thank you, </span><br>
        <span>Fami </span><br>
      </div>
      <div class="gmail_extra"><br>
        <div class="gmail_quote">On Fri, Nov 6, 2015 at 10:56 AM, fateme
          Hoseini <span dir="ltr"><<a href="mailto:hoseini.f@gmail.com" target="_blank">hoseini.f@gmail.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote">
            <div dir="ltr">Hi
              <div>So I m trying to write my first backend pass. I
                created a file in target\x86\wawanalyzer.cpp based on
                hexagonHardwareLoops.cpp file. Now it's just a simple
                file that prints hello to the output. I have attached
                the file to this post.</div>
              <div><br>
              </div>
              <div>Then I did the following:</div>
              <div><br>
              </div>
              <div>1. add "FunctionPass *createwawAnalyzer();" line to
                x86.h</div>
              <div>2. add file name to CMakelist.txt.</div>
              <div>3. This is going to run after postRAscheduler and
                before code emission so I changed the
                x86TrgetMachine.cpp as follow:</div>
              <div>
                <div>void X86PassConfig::addPreEmitPass() {</div>
                <div>/////////////add mypass here///////</div>
                <div>  addPass(createwawAnalyzer());</div>
                <div>//////////////////////////////////</div>
                <div><span> </span></div>
                <div>  if (getOptLevel() != CodeGenOpt::None)</div>
                <div>   
                  addPass(createExecutionDependencyFixPass(&X86::VR128RegClass));</div>
                <div><br>
                </div>
                <div>  if (UseVZeroUpper)</div>
                <div>    addPass(createX86IssueVZeroUpperPass());</div>
                <div><br>
                </div>
                <div>  if (getOptLevel() != CodeGenOpt::None) {</div>
                <div>    addPass(createX86PadShortFunctions());</div>
                <div>    addPass(createX86FixupLEAs());</div>
                <div>  }</div>
              </div>
              <div>then I run make on mypass and remake  llvm3.7\lib and
                llvm3.7\tool\llc.</div>
              <div>but when I run llc -help it doesn't show my pass. Did
                I miss some steps or did something wrong? What's the
                correct way to run the pass with llc command?</div>
              <div><br>
              </div>
              <div>I appreciate any help,</div>
              <div>Regards</div>
              <div>Fami</div>
            </div>
            <div>
              <div>
                <div class="gmail_extra"><br>
                  <div class="gmail_quote">On Wed, Nov 4, 2015 at 1:02
                    PM, fateme Hoseini <span dir="ltr"><<a href="mailto:hoseini.f@gmail.com" target="_blank"></a><a href="mailto:hoseini.f@gmail.com" target="_blank">hoseini.f@gmail.com</a>></span>
                    wrote:<br>
                    <blockquote class="gmail_quote">
                      <div dir="ltr">Thank you so much. 
                        <div>That helped alot.</div>
                        <div><br>
                        </div>
                        <div>Fami</div>
                      </div>
                      <div>
                        <div>
                          <div class="gmail_extra"><br>
                            <div class="gmail_quote">On Wed, Nov 4, 2015
                              at 9:40 AM, John Criswell <span dir="ltr"><<a href="mailto:jtcriswel@gmail.com" target="_blank"></a><a href="mailto:jtcriswel@gmail.com" target="_blank">jtcriswel@gmail.com</a>></span>
                              wrote:<br>
                              <blockquote class="gmail_quote">
                                <div><span>
                                    <div>On 11/3/15 7:54 PM, fateme
                                      Hoseini wrote:<br>
                                    </div>
                                    <blockquote type="cite">
                                      <div dir="ltr">Dear John,
                                        <div>Thank you so much for your
                                          help. I looked at those
                                          documents. Could you kindly
                                          answer the following
                                          questions:</div>
                                        <div><br>
                                        </div>
                                        <div>Does it mean that I have to
                                          make my own backend target in
                                          order to write a machine pass
                                          even if I want to run a simple
                                          machinefunction pass?  for
                                          example,if I want my pass to
                                          get MIPS instructions as an
                                          input, I have to copy all the
                                          files from mips target and add
                                          a file to it which implements
                                          my pass. and there should be a
                                          way to connect the pass to
                                          other MIPS backend files? <br>
                                        </div>
                                      </div>
                                    </blockquote>
                                    <br>
                                  </span> No, you do not need to create
                                  a new backend.  All you need to do is
                                  to add your pass to the list of passes
                                  that are run when the MIPS code
                                  generator is used.<br>
                                  <br>
                                  In LLVM 3.3, there was a file in the
                                  X86 backend that had code to schedule
                                  all the MachineFunctionPass'es  when
                                  the X86 code generator was used.  That
                                  was in
                                  lib/Target/X86/X86TargetMachine.cpp. 
                                  You can probably find a similar file
                                  for LLVM 3.7 for the MIPS backend.<br>
                                  <br>
                                  So, to summarize, you'll add your
                                  source file to the MIPS backend, add a
                                  line somewhere to run your pass when
                                  the MIPS code generator is used, and
                                  then recompile llvm/lib and
                                  llvm/tools/llc.<span><br>
                                    <br>
                                    <br>
                                    <blockquote type="cite">
                                      <div dir="ltr">
                                        <div><br>
                                        </div>
                                        <div>As a result, is the way
                                          that I described in my first
                                          post completely wrong because
                                          I cannot run a stand alone
                                          machine function pass like a
                                          frontend function pass?</div>
                                      </div>
                                    </blockquote>
                                    <br>
                                  </span> As far as I know, there is no
                                  way to load a MachineFunctionPass and
                                  run it using llc, opt, or clang.  I
                                  believe you need to compile it into
                                  the MIPS backend code.<span><br>
                                    <br>
                                    <blockquote type="cite">
                                      <div dir="ltr">
                                        <div><br>
                                        </div>
                                        <div>Also another question, I'm
                                          a PhD student and I'm
                                          completely new to the llvm
                                          backend process. I want to
                                          estimate my project time. How
                                          long approximately do you
                                          think it will take to be get
                                          familiar with backend and be
                                          able to write machinefunction
                                          pass? for further steps I have
                                          to implement a register
                                          allocation algorithm.</div>
                                      </div>
                                    </blockquote>
                                    <br>
                                  </span> It's difficult to estimate
                                  (especially since I haven't
                                  implemented anything as complicated as
                                  a register allocator).  Your profiling
                                  pass may take anywhere from 1 week to
                                  1 month depending on how complicated
                                  it is.  I think a register allocator
                                  would take anywhere from 1 month up to
                                  6 months depending on how robust you
                                  need it to be, but since I've never
                                  built one, I can't say for certain.<br>
                                  <br>
                                  Regards,<br>
                                  <br>
                                  John Criswell
                                  <div>
                                    <div><br>
                                      <br>
                                      <blockquote type="cite">
                                        <div dir="ltr">
                                          <div><br>
                                          </div>
                                          <div>Regards,</div>
                                          <div>Fami</div>
                                          <div><br>
                                          </div>
                                        </div>
                                        <div class="gmail_extra"><br>
                                          <div class="gmail_quote">On
                                            Tue, Nov 3, 2015 at 3:52 PM,
                                            John Criswell <span dir="ltr"><<a href="mailto:jtcriswel@gmail.com" target="_blank"></a><a href="mailto:jtcriswel@gmail.com" target="_blank">jtcriswel@gmail.com</a>></span>
                                            wrote:<br>
                                            <blockquote class="gmail_quote">
                                              <div>
                                                <div>Dear Fami,<br>
                                                  <br>
                                                  A MachineFunctionPass
                                                  is run by the code
                                                  generator, so you can
                                                  only use it in tools
                                                  like llc, clang, and
                                                  libLTO.  The opt
                                                  program only
                                                  manipulates LLVM IR
                                                  and therefore does not
                                                  run
                                                  MachineFunctionPass'es.<br>
                                                  <br>
                                                  Regarding
                                                  documentation, have
                                                  you looked at the
                                                  following?<br>
                                                  <br>
                                                  <a href="http://llvm.org/docs/WritingAnLLVMBackend.html" target="_blank"></a><a href="http://llvm.org/docs/WritingAnLLVMBackend.html" target="_blank">http://llvm.org/docs/WritingAnLLVMBackend.html</a><br>
                                                  <a href="http://llvm.org/docs/CodeGenerator.html" target="_blank"></a><a href="http://llvm.org/docs/CodeGenerator.html" target="_blank">http://llvm.org/docs/CodeGenerator.html</a><br>
                                                  <a href="http://llvm.org/docs/MIRLangRef.html" target="_blank"></a><a href="http://llvm.org/docs/MIRLangRef.html" target="_blank">http://llvm.org/docs/MIRLangRef.html</a><br>
                                                  <br>
                                                  Regards,<br>
                                                  <br>
                                                  John Criswell
                                                  <div>
                                                    <div><br>
                                                      <br>
                                                      On 11/3/15 3:47
                                                      PM, fateme Hoseini
                                                      via llvm-dev
                                                      wrote:<br>
                                                    </div>
                                                  </div>
                                                </div>
                                                <blockquote type="cite">
                                                  <div>
                                                    <div>
                                                      <div dir="ltr">
                                                        <div>Hi
                                                          everyone,</div>
                                                        <div>I am a LLVM
                                                          newbie. I need
                                                          to write a
                                                          machinefunction
                                                          pass for my
                                                          project. This
                                                          should be an
                                                          analyzer of
                                                          the machine
                                                          code to do
                                                          some
                                                          profiling. I
                                                          have written a
                                                          couple of
                                                          function
                                                          passes for
                                                          front end, but
                                                          it seems they
                                                          are completely
                                                          different. I
                                                          searched
                                                          through forum
                                                          and llvm
                                                          documents, but
                                                          couldn't find
                                                          anything
                                                          useful or
                                                          questions were
                                                          unanswered.
                                                          Can anyone
                                                          reference me
                                                          to any
                                                          material on
                                                          how to do that
                                                          or help me
                                                          with my
                                                          roblem.</div>
                                                        <div><br>
                                                        </div>
                                                        <div>I have
                                                          created a
                                                          folder in:
                                                          lib/Transform
                                                          and put my
                                                          pass in it.</div>
                                                        <div>I am
                                                          writing a
                                                          simple pass
                                                          like this:</div>
                                                        <div><br>
                                                        </div>
                                                        <div>using
                                                          namespace
                                                          llvm;</div>
                                                        <div><br>
                                                        </div>
                                                        <div>namespace {</div>
                                                        <div><span> </span></div>
                                                        <div>    struct
                                                          analyzer :
                                                          public
                                                          MachineFunctionPass
                                                          {</div>
                                                        <div><span> </span>static
                                                          char ID; </div>
                                                        <div><span> </span>analyzer()
                                                          :
                                                          MachineFunctionPass(ID)
                                                          {}<span> </span>
                                                            <span> </span></div>
                                                        <div><span> </span></div>
                                                        <div><span> </span>virtual
                                                          bool
                                                          runOnMachineFunction(MachineFunction
                                                          &MF) {<span>
                                                          </span></div>
                                                        <div><span> </span>errs()
                                                          <<
                                                          "hello " ;</div>
                                                        <div><span> </span></div>
                                                        <div><span> </span>return
                                                          false;<span> </span></div>
                                                        <div><span> </span>}</div>
                                                        <div>  };</div>
                                                        <div>}</div>
                                                        <div>char
                                                          analyzer::ID =
                                                          0;</div>
                                                        <div>static
                                                          RegisterPass<analyzer>
                                                          X("analyzer",
                                                          "WAW
                                                          analyzer");</div>
                                                        <div><br>
                                                        </div>
                                                        <div>I make it
                                                          successfully.
                                                          But when I
                                                          load it for my
                                                          test code I
                                                          get this
                                                          error:</div>
                                                        <div><br>
                                                        </div>
                                                        <div>
                                                          <div>Pass 'WAW
                                                          analyzer' is
                                                          not
                                                          initialized.</div>
                                                          <div>Verify if
                                                          there is a
                                                          pass
                                                          dependency
                                                          cycle.</div>
                                                          <div>Required
                                                          Passes:</div>
                                                          <div>opt:
                                                          /llvm/llvm-3.7/lib/IR/LegacyPassManager.cpp:635:
                                                          void
                                                          llvm::PMTopLevelManager::schedulePass(llvm::Pass*):
                                                          Assertion `PI
                                                          &&
                                                          "Expected
                                                          required
                                                          passes to be
                                                          initialized"'
                                                          failed.</div>
                                                          <div>.....</div>
                                                        </div>
                                                        <div><br>
                                                        </div>
                                                        <div>I don't
                                                          know how to
                                                          solve it? Do
                                                          we have to run
                                                          machinefunction
                                                          passes with
                                                          OPT command?
                                                          Is this
                                                          correct to put
                                                          machinefunction
                                                          pass in an
                                                          external
                                                          folder or do
                                                          we have to
                                                          change some
                                                          llvm built-in
                                                          files? </div>
                                                        <div><br>
                                                        </div>
                                                        <div>Regards,<br>
                                                        </div>
                                                        <div>Fami</div>
                                                        <div><br>
                                                        </div>
                                                      </div>
                                                      <br>
                                                      <fieldset></fieldset>
                                                      <br>
                                                    </div>
                                                  </div>
                                                  <pre>_______________________________________________
LLVM Developers mailing list
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><span>
</span></pre>
                                                  <span> </span></blockquote>
                                                <span> <br>
                                                  <br>
                                                  <pre cols="72">-- 
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a href="http://www.cs.rochester.edu/u/criswell" target="_blank">http://www.cs.rochester.edu/u/criswell</a></pre>
                                                </span></div>
                                            </blockquote>
                                          </div>
                                          <br>
                                        </div>
                                      </blockquote>
                                      <br>
                                      <br>
                                      <pre cols="72">-- 
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a href="http://www.cs.rochester.edu/u/criswell" target="_blank">http://www.cs.rochester.edu/u/criswell</a></pre>
                                    </div>
                                  </div>
                                </div>
                              </blockquote>
                            </div>
                            <br>
                          </div>
                        </div>
                      </div>
                    </blockquote>
                  </div>
                  <br>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
LLVM Developers mailing list
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
    </blockquote>
    <br>
    <br>
    <pre cols="72">-- 
John Criswell
Assistant Professor
Department of Computer Science, University of Rochester
<a href="http://www.cs.rochester.edu/u/criswell" target="_blank">http://www.cs.rochester.edu/u/criswell</a></pre>
  </div></div></div>

</blockquote></div><br></div>
</div></div></blockquote></div><br></div>