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

            Bug ID: 42672
           Summary: DSE fails to remove stores to a structure overwritten
                    by asm.
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedb...@nondot.org
          Reporter: gli...@google.com
                CC: llvm-bugs@lists.llvm.org

In the following example:

void  _raw_spin_lock(void)
{
#if STRUCT
  struct {
    unsigned short owner, next;
  } lockval;
  lockval.owner = 1;
  lockval.next = 2;
#else
  int lockval;
  lockval = 3;
#endif
  asm ("nop" : "=r" (lockval));
}

|lockval| is declared as assembly output that is overwritten by the inline
assembly (as specified by constraints).
If |lockval| is a scalar type, its initialization is correctly omitted.
However if |lockval| is a struct, DSE is unable to figure out that the stores
to its fields are effectively dead:

$ clang -O2 -USTRUCT -c spinlock.c && objdump -d spinlock.o

spinlock.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <_raw_spin_lock>:
   0:   c3                      retq   


$ clang -O2 -DSTRUCT -c spinlock.c && objdump -d spinlock.o

spinlock.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <_raw_spin_lock>:
   0:   c7 44 24 f8 01 00 02    movl   $0x20001,-0x8(%rsp)
   7:   00 
   8:   90                      nop
   9:   c3                      retq

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to