Skip to content

Commit bfb549f

Browse files
authored
llvm-reduce: Fix operand reduction asserting on target ext types (#132732)
Not all TargetExtTypes support zeroinit, so use poison as a substitute if unavailable.
1 parent eeb4132 commit bfb549f

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=operands-zero --test FileCheck --test-arg %s --test-arg --input-file %s -o %t
2+
; RUN: FileCheck --check-prefixes=CHECK,ZERO %s < %t
3+
4+
; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=operands-one --test FileCheck --test-arg %s --test-arg --input-file %s -o %t
5+
; RUN: FileCheck --check-prefixes=CHECK,ONE %s < %t
6+
7+
declare void @uses_ext_ty(target("sometarget.sometype"))
8+
9+
; TODO: Should support reduce to poison
10+
; CHECK-LABEL: @foo(
11+
; ZERO: call void @uses_ext_ty(target("sometarget.sometype") %arg)
12+
; ONE: call void @uses_ext_ty(target("sometarget.sometype") %arg)
13+
define void @foo(target("sometarget.sometype") %arg) {
14+
call void @uses_ext_ty(target("sometarget.sometype") %arg)
15+
ret void
16+
}
17+
18+
declare void @uses_zeroinit_ext_ty(target("sometarget.sometype"))
19+
20+
; CHECK-LABEL: @bar(
21+
; ZERO: call void @uses_zeroinit_ext_ty(target("spirv.sometype") zeroinitializer)
22+
; ONE: call void @uses_zeroinit_ext_ty(target("spirv.sometype") %arg)
23+
define void @bar(target("spirv.sometype") %arg) {
24+
call void @uses_zeroinit_ext_ty(target("spirv.sometype") %arg)
25+
ret void
26+
}

llvm/tools/llvm-reduce/deltas/ReduceOperands.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,17 @@ void llvm::reduceOperandsZeroDeltaPass(TestRunner &Test) {
134134
if (auto *IntTy = dyn_cast<IntegerType>(Op->getType()))
135135
if (switchCaseExists(Op, ConstantInt::get(IntTy, 0)))
136136
return nullptr;
137+
138+
if (auto *TET = dyn_cast<TargetExtType>(Op->getType())) {
139+
if (isa<ConstantTargetNone, PoisonValue>(Op))
140+
return nullptr;
141+
if (TET->hasProperty(TargetExtType::HasZeroInit))
142+
return ConstantTargetNone::get(TET);
143+
144+
// TODO: Poison reduction for this case
145+
return nullptr;
146+
}
147+
137148
// Don't replace existing zeroes.
138149
return isZero(Op) ? nullptr : Constant::getNullValue(Op->getType());
139150
};

0 commit comments

Comments
 (0)