[llvm-bugs] [Bug 44149] New: [Attributor] Null checks not eliminated

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 26 06:12:03 PST 2019


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

            Bug ID: 44149
           Summary: [Attributor] Null checks not eliminated
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: david.bolvansky at gmail.com
                CC: llvm-bugs at lists.llvm.org

#include <string.h>
int a;
extern char *p[2];
char* foo(char *s);

static char *bar(char *s) {
    if(!s) return 0;
    return foo(s);
}

void test(char *s) {
    p[0]= strchr(s, a);
    p[1]= bar(s);
}

test(char*): # @test(char*)
  push rbx
  mov rbx, rdi
  mov esi, dword ptr [rip + a]
  call strchr
  mov qword ptr [rip + p], rax
  test rbx, rbx
  je .LBB0_1
  mov rdi, rbx
  call foo(char*)
  mov qword ptr [rip + p+8], rax
  pop rbx
  ret
.LBB0_1:
  xor eax, eax
  mov qword ptr [rip + p+8], rax
  pop rbx
  ret


Looking at IR, but know everything to be able to eliminate this null check...

test(char*): # @test(char*)
  push rbx
  mov rbx, rdi
  mov esi, dword ptr [rip + a]
  call strchr
  mov qword ptr [rip + p], rax
  mov rdi, rbx
  call foo(char*)
  mov qword ptr [rip + p+8], rax
  pop rbx
  ret


https://godbolt.org/z/FEDeNG

-- 
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/20191126/458e3a0d/attachment.html>


More information about the llvm-bugs mailing list