[LLVMbugs] [Bug 18788] New: Clang misses static variable optimization

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Sun Feb 9 16:23:33 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=18788

            Bug ID: 18788
           Summary: Clang misses static variable optimization
           Product: clang
           Version: 3.4
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ju.orth at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Consider the following code.

====
void g(void);
void h(void);

static void f(void)
{
    static int i;
    if (!i) {
        i = 1;
        h();
    }
    g();
}

int main(void)
{
    f();
    f();
}
====

Clang inlines `f()` but repeats the `!i` check. Expected result:

====
int main(void)
{
    h();
    g();
    g();
}
====

which is the result when I manually inline `f()`.

-- 
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/20140210/4ed984f8/attachment.html>


More information about the llvm-bugs mailing list