mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #15501 from atrick/add-access-tracking-flag
[exclusivity] Add an access tracking flag.
This commit is contained in:
@@ -13,15 +13,16 @@
|
||||
#define DEBUG_TYPE "sil-serialize"
|
||||
#include "SILFormat.h"
|
||||
#include "Serialization.h"
|
||||
#include "swift/Strings.h"
|
||||
#include "swift/AST/Module.h"
|
||||
#include "swift/AST/GenericSignature.h"
|
||||
#include "swift/AST/Module.h"
|
||||
#include "swift/AST/ProtocolConformance.h"
|
||||
#include "swift/SIL/CFG.h"
|
||||
#include "swift/SIL/PrettyStackTrace.h"
|
||||
#include "swift/SIL/SILArgument.h"
|
||||
#include "swift/SIL/SILModule.h"
|
||||
#include "swift/SIL/SILUndef.h"
|
||||
#include "swift/SILOptimizer/Utils/Generics.h"
|
||||
#include "swift/Strings.h"
|
||||
|
||||
#include "llvm/ADT/MapVector.h"
|
||||
#include "llvm/ADT/PostOrderIterator.h"
|
||||
@@ -264,6 +265,8 @@ namespace {
|
||||
void writeOneOperandLayout(SILInstructionKind valueKind,
|
||||
unsigned attrs,
|
||||
SILValue operand);
|
||||
void writeOneOperandExtraAttributeLayout(SILInstructionKind valueKind,
|
||||
unsigned attrs, SILValue operand);
|
||||
|
||||
void writeKeyPathPatternComponent(
|
||||
const KeyPathPatternComponent &component,
|
||||
@@ -362,6 +365,8 @@ ValueID SILSerializer::addValueRef(const ValueBase *Val) {
|
||||
}
|
||||
|
||||
void SILSerializer::writeSILFunction(const SILFunction &F, bool DeclOnly) {
|
||||
PrettyStackTraceSILFunction stackTrace("Serializing", &F);
|
||||
|
||||
ValueIDs.clear();
|
||||
InstID = 0;
|
||||
|
||||
@@ -545,6 +550,21 @@ void SILSerializer::writeOneOperandLayout(SILInstructionKind valueKind,
|
||||
operandRef);
|
||||
}
|
||||
|
||||
void SILSerializer::
|
||||
writeOneOperandExtraAttributeLayout(SILInstructionKind valueKind,
|
||||
unsigned attrs,
|
||||
SILValue operand) {
|
||||
|
||||
auto operandType = operand->getType();
|
||||
auto operandTypeRef = S.addTypeRef(operandType.getSwiftRValueType());
|
||||
auto operandRef = addValueRef(operand);
|
||||
|
||||
SILOneOperandExtraAttributeLayout::emitRecord(
|
||||
Out, ScratchRecord, SILAbbrCodes[SILOneOperandExtraAttributeLayout::Code],
|
||||
unsigned(valueKind), attrs, operandTypeRef,
|
||||
unsigned(operandType.getCategory()), operandRef);
|
||||
}
|
||||
|
||||
void SILSerializer::writeOneTypeOneOperandLayout(SILInstructionKind valueKind,
|
||||
unsigned attrs,
|
||||
SILType type,
|
||||
@@ -677,6 +697,8 @@ SILSerializer::writeKeyPathPatternComponent(
|
||||
}
|
||||
|
||||
void SILSerializer::writeSILInstruction(const SILInstruction &SI) {
|
||||
PrettyStackTraceSILNode stackTrace("Serializing", &SI);
|
||||
|
||||
switch (SI.getKind()) {
|
||||
case SILInstructionKind::ObjectInst:
|
||||
llvm_unreachable("static initializers of sil_global are not serialized");
|
||||
@@ -1216,7 +1238,6 @@ void SILSerializer::writeSILInstruction(const SILInstruction &SI) {
|
||||
case SILInstructionKind::BeginBorrowInst:
|
||||
case SILInstructionKind::LoadUnownedInst:
|
||||
case SILInstructionKind::LoadWeakInst:
|
||||
case SILInstructionKind::MarkUninitializedInst:
|
||||
case SILInstructionKind::ClassifyBridgeObjectInst:
|
||||
case SILInstructionKind::ValueToBridgeObjectInst:
|
||||
case SILInstructionKind::FixLifetimeInst:
|
||||
@@ -1244,8 +1265,6 @@ void SILSerializer::writeSILInstruction(const SILInstruction &SI) {
|
||||
Attr = LWI->isTake();
|
||||
else if (auto *LUI = dyn_cast<LoadUnownedInst>(&SI))
|
||||
Attr = LUI->isTake();
|
||||
else if (auto *MUI = dyn_cast<MarkUninitializedInst>(&SI))
|
||||
Attr = (unsigned)MUI->getKind();
|
||||
else if (auto *DRI = dyn_cast<DeallocRefInst>(&SI))
|
||||
Attr = (unsigned)DRI->canAllocOnStack();
|
||||
else if (auto *RCI = dyn_cast<RefCountingInst>(&SI))
|
||||
@@ -1258,6 +1277,11 @@ void SILSerializer::writeSILInstruction(const SILInstruction &SI) {
|
||||
writeOneOperandLayout(SI.getKind(), Attr, SI.getOperand(0));
|
||||
break;
|
||||
}
|
||||
case SILInstructionKind::MarkUninitializedInst: {
|
||||
unsigned Attr = (unsigned)cast<MarkUninitializedInst>(&SI)->getKind();
|
||||
writeOneOperandExtraAttributeLayout(SI.getKind(), Attr, SI.getOperand(0));
|
||||
break;
|
||||
}
|
||||
case SILInstructionKind::YieldInst: {
|
||||
auto YI = cast<YieldInst>(&SI);
|
||||
SmallVector<ValueID, 4> args;
|
||||
@@ -1557,14 +1581,14 @@ void SILSerializer::writeSILInstruction(const SILInstruction &SI) {
|
||||
}
|
||||
|
||||
case SILInstructionKind::BeginAccessInst: {
|
||||
unsigned abbrCode = SILAbbrCodes[SILOneOperandLayout::Code];
|
||||
unsigned abbrCode = SILAbbrCodes[SILOneOperandExtraAttributeLayout::Code];
|
||||
auto *BAI = cast<BeginAccessInst>(&SI);
|
||||
unsigned attr =
|
||||
unsigned(BAI->getAccessKind())
|
||||
+ (unsigned(BAI->getEnforcement()) << 2);
|
||||
unsigned attr = unsigned(BAI->getAccessKind())
|
||||
+ (unsigned(BAI->getEnforcement()) << 2)
|
||||
+ (BAI->hasNoNestedConflict() << 4);
|
||||
SILValue operand = BAI->getOperand();
|
||||
|
||||
SILOneOperandLayout::emitRecord(
|
||||
SILOneOperandExtraAttributeLayout::emitRecord(
|
||||
Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), attr,
|
||||
S.addTypeRef(operand->getType().getSwiftRValueType()),
|
||||
(unsigned)operand->getType().getCategory(),
|
||||
@@ -1587,15 +1611,15 @@ void SILSerializer::writeSILInstruction(const SILInstruction &SI) {
|
||||
}
|
||||
|
||||
case SILInstructionKind::BeginUnpairedAccessInst: {
|
||||
unsigned abbrCode = SILAbbrCodes[SILTwoOperandsLayout::Code];
|
||||
unsigned abbrCode = SILAbbrCodes[SILTwoOperandsExtraAttributeLayout::Code];
|
||||
auto *BAI = cast<BeginUnpairedAccessInst>(&SI);
|
||||
unsigned attr =
|
||||
unsigned(BAI->getAccessKind())
|
||||
+ (unsigned(BAI->getEnforcement()) << 2);
|
||||
unsigned attr = unsigned(BAI->getAccessKind())
|
||||
+ (unsigned(BAI->getEnforcement()) << 2)
|
||||
+ (unsigned(BAI->hasNoNestedConflict()) << 4);
|
||||
SILValue source = BAI->getSource();
|
||||
SILValue buffer = BAI->getBuffer();
|
||||
|
||||
SILTwoOperandsLayout::emitRecord(
|
||||
SILTwoOperandsExtraAttributeLayout::emitRecord(
|
||||
Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), attr,
|
||||
S.addTypeRef(source->getType().getSwiftRValueType()),
|
||||
(unsigned)source->getType().getCategory(),
|
||||
@@ -1607,13 +1631,13 @@ void SILSerializer::writeSILInstruction(const SILInstruction &SI) {
|
||||
}
|
||||
|
||||
case SILInstructionKind::EndUnpairedAccessInst: {
|
||||
unsigned abbrCode = SILAbbrCodes[SILOneOperandLayout::Code];
|
||||
unsigned abbrCode = SILAbbrCodes[SILOneOperandExtraAttributeLayout::Code];
|
||||
auto *EAI = cast<EndUnpairedAccessInst>(&SI);
|
||||
unsigned attr = unsigned(EAI->isAborting())
|
||||
+ (unsigned(EAI->getEnforcement()) << 1);
|
||||
SILValue operand = EAI->getOperand();
|
||||
|
||||
SILOneOperandLayout::emitRecord(
|
||||
SILOneOperandExtraAttributeLayout::emitRecord(
|
||||
Out, ScratchRecord, abbrCode, (unsigned)SI.getKind(), attr,
|
||||
S.addTypeRef(operand->getType().getSwiftRValueType()),
|
||||
(unsigned)operand->getType().getCategory(),
|
||||
@@ -2374,13 +2398,17 @@ void SILSerializer::writeSILBlock(const SILModule *SILMod) {
|
||||
registerSILAbbr<SILOneValueOneOperandLayout>();
|
||||
registerSILAbbr<SILOneTypeLayout>();
|
||||
registerSILAbbr<SILOneOperandLayout>();
|
||||
registerSILAbbr<SILOneOperandExtraAttributeLayout>();
|
||||
registerSILAbbr<SILOneTypeOneOperandLayout>();
|
||||
registerSILAbbr<SILInitExistentialLayout>();
|
||||
registerSILAbbr<SILOneTypeValuesLayout>();
|
||||
registerSILAbbr<SILTwoOperandsLayout>();
|
||||
registerSILAbbr<SILTwoOperandsExtraAttributeLayout>();
|
||||
registerSILAbbr<SILTailAddrLayout>();
|
||||
registerSILAbbr<SILInstApplyLayout>();
|
||||
registerSILAbbr<SILInstNoOperandLayout>();
|
||||
registerSILAbbr<SILOneOperandLayout>();
|
||||
registerSILAbbr<SILTwoOperandsLayout>();
|
||||
|
||||
registerSILAbbr<VTableLayout>();
|
||||
registerSILAbbr<VTableEntryLayout>();
|
||||
|
||||
Reference in New Issue
Block a user