Repository navigation
llvm2alive: do not skip range and initializes param attributes - #1394
Merged
Merged
Conversation
AliveToolkit#1352 made handleParamAttrs skip every attribute that is not an enum, int or type attribute, to keep string attributes away from getKindAsEnum(). That also skips the constant range attributes, so the Range and Initializes cases of the switch became unreachable and a range or initializes attribute on a parameter was silently ignored. Skip only string attributes, as intended. Assisted-by: Claude Code (Claude Opus 5.5) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nunoplopes
pushed a commit
that referenced
this pull request
Dec 1, 2026
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": ```llvm 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 } ``` 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 Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#1352 added a check at the top of
handleParamAttrsthat lets only enum, int and type attributes reach the switch, so that string attributes no longer reachgetKindAsEnum().rangeandinitializesare constant range attributes, so their cases in the switch became unreachable, and both have been ignored on parameters since then.For example, this incorrect transformation verifies:
and this correct one reports a value mismatch:
The existing test
alive-tv/uscmp.srctgt.ll, which hasrangeparameters, fails for the same reason.Skip only string attributes, as #1352 intended.
Assisted-by: Claude Code