Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[InstCombine] Crash on valid input when narrowing type but not updating range attribute #112633

Open
goldsteinn opened this issue Oct 16, 2024 · 1 comment · May be fixed by #112649
Open

[InstCombine] Crash on valid input when narrowing type but not updating range attribute #112633

goldsteinn opened this issue Oct 16, 2024 · 1 comment · May be fixed by #112649

Comments

@goldsteinn
Copy link
Contributor

https://godbolt.org/z/b3M1dj6aj

define void @SetRow_C(ptr %p, i32 %conv) {
entry:
  %call.i = tail call ptr @__memset_chk(ptr %p, i32 range(i32 0, 123) %conv, i64 1, i64 1)
  ret void
}

declare ptr @__memset_chk(ptr, i32, i64, i64)

We keep the range(i32 ...) when we replace the _chk with memset.inline.p0.i64 which leads to a crash:

Range bit width must match type bit width!
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(1) %p, i8 range(i32 0, 250) %0, i64 1, i1 false)
@goldsteinn
Copy link
Contributor Author

Ill have fix up in a bit. Going to basically add AttributeSet to typeIncompatible and drop range if it has become invalid.

goldsteinn added a commit to goldsteinn/llvm-project that referenced this issue Oct 17, 2024
…ith incompatible type

In a variety of places we change the bitwidth of a parameter but don't
update the attributes.

The issue in this case is from the `range` attribute when inlining
`__memset_chk`. `optimizeMemSetChk` will replace an `i32` with an
`i8`, and if the `i32` had a `range` attr assosiated it will cause an
error.

Fixes llvm#112633
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant