Skip to content

Commit d76a8e6

Browse files
committed
[NFC] SIL: Typed destroy_value.poisonRefs.
Type the existing flag before adding another flag.
1 parent 0350023 commit d76a8e6

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

include/swift/SIL/SILBuilder.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,8 +1442,9 @@ class SILBuilder {
14421442
ExplicitCopyValueInst(getSILDebugLocation(Loc), operand));
14431443
}
14441444

1445-
DestroyValueInst *createDestroyValue(SILLocation Loc, SILValue operand,
1446-
bool poisonRefs = false) {
1445+
DestroyValueInst *
1446+
createDestroyValue(SILLocation Loc, SILValue operand,
1447+
PoisonRefs_t poisonRefs = DontPoisonRefs) {
14471448
assert(getFunction().hasOwnership());
14481449
assert(isLoadableOrOpaque(operand->getType()));
14491450
assert(!operand->getType().isTrivial(getFunction()) &&

include/swift/SIL/SILInstruction.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5381,6 +5381,11 @@ class DebugStepInst final
53815381
MutableArrayRef<Operand> getAllOperands() { return {}; }
53825382
};
53835383

5384+
enum PoisonRefs_t : bool {
5385+
DontPoisonRefs = false,
5386+
PoisonRefs = true,
5387+
};
5388+
53845389
/// Define the start or update to a symbolic variable value (for loadable
53855390
/// types).
53865391
class DebugValueInst final
@@ -8805,7 +8810,8 @@ class DestroyValueInst
88058810
friend class SILBuilder;
88068811
USE_SHARED_UINT8;
88078812

8808-
DestroyValueInst(SILDebugLocation DebugLoc, SILValue operand, bool poisonRefs)
8813+
DestroyValueInst(SILDebugLocation DebugLoc, SILValue operand,
8814+
PoisonRefs_t poisonRefs)
88098815
: UnaryInstructionBase(DebugLoc, operand) {
88108816
setPoisonRefs(poisonRefs);
88118817
}
@@ -8824,12 +8830,14 @@ class DestroyValueInst
88248830
/// transformations keep the poison operation associated with the destroy
88258831
/// point. After OSSA, these are lowered to 'debug_values [poison]'
88268832
/// instructions, after which the Onone pipeline should avoid code motion.
8827-
bool poisonRefs() const { return sharedUInt8().DestroyValueInst.poisonRefs; }
8833+
PoisonRefs_t poisonRefs() const {
8834+
return PoisonRefs_t(sharedUInt8().DestroyValueInst.poisonRefs);
8835+
}
88288836

8829-
void setPoisonRefs(bool poisonRefs = true) {
8837+
void setPoisonRefs(PoisonRefs_t poisonRefs = PoisonRefs) {
88308838
sharedUInt8().DestroyValueInst.poisonRefs = poisonRefs;
88318839
}
8832-
8840+
88338841
/// If the value being destroyed is a stack allocation of a nonescaping
88348842
/// closure, then return the PartialApplyInst that allocated the closure.
88358843
PartialApplyInst *getNonescapingClosureAllocation() const;

lib/SIL/Parser/ParseSIL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3356,7 +3356,7 @@ bool SILParser::parseSpecificSILInstruction(SILBuilder &B,
33563356
if (parseSILOptional(poisonRefs, *this, "poison")
33573357
|| parseTypedValueRef(Val, B) || parseSILDebugLocation(InstLoc, B))
33583358
return true;
3359-
ResultVal = B.createDestroyValue(InstLoc, Val, poisonRefs);
3359+
ResultVal = B.createDestroyValue(InstLoc, Val, PoisonRefs_t(poisonRefs));
33603360
break;
33613361
}
33623362
case SILInstructionKind::BeginCOWMutationInst: {

lib/Serialization/DeserializeSIL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2322,13 +2322,13 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn,
23222322
}
23232323
case SILInstructionKind::DestroyValueInst: {
23242324
assert(RecordKind == SIL_ONE_OPERAND && "Layout should be OneOperand.");
2325-
unsigned poisonRefs = Attr;
2325+
PoisonRefs_t poisonRefs = PoisonRefs_t(Attr & 0x1);
23262326
ResultInst = Builder.createDestroyValue(
23272327
Loc,
23282328
getLocalValue(
23292329
Builder.maybeGetFunction(), ValID,
23302330
getSILType(MF->getType(TyID), (SILValueCategory)TyCategory, Fn)),
2331-
poisonRefs != 0);
2331+
poisonRefs);
23322332
break;
23332333
}
23342334

0 commit comments

Comments
 (0)