Skip to content

AssumeVal: a well-defined assumption has side effects - #1405

Merged
nunoplopes merged 1 commit into
AliveToolkit:masterfrom
cjsrxzdyzds:fix-unused-noundef-range-param
Dec 1, 2026
Merged

nunoplopes merged 1 commit into
AliveToolkit:masterfrom
cjsrxzdyzds:fix-unused-noundef-range-param

Conversation

@cjsrxzdyzds

Copy link
Copy Markdown
Contributor

A range attribute on a noundef parameter becomes a well-defined AssumeVal, which is UB when the value is out of range. AssumeVal::hasSideEffects() returns false, so the transform deletes it, together with the UB, when the function does not use the parameter. That function is then treated as defined for every argument. The path is reachable again since #1394.

For example, this correct transformation reports "Source is more defined than target":

define i8 @src(i8 noundef range(i8 4, 8) %x) {
  ret i8 0
}

define i8 @tgt(i8 noundef range(i8 4, 8) %x) {
  %d = sub i8 %x, 4
  %in = icmp ult i8 %d, 4
  call void @llvm.assume(i1 %in)
  ret i8 0
}

and this incorrect one, which narrows the range of an unused parameter, verifies:

define i8 @src(i8 noundef range(i8 4, 10) %x) {
  ret i8 0
}

define i8 @tgt(i8 noundef range(i8 4, 8) %x) {
  ret i8 0
}

Make hasSideEffects() return is_welldefined, as BinOp does for division. !range metadata on loads is not affected, because it is lowered to a separate assume_welldefined.

Assisted-by: Claude Code

A range attribute on a noundef parameter becomes a well-defined
AssumeVal, which triggers UB when the value is out of range. But
AssumeVal::hasSideEffects() returned false, so the transform deleted it
when the parameter was unused. A function that ignores such a parameter
was then treated as defined for every argument, which gives a false
counterexample when the target uses the parameter and misses a bug when
the target narrows the range.

Report side effects for well-defined assumptions, as for division.

Assisted-by: Claude Code (Claude Opus 5.5)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nunoplopes
nunoplopes merged commit abe0411 into AliveToolkit:master Dec 1, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants