<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - [Attributor] Null checks not eliminated"
href="https://bugs.llvm.org/show_bug.cgi?id=44149">44149</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[Attributor] Null checks not eliminated
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Scalar Optimizations
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>david.bolvansky@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>#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
<a href="https://godbolt.org/z/FEDeNG">https://godbolt.org/z/FEDeNG</a></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>