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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to