@@ -1204,67 +1204,55 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
1204
1204
}
1205
1205
}
1206
1206
1207
- void checkInstructionsSILLocation (SILInstruction *I) {
1208
- // Check the debug scope.
1209
- auto *DS = I->getDebugScope ();
1210
- if (DS && !maybeScopeless (*I))
1211
- require (DS, " instruction has a location, but no scope" );
1207
+ void checkInstructionsSILLocation (SILInstruction *inst) {
1208
+ // First verify structural debug info information.
1209
+ inst->verifyDebugInfo ();
1212
1210
1213
- require (!DS || DS->getParentFunction () == I->getFunction (),
1211
+ // Check the debug scope.
1212
+ auto *debugScope = inst->getDebugScope ();
1213
+ if (debugScope && !maybeScopeless (*inst))
1214
+ require (debugScope, " instruction has a location, but no scope" );
1215
+ require (!debugScope ||
1216
+ debugScope->getParentFunction () == inst->getFunction (),
1214
1217
" debug scope of instruction belongs to a different function" );
1215
1218
1216
- // Check the location kind.
1217
- SILLocation L = I->getLoc ();
1218
- SILLocation::LocationKind LocKind = L.getKind ();
1219
- SILInstructionKind InstKind = I->getKind ();
1220
-
1221
- // Check that there is at most one debug variable defined
1222
- // for each argument slot. This catches SIL transformations
1223
- // that accidentally remove inline information (stored in the SILDebugScope)
1224
- // from debug-variable-carrying instructions.
1225
- if (!DS->InlinedCallSite ) {
1226
- Optional<SILDebugVariable> VarInfo;
1227
- if (auto *DI = dyn_cast<AllocStackInst>(I))
1228
- VarInfo = DI->getVarInfo ();
1229
- else if (auto *DI = dyn_cast<AllocBoxInst>(I))
1230
- VarInfo = DI->getVarInfo ();
1231
- else if (auto *DI = dyn_cast<DebugValueInst>(I))
1232
- VarInfo = DI->getVarInfo ();
1233
- else if (auto *DI = dyn_cast<DebugValueAddrInst>(I))
1234
- VarInfo = DI->getVarInfo ();
1235
-
1236
- if (VarInfo)
1237
- if (unsigned ArgNo = VarInfo->ArgNo ) {
1238
- // It is a function argument.
1239
- if (ArgNo < DebugVars.size () && !DebugVars[ArgNo].empty () && !VarInfo->Name .empty ()) {
1240
- require (
1241
- DebugVars[ArgNo] == VarInfo->Name ,
1219
+ // Check that there is at most one debug variable defined for each argument
1220
+ // slot if our debug scope is not an inlined call site.
1221
+ //
1222
+ // This catches SIL transformations that accidentally remove inline
1223
+ // information (stored in the SILDebugScope) from debug-variable-carrying
1224
+ // instructions.
1225
+ if (debugScope->InlinedCallSite )
1226
+ return ;
1227
+
1228
+ Optional<SILDebugVariable> varInfo;
1229
+ if (auto *di = dyn_cast<AllocStackInst>(inst))
1230
+ varInfo = di->getVarInfo ();
1231
+ else if (auto *di = dyn_cast<AllocBoxInst>(inst))
1232
+ varInfo = di->getVarInfo ();
1233
+ else if (auto *di = dyn_cast<DebugValueInst>(inst))
1234
+ varInfo = di->getVarInfo ();
1235
+ else if (auto *di = dyn_cast<DebugValueAddrInst>(inst))
1236
+ varInfo = di->getVarInfo ();
1237
+
1238
+ if (!varInfo)
1239
+ return ;
1240
+
1241
+ if (unsigned argNum = varInfo->ArgNo ) {
1242
+ // It is a function argument.
1243
+ if (argNum < DebugVars.size () && !DebugVars[argNum].empty () &&
1244
+ !varInfo->Name .empty ()) {
1245
+ require (DebugVars[argNum] == varInfo->Name ,
1242
1246
" Scope contains conflicting debug variables for one function "
1243
1247
" argument" );
1244
- } else {
1245
- // Reserve enough space.
1246
- while (DebugVars.size () <= ArgNo) {
1247
- DebugVars.push_back (StringRef ());
1248
- }
1249
- }
1250
- DebugVars[ArgNo] = VarInfo->Name ;
1248
+ } else {
1249
+ // Reserve enough space.
1250
+ while (DebugVars.size () <= argNum) {
1251
+ DebugVars.push_back (StringRef ());
1252
+ }
1251
1253
}
1254
+ DebugVars[argNum] = varInfo->Name ;
1252
1255
}
1253
-
1254
- // Regular locations are allowed on all instructions.
1255
- if (LocKind == SILLocation::RegularKind)
1256
- return ;
1257
-
1258
- if (LocKind == SILLocation::ReturnKind ||
1259
- LocKind == SILLocation::ImplicitReturnKind)
1260
- require (InstKind == SILInstructionKind::BranchInst ||
1261
- InstKind == SILInstructionKind::ReturnInst ||
1262
- InstKind == SILInstructionKind::UnreachableInst,
1263
- " return locations are only allowed on branch and return instructions" );
1264
-
1265
- if (LocKind == SILLocation::ArtificialUnreachableKind)
1266
- require (InstKind == SILInstructionKind::UnreachableInst,
1267
- " artificial locations are only allowed on Unreachable instructions" );
1268
1256
}
1269
1257
1270
1258
// / Check that the types of this value producer are all legal in the function
0 commit comments