@@ -597,7 +597,6 @@ class Verifier : public InstVisitor<Verifier>, VerifierSupport {
597
597
void visitIntrinsicCall (Intrinsic::ID ID, CallBase &Call);
598
598
void visitConstrainedFPIntrinsic (ConstrainedFPIntrinsic &FPI);
599
599
void visitVPIntrinsic (VPIntrinsic &VPI);
600
- void visitDbgIntrinsic (StringRef Kind, DbgVariableIntrinsic &DII);
601
600
void visitDbgLabelIntrinsic (StringRef Kind, DbgLabelInst &DLI);
602
601
void visitAtomicCmpXchgInst (AtomicCmpXchgInst &CXI);
603
602
void visitAtomicRMWInst (AtomicRMWInst &RMWI);
@@ -636,15 +635,12 @@ class Verifier : public InstVisitor<Verifier>, VerifierSupport {
636
635
void verifyFrameRecoverIndices ();
637
636
void verifySiblingFuncletUnwinds ();
638
637
639
- void verifyFragmentExpression (const DbgVariableIntrinsic &I);
640
638
void verifyFragmentExpression (const DbgVariableRecord &I);
641
639
template <typename ValueOrMetadata>
642
640
void verifyFragmentExpression (const DIVariable &V,
643
641
DIExpression::FragmentInfo Fragment,
644
642
ValueOrMetadata *Desc);
645
- void verifyFnArgs (const DbgVariableIntrinsic &I);
646
643
void verifyFnArgs (const DbgVariableRecord &DVR);
647
- void verifyNotEntryValue (const DbgVariableIntrinsic &I);
648
644
void verifyNotEntryValue (const DbgVariableRecord &I);
649
645
650
646
// / Module-level debug info verification...
@@ -5497,11 +5493,6 @@ void Verifier::visitInstruction(Instruction &I) {
5497
5493
}
5498
5494
}
5499
5495
5500
- if (auto *DII = dyn_cast<DbgVariableIntrinsic>(&I)) {
5501
- verifyFragmentExpression (*DII);
5502
- verifyNotEntryValue (*DII);
5503
- }
5504
-
5505
5496
SmallVector<std::pair<unsigned , MDNode *>, 4 > MDs;
5506
5497
I.getAllMetadata (MDs);
5507
5498
for (auto Attachment : MDs) {
@@ -5706,18 +5697,14 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
5706
5697
visitConstrainedFPIntrinsic (cast<ConstrainedFPIntrinsic>(Call));
5707
5698
break ;
5708
5699
case Intrinsic::dbg_declare: // llvm.dbg.declare
5709
- Check (isa<MetadataAsValue>(Call.getArgOperand (0 )),
5710
- " invalid llvm.dbg.declare intrinsic call 1" , Call);
5711
- visitDbgIntrinsic (" declare" , cast<DbgVariableIntrinsic>(Call));
5712
- break ;
5713
- case Intrinsic::dbg_value: // llvm.dbg.value
5714
- visitDbgIntrinsic (" value" , cast<DbgVariableIntrinsic>(Call));
5715
- break ;
5716
- case Intrinsic::dbg_assign: // llvm.dbg.assign
5717
- visitDbgIntrinsic (" assign" , cast<DbgVariableIntrinsic>(Call));
5718
- break ;
5719
- case Intrinsic::dbg_label: // llvm.dbg.label
5720
- visitDbgLabelIntrinsic (" label" , cast<DbgLabelInst>(Call));
5700
+ case Intrinsic::dbg_value: // llvm.dbg.value
5701
+ case Intrinsic::dbg_assign: // llvm.dbg.assign
5702
+ case Intrinsic::dbg_label: // llvm.dbg.label
5703
+ // We no longer interpret debug intrinsics (the old variable-location
5704
+ // design). They're meaningless as far as LLVM is concerned we could make
5705
+ // it an error for them to appear, but it's possible we'll have users
5706
+ // converting back to intrinsics for the forseeable future (such as DXIL),
5707
+ // so tolerate their existance.
5721
5708
break ;
5722
5709
case Intrinsic::memcpy:
5723
5710
case Intrinsic::memcpy_inline:
@@ -7126,123 +7113,6 @@ void Verifier::visitConstrainedFPIntrinsic(ConstrainedFPIntrinsic &FPI) {
7126
7113
}
7127
7114
}
7128
7115
7129
- void Verifier::visitDbgIntrinsic (StringRef Kind, DbgVariableIntrinsic &DII) {
7130
- auto *MD = DII.getRawLocation ();
7131
- CheckDI (isa<ValueAsMetadata>(MD) || isa<DIArgList>(MD) ||
7132
- (isa<MDNode>(MD) && !cast<MDNode>(MD)->getNumOperands ()),
7133
- " invalid llvm.dbg." + Kind + " intrinsic address/value" , &DII, MD);
7134
- CheckDI (isa<DILocalVariable>(DII.getRawVariable ()),
7135
- " invalid llvm.dbg." + Kind + " intrinsic variable" , &DII,
7136
- DII.getRawVariable ());
7137
- CheckDI (isa<DIExpression>(DII.getRawExpression ()),
7138
- " invalid llvm.dbg." + Kind + " intrinsic expression" , &DII,
7139
- DII.getRawExpression ());
7140
-
7141
- if (auto *DAI = dyn_cast<DbgAssignIntrinsic>(&DII)) {
7142
- CheckDI (isa<DIAssignID>(DAI->getRawAssignID ()),
7143
- " invalid llvm.dbg.assign intrinsic DIAssignID" , &DII,
7144
- DAI->getRawAssignID ());
7145
- const auto *RawAddr = DAI->getRawAddress ();
7146
- CheckDI (
7147
- isa<ValueAsMetadata>(RawAddr) ||
7148
- (isa<MDNode>(RawAddr) && !cast<MDNode>(RawAddr)->getNumOperands ()),
7149
- " invalid llvm.dbg.assign intrinsic address" , &DII,
7150
- DAI->getRawAddress ());
7151
- CheckDI (isa<DIExpression>(DAI->getRawAddressExpression ()),
7152
- " invalid llvm.dbg.assign intrinsic address expression" , &DII,
7153
- DAI->getRawAddressExpression ());
7154
- // All of the linked instructions should be in the same function as DII.
7155
- for (Instruction *I : at::getAssignmentInsts (DAI))
7156
- CheckDI (DAI->getFunction () == I->getFunction (),
7157
- " inst not in same function as dbg.assign" , I, DAI);
7158
- }
7159
-
7160
- // Ignore broken !dbg attachments; they're checked elsewhere.
7161
- if (MDNode *N = DII.getDebugLoc ().getAsMDNode ())
7162
- if (!isa<DILocation>(N))
7163
- return ;
7164
-
7165
- BasicBlock *BB = DII.getParent ();
7166
- Function *F = BB ? BB->getParent () : nullptr ;
7167
-
7168
- // The scopes for variables and !dbg attachments must agree.
7169
- DILocalVariable *Var = DII.getVariable ();
7170
- DILocation *Loc = DII.getDebugLoc ();
7171
- CheckDI (Loc, " llvm.dbg." + Kind + " intrinsic requires a !dbg attachment" ,
7172
- &DII, BB, F);
7173
-
7174
- DISubprogram *VarSP = getSubprogram (Var->getRawScope ());
7175
- DISubprogram *LocSP = getSubprogram (Loc->getRawScope ());
7176
- if (!VarSP || !LocSP)
7177
- return ; // Broken scope chains are checked elsewhere.
7178
-
7179
- CheckDI (VarSP == LocSP,
7180
- " mismatched subprogram between llvm.dbg." + Kind +
7181
- " variable and !dbg attachment" ,
7182
- &DII, BB, F, Var, Var->getScope ()->getSubprogram (), Loc,
7183
- Loc->getScope ()->getSubprogram ());
7184
-
7185
- // This check is redundant with one in visitLocalVariable().
7186
- CheckDI (isType (Var->getRawType ()), " invalid type ref" , Var,
7187
- Var->getRawType ());
7188
- verifyFnArgs (DII);
7189
- }
7190
-
7191
- void Verifier::visitDbgLabelIntrinsic (StringRef Kind, DbgLabelInst &DLI) {
7192
- CheckDI (isa<DILabel>(DLI.getRawLabel ()),
7193
- " invalid llvm.dbg." + Kind + " intrinsic variable" , &DLI,
7194
- DLI.getRawLabel ());
7195
-
7196
- // Ignore broken !dbg attachments; they're checked elsewhere.
7197
- if (MDNode *N = DLI.getDebugLoc ().getAsMDNode ())
7198
- if (!isa<DILocation>(N))
7199
- return ;
7200
-
7201
- BasicBlock *BB = DLI.getParent ();
7202
- Function *F = BB ? BB->getParent () : nullptr ;
7203
-
7204
- // The scopes for variables and !dbg attachments must agree.
7205
- DILabel *Label = DLI.getLabel ();
7206
- DILocation *Loc = DLI.getDebugLoc ();
7207
- Check (Loc, " llvm.dbg." + Kind + " intrinsic requires a !dbg attachment" , &DLI,
7208
- BB, F);
7209
-
7210
- DISubprogram *LabelSP = getSubprogram (Label->getRawScope ());
7211
- DISubprogram *LocSP = getSubprogram (Loc->getRawScope ());
7212
- if (!LabelSP || !LocSP)
7213
- return ;
7214
-
7215
- CheckDI (LabelSP == LocSP,
7216
- " mismatched subprogram between llvm.dbg." + Kind +
7217
- " label and !dbg attachment" ,
7218
- &DLI, BB, F, Label, Label->getScope ()->getSubprogram (), Loc,
7219
- Loc->getScope ()->getSubprogram ());
7220
- }
7221
-
7222
- void Verifier::verifyFragmentExpression (const DbgVariableIntrinsic &I) {
7223
- DILocalVariable *V = dyn_cast_or_null<DILocalVariable>(I.getRawVariable ());
7224
- DIExpression *E = dyn_cast_or_null<DIExpression>(I.getRawExpression ());
7225
-
7226
- // We don't know whether this intrinsic verified correctly.
7227
- if (!V || !E || !E->isValid ())
7228
- return ;
7229
-
7230
- // Nothing to do if this isn't a DW_OP_LLVM_fragment expression.
7231
- auto Fragment = E->getFragmentInfo ();
7232
- if (!Fragment)
7233
- return ;
7234
-
7235
- // The frontend helps out GDB by emitting the members of local anonymous
7236
- // unions as artificial local variables with shared storage. When SROA splits
7237
- // the storage for artificial local variables that are smaller than the entire
7238
- // union, the overhang piece will be outside of the allotted space for the
7239
- // variable and this check fails.
7240
- // FIXME: Remove this check as soon as clang stops doing this; it hides bugs.
7241
- if (V->isArtificial ())
7242
- return ;
7243
-
7244
- verifyFragmentExpression (*V, *Fragment, &I);
7245
- }
7246
7116
void Verifier::verifyFragmentExpression (const DbgVariableRecord &DVR) {
7247
7117
DILocalVariable *V = dyn_cast_or_null<DILocalVariable>(DVR.getRawVariable ());
7248
7118
DIExpression *E = dyn_cast_or_null<DIExpression>(DVR.getRawExpression ());
@@ -7285,34 +7155,6 @@ void Verifier::verifyFragmentExpression(const DIVariable &V,
7285
7155
CheckDI (FragSize != *VarSize, " fragment covers entire variable" , Desc, &V);
7286
7156
}
7287
7157
7288
- void Verifier::verifyFnArgs (const DbgVariableIntrinsic &I) {
7289
- // This function does not take the scope of noninlined function arguments into
7290
- // account. Don't run it if current function is nodebug, because it may
7291
- // contain inlined debug intrinsics.
7292
- if (!HasDebugInfo)
7293
- return ;
7294
-
7295
- // For performance reasons only check non-inlined ones.
7296
- if (I.getDebugLoc ()->getInlinedAt ())
7297
- return ;
7298
-
7299
- DILocalVariable *Var = I.getVariable ();
7300
- CheckDI (Var, " dbg intrinsic without variable" );
7301
-
7302
- unsigned ArgNo = Var->getArg ();
7303
- if (!ArgNo)
7304
- return ;
7305
-
7306
- // Verify there are no duplicate function argument debug info entries.
7307
- // These will cause hard-to-debug assertions in the DWARF backend.
7308
- if (DebugFnArgs.size () < ArgNo)
7309
- DebugFnArgs.resize (ArgNo, nullptr );
7310
-
7311
- auto *Prev = DebugFnArgs[ArgNo - 1 ];
7312
- DebugFnArgs[ArgNo - 1 ] = Var;
7313
- CheckDI (!Prev || (Prev == Var), " conflicting debug info for argument" , &I,
7314
- Prev, Var);
7315
- }
7316
7158
void Verifier::verifyFnArgs (const DbgVariableRecord &DVR) {
7317
7159
// This function does not take the scope of noninlined function arguments into
7318
7160
// account. Don't run it if current function is nodebug, because it may
@@ -7342,29 +7184,6 @@ void Verifier::verifyFnArgs(const DbgVariableRecord &DVR) {
7342
7184
Prev, Var);
7343
7185
}
7344
7186
7345
- void Verifier::verifyNotEntryValue (const DbgVariableIntrinsic &I) {
7346
- DIExpression *E = dyn_cast_or_null<DIExpression>(I.getRawExpression ());
7347
-
7348
- // We don't know whether this intrinsic verified correctly.
7349
- if (!E || !E->isValid ())
7350
- return ;
7351
-
7352
- if (isa<ValueAsMetadata>(I.getRawLocation ())) {
7353
- Value *VarValue = I.getVariableLocationOp (0 );
7354
- if (isa<UndefValue>(VarValue) || isa<PoisonValue>(VarValue))
7355
- return ;
7356
- // We allow EntryValues for swift async arguments, as they have an
7357
- // ABI-guarantee to be turned into a specific register.
7358
- if (auto *ArgLoc = dyn_cast_or_null<Argument>(VarValue);
7359
- ArgLoc && ArgLoc->hasAttribute (Attribute::SwiftAsync))
7360
- return ;
7361
- }
7362
-
7363
- CheckDI (!E->isEntryValue (),
7364
- " Entry values are only allowed in MIR unless they target a "
7365
- " swiftasync Argument" ,
7366
- &I);
7367
- }
7368
7187
void Verifier::verifyNotEntryValue (const DbgVariableRecord &DVR) {
7369
7188
DIExpression *E = dyn_cast_or_null<DIExpression>(DVR.getRawExpression ());
7370
7189
0 commit comments