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: unassignedb...@nondot.org
Reporter: david.bolvan...@gmail.com
CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs