[llvm-bugs] [Bug 41178] New: clang strict-aliasing optimizations vs unreachable code

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 21 04:30:18 PDT 2019


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

            Bug ID: 41178
           Summary: clang strict-aliasing optimizations vs unreachable
                    code
           Product: libraries
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: paul_st at list.ru
                CC: llvm-bugs at lists.llvm.org

Created attachment 21640
  --> https://bugs.llvm.org/attachment.cgi?id=21640&action=edit
test with unreachable code

Lets consider example r.c from attachment

$ clang-7.0 -O0 r.c -o r0.out
$ clang-7.0 -O1 r.c -fno-strict-aliasing -o r1.nsa.out
$ clang-7.0 -O1 r.c -o r1.sa.out

$ ./r0.out
this should be zero: 0

$ ./r1.nsa.out
this should be zero: 0

$ ./r1.sa.out
this should be zero: -1


static inline void __attribute__((always_inline)) longLongAssign( int cond,
char *ptr)
{
    if ( cond )
    {
        *((long long *)ptr) = 0;
    }
}

I suppose test doesn't violate strict-aliasing rule, because
1) argument "ptr" has type "char *"
2) condition "cond" is always zero

Why I got different results?

P.S. I am new therefore apologize for my mistakes.

-- 
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/20190321/b87bce37/attachment.html>


More information about the llvm-bugs mailing list