This issue is specific to the use of bzero in a conditional expression as below.
bash-4.1$ cat test.c
typedef SIZE_TYPE size_t;
void bzero(void*, size_t);
void foo(void);
void test_bzero() {
char dst[20]; int _sz = 20, len = 20; return (_sz ? ((_sz >= len) ? bzero(dst, len) : foo()) : bzero(dst, len));
}
Compiling this test case results in the following error:
Instruction does not dominate all uses!
%arraydecay = getelementptr inbounds [20 x i8], [20 x i8]* %dst, i32 0, i32 0 %cond = phi i8* [ %arraydecay, %cond.end ], [ %arraydecay3, %cond.false2 ]
fatal error: error in backend: Broken function found, compilation aborted!
Inspecting the IR, the generation of Phi node appears to be incorrect. Looks like the phi node (for merging dst) is rather unnecessary since bzero returns void. In EmitBuiltinExpr(), bzero is replaced by a call to memset, which returns a pointer to the destination.
The proposed patch addresses this issue. The llvm test suite and spec runs are succcessful with the patch.