[llvm-bugs] [Bug 32450] New: CallGraph failed to identify some direct calls' targets

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Mar 28 09:24:33 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=32450

            Bug ID: 32450
           Summary: CallGraph failed to identify some direct calls'
                    targets
           Product: new-bugs
           Version: 3.9
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: aquach1 at binghamton.edu
                CC: llvm-bugs at lists.llvm.org

Attached are LLVM assembly and bitcode files to reproduce the problem. I also
attached the callgraph retrieved from opt. They are compiled from musl libc
version 1.1.16 with LLVM LTO. 

The callgraph generated by opt from this bitcode shows only 1 direct callee of
function __fwritex.
Call graph node for function: '__fwritex'<<0x6784590>>  #uses=5
  CS<0x61b65e0> calls external node
  CS<0x61b7080> calls external node
  CS<0x61b8260> calls external node
  CS<0x61b8d20> calls function 'memcpy'

However, source code says there is another direct callsite to __towrite. This
is compiled into a direct call in the result binary as well.
size_t __fwritex(const unsigned char *restrict s, size_t l, FILE *restrict f)
{
        size_t i=0;

        if (!f->wend && __towrite(f)) return 0;

        if (l > f->wend - f->wpos) return f->write(f, s, l);

        if (f->lbf >= 0) {
                /* Match /^(.*\n|)/ */
                for (i=l; i && s[i-1] != '\n'; i--);
                if (i) {
                        size_t n = f->write(f, s, i);
                        if (n < i) return n;
                        s += i;
                        l -= i;
                }
        }

        memcpy(f->wpos, s, l);
        f->wpos += l;
        return l+i;
}

Another example is function _flushlbf where the direct call to fflush does not
show up in its callgraph. This also appears as a direct call in executable.
void _flushlbf(void)
{
        fflush(0);
}

Call graph node for function: '_flushlbf'<<0x6782160>>  #uses=1
  CS<0x6151c40> calls external node

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170328/f005e549/attachment.html>


More information about the llvm-bugs mailing list