Commit f6f9825e by Jim Stichnoth

Subzero: Fix an Om1 crash from memset lowering.

With a certain combination of memset arguments, legalizeToReg() is called but its result is unused. Om1 register allocation does not like this because it sees an infinite-weight variable with a definition but no uses. The simplest fix is to add a fake use. The problem shows up when building spec2k with -Om1. BUG= none R=ascull@google.com Review URL: https://codereview.chromium.org/1272823004.
parent 552490c2
......@@ -3804,6 +3804,10 @@ void TargetX86Base<Machine>::lowerMemset(Operand *Dest, Operand *Val,
// eax, ax and al.
if (IsCountConst && IsValConst) {
Variable *Base = legalizeToReg(Dest);
// Add a FakeUse in case Base is ultimately not used, e.g. it falls back to
// calling memset(). Otherwise Om1 register allocation fails because this
// infinite-weight variable has a definition but no uses.
Context.insert(InstFakeUse::create(Func, Base));
// 3 is the awkward size as it is too small for the vector or 32-bit
// operations and will not work with lowerLeftOvers as there is no valid
......
......@@ -101,6 +101,19 @@ entry:
; ARM32: uxtb
; ARM32: bl {{.*}} memset
define void @test_memset_long_const_len_zero_val_align(i32 %iptr_dst) {
entry:
%dst = inttoptr i32 %iptr_dst to i8*
call void @llvm.memset.p0i8.i32(i8* %dst, i8 0,
i32 4876, i32 1, i1 false)
ret void
}
; CHECK-LABEL: test_memset_long_const_len_zero_val_align
; CHECK: call {{.*}} R_{{.*}} memset
; ARM32-LABEL: test_memset_long_const_len_zero_val_align
; ARM32: uxtb
; ARM32: bl {{.*}} memset
define void @test_memset_const_val(i32 %iptr_dst, i32 %len) {
entry:
%dst = inttoptr i32 %iptr_dst to i8*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment