@@ -5746,78 +5746,6 @@ void CGDebugInfo::EmitExternalVariable(llvm::GlobalVariable *Var,
5746
5746
Var->addDebugInfo (GVE);
5747
5747
}
5748
5748
5749
- void CGDebugInfo::EmitPseudoVariable (CGBuilderTy &Builder,
5750
- llvm::Instruction *Value, QualType Ty) {
5751
- // Only when -g2 or above is specified, debug info for variables will be
5752
- // generated.
5753
- if (CGM.getCodeGenOpts ().getDebugInfo () <=
5754
- llvm::codegenoptions::DebugLineTablesOnly)
5755
- return ;
5756
-
5757
- llvm::DebugLoc SaveDebugLoc = Builder.getCurrentDebugLocation ();
5758
- if (!SaveDebugLoc.get ())
5759
- return ;
5760
-
5761
- llvm::DIFile *Unit = SaveDebugLoc->getFile ();
5762
- llvm::DIType *Type = getOrCreateType (Ty, Unit);
5763
-
5764
- // Check if Value is already a declared variable and has debug info, in this
5765
- // case we have nothing to do. Clang emits declared variable as alloca, and
5766
- // it is loaded upon use, so we identify such pattern here.
5767
- if (llvm::LoadInst *Load = dyn_cast<llvm::LoadInst>(Value)) {
5768
- llvm::Value *Var = Load->getPointerOperand ();
5769
- // There can be implicit type cast applied on a variable if it is an opaque
5770
- // ptr, in this case its debug info may not match the actual type of object
5771
- // being used as in the next instruction, so we will need to emit a pseudo
5772
- // variable for type-casted value.
5773
- auto DeclareTypeMatches = [&](auto *DbgDeclare) {
5774
- return DbgDeclare->getVariable ()->getType () == Type;
5775
- };
5776
- if (any_of (llvm::findDbgDeclares (Var), DeclareTypeMatches) ||
5777
- any_of (llvm::findDVRDeclares (Var), DeclareTypeMatches))
5778
- return ;
5779
- }
5780
-
5781
- // Find the correct location to insert a sequence of instructions to
5782
- // materialize Value on the stack.
5783
- auto SaveInsertionPoint = Builder.saveIP ();
5784
- if (llvm::InvokeInst *Invoke = dyn_cast<llvm::InvokeInst>(Value))
5785
- Builder.SetInsertPoint (Invoke->getNormalDest ()->begin ());
5786
- else if (llvm::Instruction *Next = Value->getIterator ()->getNextNode ())
5787
- Builder.SetInsertPoint (Next);
5788
- else
5789
- Builder.SetInsertPoint (Value->getParent ());
5790
- llvm::DebugLoc DL = Value->getDebugLoc ();
5791
- if (DL.get ())
5792
- Builder.SetCurrentDebugLocation (DL);
5793
- else if (!Builder.getCurrentDebugLocation ().get ())
5794
- Builder.SetCurrentDebugLocation (SaveDebugLoc);
5795
-
5796
- llvm::AllocaInst *PseudoVar = Builder.CreateAlloca (Value->getType ());
5797
- Address PseudoVarAddr (PseudoVar, Value->getType (),
5798
- CharUnits::fromQuantity (PseudoVar->getAlign ()));
5799
- llvm::LoadInst *Load = Builder.CreateLoad (PseudoVarAddr);
5800
- Value->replaceAllUsesWith (Load);
5801
- Builder.SetInsertPoint (Load);
5802
- Builder.CreateStore (Value, PseudoVarAddr);
5803
-
5804
- // Emit debug info for materialized Value.
5805
- unsigned Line = Builder.getCurrentDebugLocation ().getLine ();
5806
- unsigned Column = Builder.getCurrentDebugLocation ().getCol ();
5807
- llvm::DILocalVariable *D = DBuilder.createAutoVariable (
5808
- LexicalBlockStack.back (), " " , nullptr , 0 , Type, false ,
5809
- llvm::DINode::FlagArtificial);
5810
- llvm::DILocation *DIL =
5811
- llvm::DILocation::get (CGM.getLLVMContext (), Line, Column,
5812
- LexicalBlockStack.back (), CurInlinedAt);
5813
- SmallVector<uint64_t > Expr;
5814
- DBuilder.insertDeclare (PseudoVar, D, DBuilder.createExpression (Expr), DIL,
5815
- Load);
5816
-
5817
- Builder.restoreIP (SaveInsertionPoint);
5818
- Builder.SetCurrentDebugLocation (SaveDebugLoc);
5819
- }
5820
-
5821
5749
void CGDebugInfo::EmitGlobalAlias (const llvm::GlobalValue *GV,
5822
5750
const GlobalDecl GD) {
5823
5751
0 commit comments