<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    On 5/23/11 1:32 PM, George Baah wrote:
    <blockquote
      cite="mid:BANLkTik8MBLhuKnpKAADRTFDBX-azeD9Ww@mail.gmail.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      I see that some of the system header-file definitions have the
      internal keyword.
      <div>For example, </div>
      <div>
        <div><br>
        </div>
        <div>define internal void @__cxx_global_var_init() section
          "__TEXT,__StaticInit,regular,pure_instructions" {</div>
        <div>entry:</div>
        <div>  call void
          @_ZNSt8ios_base4InitC1Ev(%"class.std::ios_base::Init"*
          @_ZStL8__ioinit)</div>
        <div>  %0 = call i32 @__cxa_atexit(void (i8*)* bitcast (void
          (%"class.std::ios_base::Init"*)* @_ZNSt8ios_base4InitD1Ev to
          void (i8*)*), i8* getelementptr </div>
        <div>inbounds (%"class.std::ios_base::Init"* @_ZStL8__ioinit,
          i32 0, i32 0), i8* bitcast (i8** @__dso_handle to i8*))</div>
        <div>  ret void</div>
        <div>}</div>
      </div>
    </blockquote>
    <br>
    Indeed.  Functions defined with the static keyword in C/C++ get
    internal LLVM linkage when compiled to LLVM bitcode.  This makes the
    function name invisible to other functions in other compilation
    units that might be linked with this bitcode file later on.<br>
    <br>
    Internal linkage, however, is not a sign that a function came from a
    header file.  Programmers can write their own static functions
    within their own code.<br>
    <br>
    -- John T.<br>
    <br>
    <blockquote
      cite="mid:BANLkTik8MBLhuKnpKAADRTFDBX-azeD9Ww@mail.gmail.com"
      type="cite"><br>
      <div class="gmail_quote">On Mon, May 23, 2011 at 2:24 PM, John
        Criswell <span dir="ltr"><<a moz-do-not-send="true"
            href="mailto:criswell@illinois.edu">criswell@illinois.edu</a>></span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">
          <div text="#000000" bgcolor="#ffffff">
            <div>
              <div class="h5"> On 5/23/11 1:05 PM, George Baah wrote:
                <blockquote type="cite"> Hi,
                  <div> I am writing a pass which is supposed to ignore
                    library functions. Is there a way to </div>
                  <div>distinguish functions declared and defined by a
                    developer from non-local functions (library
                    functions)? </div>
                  <div>Thanks.</div>
                </blockquote>
                <br>
              </div>
            </div>
            There is no reliable way to do this, but there are several
            heuristics that will probably work well in practice.<br>
            <br>
            When analyzing a program, any function that is defined
            (i.e., has a function body) most likely came from the
            program's source code.  The exception will be functions
            declared in system header files or C/C++ library header
            files.<br>
            <br>
            Any function that is declared but not defined (i.e., has no
            function body) is either a function that is defined in
            another translation unit (i.e., another source file) or
            defined in a system or language library (e.g., libc).  It
            is, in general, not possible to distinguish between the two
            situations, although if you've linked your entire program
            into a single bitcode file, the only external functions are
            coming from library functions.<br>
            <br>
            -- John T.<br>
            <br>
            <blockquote type="cite">
              <div><br>
              </div>
              <div>George</div>
              <pre><fieldset></fieldset>
_______________________________________________
LLVM Developers mailing list
<a moz-do-not-send="true" href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a moz-do-not-send="true" href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a>
<a moz-do-not-send="true" href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a>
</pre>
            </blockquote>
            <br>
          </div>
        </blockquote>
      </div>
      <br>
    </blockquote>
    <br>
  </body>
</html>