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
6 changes: 4 additions & 2 deletions llvm_util/llvm2alive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1604,8 +1604,10 @@ class llvm2alive_ : public llvm::InstVisitor<llvm2alive_, unique_ptr<Instr>> {
Value **val, bool is_callsite) {
bool precise = true;
for (const llvm::Attribute &llvmattr : aset) {
if (!llvmattr.isEnumAttribute() && !llvmattr.isIntAttribute() &&
!llvmattr.isTypeAttribute())
// String attributes have no enum kind, so skip them. Every other kind
// must reach the switch, including the constant range ones (range and
// initializes).
if (llvmattr.isStringAttribute())
continue;

switch (llvmattr.getKindAsEnum()) {
Expand Down
12 changes: 12 additions & 0 deletions tests/alive-tv/attrs/initializes-param.srctgt.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
; The initializes attribute on a parameter must be kept, not skipped.
; CHECK: define i32 @src(ptr initializes((0, 4)) %p)
define i32 @src(ptr initializes((0, 4)) %p) {
store i32 0, ptr %p
%v = load i32, ptr %p
ret i32 %v
}

define i32 @tgt(ptr initializes((0, 4)) %p) {
store i32 0, ptr %p
ret i32 0
}
8 changes: 8 additions & 0 deletions tests/alive-tv/attrs/range-param-poison.srctgt.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
; Without noundef, a value outside the range is poison, which 1 refines.
define i8 @src(i8 range(i8 1, 2) %x) {
ret i8 %x
}

define i8 @tgt(i8 range(i8 1, 2) %x) {
ret i8 1
}
8 changes: 8 additions & 0 deletions tests/alive-tv/attrs/range-param.srctgt.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
; A range attribute on a parameter must be honored: %x can only be 1.
define i8 @src(i8 noundef range(i8 1, 2) %x) {
ret i8 %x
}

define i8 @tgt(i8 noundef range(i8 1, 2) %x) {
ret i8 1
}