[llvm-bugs] [Bug 41112] New: missed opt: indeterminate value in lvalue expression does not optimize function call away

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Mar 17 04:42:14 PDT 2019


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

            Bug ID: 41112
           Summary: missed opt: indeterminate value in lvalue expression
                    does not optimize function call away
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: gonzalobg88 at gmail.com
                CC: llvm-bugs at lists.llvm.org

This code (https://gcc.godbolt.org/z/Zw-9jM):

extern int foo(int);

int bar() {
    int a;
    return foo(a);
}

int baz() {
    int a;
    return a;
}

compiles with -O3 to:

bar:                                    # @bar
        jmp     foo                     # TAILCALL
baz:                                    # @baz
        retq

Here, `baz` is optimized away because an indeterminate value participates in an
lvalue-expression, which is undefined behavior.

However, an indeterminate value participates in an lvalue expression in `bar`,
yet the call to `foo` is not optimized away. I believe it should.

-- 
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/20190317/50caea2c/attachment-0001.html>


More information about the llvm-bugs mailing list