<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 6/16/14, 6:34 AM, Umer wrote:<br>
    </div>
    <blockquote
cite="mid:CAJf8nvAbxggFeYWn87HCyVyKEuim5b-0KH4+0pt6bfCa818v7A@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <div dir="ltr"><br>
        Hello,<br>
        <br>
        Here is the error: 
        <div><br>
          Error opening '../lib/LLVMENTRA.dylib':
          dlopen(../lib/LLVMENTRA.dylib, 9): Symbol not found:
          __ZN8CiaoType14typeInstances1E
          <div><br>
          </div>
          <div>typeInstances1 is a static variable defined in a class,
            whenever it is used during a function pass I get this error
            see below a minimal class definition.<br>
            <br>
            <br>
            class A{<br>
             static MapVector<Type*, A *> typeInstances1;<br>
             public:<br>
             static CiaoType * create(Type* T)<br>
             {<br>
                if(CiaoType * CT= typeInstances1.lookup(T))<br>
                    return CT;<br>
                else
            <div>     //create new instance and return</div>
            <div> }</div>
            <div>};</div>
            <div><br>
            </div>
            <div>As long as I don't call the create method, everything
              works fine. Any idea why the static variable symbol is not
              found in the dynamic library?</div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    I believe the problem is caused by the fact that a static class
    member variable has to be declared in a .cpp file somewhere.  I
    think the static variable in the class definition above is just a
    declaration (it's kind of like the difference between a function
    prototype and function declaration in C).<br>
    <br>
    That said, I think you're better off not declaring typeInstances1 as
    static.  I think multiple instances of an LLVM pass are supposed to
    be able to run concurrently (e.g., two modules being analyzed by two
    threads of the same process), and so a FunctionPass and ModulePass
    instantiations should not share information with each other.<br>
    <br>
    Regards,<br>
    <br>
    John Criswell<br>
    <br>
    <blockquote
cite="mid:CAJf8nvAbxggFeYWn87HCyVyKEuim5b-0KH4+0pt6bfCa818v7A@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div>
            <div><br>
            </div>
            <div><br>
            </div>
            <div>PS:</div>
            <div>here is how I load and run my pass using opt</div>
            <div><br>
              ./opt -analyze -load ../lib/LLVMENTRA.dylib -instnamer
              -mypass foo.ll <br>
            </div>
            <div><br>
            </div>
            <div>Regards</div>
            <div>Umer<br>
              <br>
              <br>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a class="moz-txt-link-freetext" href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>