Skip to content

[mem2reg] Local alloca optimization incorrect for read-before-write case #962

@llvmbot

Description

@llvmbot
Bugzilla Link 590
Resolution FIXED
Resolved on Feb 22, 2010 12:42
Version 1.4
OS All
Reporter LLVM Bugzilla Contributor

Extended Description

llvm-gcc miscompiles the following function:

void zero(char *p, int n) {
int i;
int out, undef;
for (i = 0; i < n+1; ++i) {
out = undef;
undef = 0;
if (i > 0)
p[i-1] = out;
}
}

This function zeros out n locations starting at p. (out is undefined on iteration 0 of the loop, but it is
not written there.) llvm-gcc miscompiles this function to ret void. I have narrowed the problem down
to the scalarrepl pass. When I compile with scalarrepl in, it fails, and with scalarrepl out it succeeds.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions