Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ir/instr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3783,7 +3783,9 @@ bool AssumeVal::propagatesPoison() const {
}

bool AssumeVal::hasSideEffects() const {
return false;
// A well-defined assumption is UB when it fails, so it must stay even if its
// result is unused.
return is_welldefined;
}

DEFINE_AS_RETZERO(AssumeVal, getMaxGEPOffset)
Expand Down
10 changes: 10 additions & 0 deletions tests/alive-tv/attrs/range-param-unused-narrow.srctgt.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
; ERROR: Source is more defined than target

; Narrowing the range of an unused parameter makes tgt UB for 8 and 9.
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
}
14 changes: 14 additions & 0 deletions tests/alive-tv/attrs/range-param-unused.srctgt.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
; %x is unused in src, but a value outside the range is still UB there, so tgt
; may assume the range.
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
}

declare void @llvm.assume(i1)
Loading