@@ -281,6 +281,9 @@ class Verifier : public InstVisitor<Verifier>, VerifierSupport {
281
281
// / Whether the current function has a DISubprogram attached to it.
282
282
bool HasDebugInfo = false ;
283
283
284
+ // / Whether source was present on the first DIFile encountered in each CU.
285
+ DenseMap<const DICompileUnit *, bool > HasSourceDebugInfo;
286
+
284
287
// / Stores the count of how many objects were passed to llvm.localescape for a
285
288
// / given function and the largest index passed to llvm.localrecover.
286
289
DenseMap<Function *, std::pair<unsigned , unsigned >> FrameEscapeInfo;
@@ -519,6 +522,9 @@ class Verifier : public InstVisitor<Verifier>, VerifierSupport {
519
522
// / Module-level verification that all @llvm.experimental.deoptimize
520
523
// / declarations share the same calling convention.
521
524
void verifyDeoptimizeCallingConvs ();
525
+
526
+ // / Verify all-or-nothing property of DIFile source attribute within a CU.
527
+ void verifySourceDebugInfo (const DICompileUnit &U, const DIFile &F);
522
528
};
523
529
524
530
} // end anonymous namespace
@@ -1032,6 +1038,8 @@ void Verifier::visitDICompileUnit(const DICompileUnit &N) {
1032
1038
AssertDI (!N.getFile ()->getFilename ().empty (), " invalid filename" , &N,
1033
1039
N.getFile ());
1034
1040
1041
+ verifySourceDebugInfo (N, *N.getFile ());
1042
+
1035
1043
AssertDI ((N.getEmissionKind () <= DICompileUnit::LastEmissionKind),
1036
1044
" invalid emission kind" , &N);
1037
1045
@@ -1109,6 +1117,8 @@ void Verifier::visitDISubprogram(const DISubprogram &N) {
1109
1117
AssertDI (N.isDistinct (), " subprogram definitions must be distinct" , &N);
1110
1118
AssertDI (Unit, " subprogram definitions must have a compile unit" , &N);
1111
1119
AssertDI (isa<DICompileUnit>(Unit), " invalid unit type" , &N, Unit);
1120
+ if (N.getFile ())
1121
+ verifySourceDebugInfo (*N.getUnit (), *N.getFile ());
1112
1122
} else {
1113
1123
// Subprogram declarations (part of the type hierarchy).
1114
1124
AssertDI (!Unit, " subprogram declarations must not have a compile unit" , &N);
@@ -4744,6 +4754,14 @@ void Verifier::verifyDeoptimizeCallingConvs() {
4744
4754
}
4745
4755
}
4746
4756
4757
+ void Verifier::verifySourceDebugInfo (const DICompileUnit &U, const DIFile &F) {
4758
+ bool HasSource = F.getSource ().hasValue ();
4759
+ if (!HasSourceDebugInfo.count (&U))
4760
+ HasSourceDebugInfo[&U] = HasSource;
4761
+ AssertDI (HasSource == HasSourceDebugInfo[&U],
4762
+ " inconsistent use of embedded source" );
4763
+ }
4764
+
4747
4765
// ===----------------------------------------------------------------------===//
4748
4766
// Implement the public interfaces to this file...
4749
4767
// ===----------------------------------------------------------------------===//
0 commit comments