@@ -225,6 +225,10 @@ class PartitionOpTranslator {
225
225
// / ensure simplifyVal is called on SILValues before entering into this map
226
226
llvm::DenseMap<SILValue, TrackableValueState> equivalenceClassValuesToState;
227
227
228
+ #ifndef NDEBUG
229
+ llvm::DenseMap<unsigned , SILValue> stateIndexToEquivalenceClass;
230
+ #endif
231
+
228
232
// some values that AccessStorage claims are uniquely identified are still
229
233
// captured (e.g. in a closure). This set is initialized upon
230
234
// PartitionOpTranslator construction to store those values.
@@ -245,9 +249,13 @@ class PartitionOpTranslator {
245
249
246
250
// If we did not insert, just return the already stored value.
247
251
if (!iter.second ) {
248
- return {value , iter.first ->second };
252
+ return {iter. first -> first , iter.first ->second };
249
253
}
250
254
255
+ #ifndef NDEBUG
256
+ self->stateIndexToEquivalenceClass [iter.first ->second .getID ()] = value;
257
+ #endif
258
+
251
259
// Otherwise, we need to compute our true aliased and sendable values. Begi
252
260
// by seeing if we have a value that we can prove is not aliased.
253
261
if (isAddress (value)) {
@@ -930,6 +938,10 @@ class PartitionOpTranslator {
930
938
// translate each SIL instruction to a PartitionOp, if necessary
931
939
std::vector<PartitionOp> partitionOps;
932
940
int lastTranslationIndex = -1 ;
941
+ #ifndef NDEBUG
942
+ llvm::SmallVector<unsigned , 8 > opsToPrint;
943
+ #endif
944
+
933
945
for (SILInstruction &instruction : *basicBlock) {
934
946
auto ops = translateSILInstruction (&instruction);
935
947
for (PartitionOp &op : ops) {
@@ -943,10 +955,32 @@ class PartitionOpTranslator {
943
955
instruction.getLoc ().getSourceLoc ().printLineAndColumn (
944
956
llvm::dbgs (), function->getASTContext ().SourceMgr );
945
957
llvm::dbgs () << " │ translation #" << translationIndex;
946
- llvm::dbgs () << " \n └─────╼ " ;
947
- } else { llvm::dbgs () << " └╼ " ; } op.print (llvm::dbgs ());
948
- lastTranslationIndex = translationIndex;);
958
+ llvm::dbgs () << " \n ├─────╼ " ;
959
+ } else {
960
+ llvm::dbgs () << " │ └╼ " ;
961
+ }
962
+ op.print (llvm::dbgs ());
963
+ lastTranslationIndex = translationIndex;
964
+ );
949
965
}
966
+ LLVM_DEBUG (
967
+ if (ops.size ()) {
968
+ llvm::dbgs () << " └─────╼ Used Values\n " ;
969
+ SWIFT_DEFER { opsToPrint.clear (); };
970
+ for (PartitionOp &op : ops) {
971
+ // Now dump our the root value we map.
972
+ for (unsigned opArg : op.getOpArgs ()) {
973
+ // If we didn't insert, skip this. We only emit this once.
974
+ opsToPrint.push_back (opArg);
975
+ }
976
+ }
977
+ sortUnique (opsToPrint);
978
+ for (unsigned opArg : opsToPrint) {
979
+ llvm::dbgs () << " └╼ " ;
980
+ llvm::dbgs () << " %%" << opArg << " : " << stateIndexToEquivalenceClass[opArg];
981
+ }
982
+ }
983
+ );
950
984
}
951
985
952
986
return partitionOps;
0 commit comments