llvm.org GIT mirror llvm / 10c4265
Revert r218778 while investigating buldbot breakage. "Move the complex address expression out of DIVariable and into an extra" git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218782 91177308-0d34-0410-b5e6-96231b3b80d8 Adrian Prantl 5 years ago
257 changed file(s) with 1387 addition(s) and 1539 deletion(s). Raw diff Collapse all Expand all
570570 metadata, ;; Reference to the type descriptor
571571 i32, ;; flags
572572 metadata ;; (optional) Reference to inline location
573 metadata ;; (optional) Reference to a complex expression.
573 metadata ;; (optional) Reference to a complex expression (see below)
574574 }
575575
576576 These descriptors are used to define variables local to a sub program. The
589589 Name the source variable name. Context and line indicate where the variable
590590 was defined. Type descriptor defines the declared type of the variable.
591591
592 Complex Expressions
593 ^^^^^^^^^^^^^^^^^^^
594 .. code-block:: llvm
595
596 !8 = metadata !{
597 i32, ;; DW_TAG_expression
598 ...
599 }
600
601 Complex expressions describe variable storage locations in terms of
602 prefix-notated DWARF expressions. Currently the only supported
603 operators are ``DW_OP_plus``, ``DW_OP_deref``, and ``DW_OP_piece``.
604
605 The ``DW_OP_piece`` operator is used for (typically larger aggregate)
592 The ``OpPiece`` operator is used for (typically larger aggregate)
606593 variables that are fragmented across several locations. It takes two
607594 i32 arguments, an offset and a size in bytes to describe which piece
608595 of the variable is at this location.
243243 ///
244244 DebugLoc getDebugLoc() const { return debugLoc; }
245245
246 /// \brief Return the debug variable referenced by
246 /// getDebugVariable() - Return the debug variable referenced by
247247 /// this DBG_VALUE instruction.
248248 DIVariable getDebugVariable() const {
249249 assert(isDebugValue() && "not a DBG_VALUE");
250 DIVariable Var(getOperand(2).getMetadata());
251 assert(Var.Verify() && "not a DIVariable");
252 return Var;
253 }
254
255 /// \brief Return the complex address expression referenced by
256 /// this DBG_VALUE instruction.
257 DIExpression getDebugExpression() const {
258 assert(isDebugValue() && "not a DBG_VALUE");
259 DIExpression Expr(getOperand(3).getMetadata());
260 assert(Expr.Verify() && "not a DIExpression");
261 return Expr;
250 const MDNode *Var = getOperand(getNumOperands() - 1).getMetadata();
251 return DIVariable(Var);
262252 }
263253
264254 /// emitError - Emit an error referring to the source location of this
169169
170170 const MachineInstrBuilder &addMetadata(const MDNode *MD) const {
171171 MI->addOperand(*MF, MachineOperand::CreateMetadata(MD));
172 assert((MI->isDebugValue() ? MI->getDebugVariable().Verify() : true) &&
173 "first MDNode argument of a DBG_VALUE not a DIVariable");
174172 return *this;
175173 }
176174
346344 /// address. The convention is that a DBG_VALUE is indirect iff the
347345 /// second operand is an immediate.
348346 ///
349 inline MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL,
350 const MCInstrDesc &MCID, bool IsIndirect,
351 unsigned Reg, unsigned Offset,
352 const MDNode *Variable, const MDNode *Expr) {
353 assert(DIVariable(Variable).Verify() && "not a DIVariable");
354 assert(DIExpression(Expr).Verify() && "not a DIExpression");
347 inline MachineInstrBuilder BuildMI(MachineFunction &MF,
348 DebugLoc DL,
349 const MCInstrDesc &MCID,
350 bool IsIndirect,
351 unsigned Reg,
352 unsigned Offset,
353 const MDNode *MD) {
355354 if (IsIndirect)
356355 return BuildMI(MF, DL, MCID)
357 .addReg(Reg, RegState::Debug)
358 .addImm(Offset)
359 .addMetadata(Variable)
360 .addMetadata(Expr);
356 .addReg(Reg, RegState::Debug)
357 .addImm(Offset)
358 .addMetadata(MD);
361359 else {
362360 assert(Offset == 0 && "A direct address cannot have an offset.");
363361 return BuildMI(MF, DL, MCID)
364 .addReg(Reg, RegState::Debug)
365 .addReg(0U, RegState::Debug)
366 .addMetadata(Variable)
367 .addMetadata(Expr);
362 .addReg(Reg, RegState::Debug)
363 .addReg(0U, RegState::Debug)
364 .addMetadata(MD);
368365 }
369366 }
370367
373370 /// address and inserts it at position I.
374371 ///
375372 inline MachineInstrBuilder BuildMI(MachineBasicBlock &BB,
376 MachineBasicBlock::iterator I, DebugLoc DL,
377 const MCInstrDesc &MCID, bool IsIndirect,
378 unsigned Reg, unsigned Offset,
379 const MDNode *Variable, const MDNode *Expr) {
380 assert(DIVariable(Variable).Verify() && "not a DIVariable");
381 assert(DIExpression(Expr).Verify() && "not a DIExpression");
373 MachineBasicBlock::iterator I,
374 DebugLoc DL,
375 const MCInstrDesc &MCID,
376 bool IsIndirect,
377 unsigned Reg,
378 unsigned Offset,
379 const MDNode *MD) {
382380 MachineFunction &MF = *BB.getParent();
383 MachineInstr *MI =
384 BuildMI(MF, DL, MCID, IsIndirect, Reg, Offset, Variable, Expr);
381 MachineInstr *MI = BuildMI(MF, DL, MCID, IsIndirect, Reg, Offset, MD);
385382 BB.insert(I, MI);
386383 return MachineInstrBuilder(MF, MI);
387384 }
165165
166166 struct VariableDbgInfo {
167167 TrackingVH Var;
168 TrackingVH Expr;
169168 unsigned Slot;
170169 DebugLoc Loc;
171170 };
390389
391390 /// setVariableDbgInfo - Collect information used to emit debugging
392391 /// information of a variable.
393 void setVariableDbgInfo(MDNode *Var, MDNode *Expr, unsigned Slot,
394 DebugLoc Loc) {
395 VariableDbgInfo Info = {Var, Expr, Slot, Loc};
392 void setVariableDbgInfo(MDNode *N, unsigned Slot, DebugLoc Loc) {
393 VariableDbgInfo Info = { N, Slot, Loc };
396394 VariableDbgInfos.push_back(std::move(Info));
397395 }
398396
983983
984984 /// getDbgValue - Creates a SDDbgValue node.
985985 ///
986 /// SDNode
987 SDDbgValue *getDbgValue(MDNode *Var, MDNode *Expr, SDNode *N, unsigned R,
988 bool IsIndirect, uint64_t Off, DebugLoc DL,
989 unsigned O);
990
991 /// Constant
992 SDDbgValue *getConstantDbgValue(MDNode *Var, MDNode *Expr, const Value *C,
993 uint64_t Off, DebugLoc DL, unsigned O);
994
995 /// FrameIndex
996 SDDbgValue *getFrameIndexDbgValue(MDNode *Var, MDNode *Expr, unsigned FI,
997 uint64_t Off, DebugLoc DL, unsigned O);
986 SDDbgValue *getDbgValue(MDNode *MDPtr, SDNode *N, unsigned R,
987 bool IsIndirect, uint64_t Off,
988 DebugLoc DL, unsigned O);
989 /// Constant.
990 SDDbgValue *getConstantDbgValue(MDNode *MDPtr, const Value *C, uint64_t Off,
991 DebugLoc DL, unsigned O);
992 /// Frame index.
993 SDDbgValue *getFrameIndexDbgValue(MDNode *MDPtr, unsigned FI, uint64_t Off,
994 DebugLoc DL, unsigned O);
998995
999996 /// RemoveDeadNode - Remove the specified node from the system. If any of its
1000997 /// operands then becomes dead, remove them as well. Inform UpdateListener
8484
8585 public:
8686 explicit DIBuilder(Module &M);
87 enum ComplexAddrKind { OpPlus=1, OpDeref, OpPiece };
8788 enum DebugEmissionKind { FullDebug=1, LineTablesOnly };
8889
8990 /// finalize - Construct any deferred debug info descriptors.
499500 unsigned Flags = 0,
500501 unsigned ArgNo = 0);
501502
502 /// createExpression - Create a new descriptor for the specified
503
504 /// createComplexVariable - Create a new descriptor for the specified
503505 /// variable which has a complex address expression for its address.
506 /// @param Tag Dwarf TAG. Usually DW_TAG_auto_variable or
507 /// DW_TAG_arg_variable.
508 /// @param Scope Variable scope.
509 /// @param Name Variable name.
510 /// @param F File where this variable is defined.
511 /// @param LineNo Line number.
512 /// @param Ty Variable Type
504513 /// @param Addr An array of complex address operations.
505 DIExpression createExpression(ArrayRef Addr = None);
506
507 /// createPieceExpression - Create a descriptor to describe one part
514 /// @param ArgNo If this variable is an argument then this argument's
515 /// number. 1 indicates 1st argument.
516 DIVariable createComplexVariable(unsigned Tag, DIDescriptor Scope,
517 StringRef Name, DIFile F, unsigned LineNo,
518 DITypeRef Ty, ArrayRef Addr,
519 unsigned ArgNo = 0);
520
521 /// createVariablePiece - Create a descriptor to describe one part
508522 /// of aggregate variable that is fragmented across multiple Values.
509523 ///
524 /// @param Variable Variable that is partially represented by this.
510525 /// @param OffsetInBytes Offset of the piece in bytes.
511526 /// @param SizeInBytes Size of the piece in bytes.
512 DIExpression createPieceExpression(unsigned OffsetInBytes,
513 unsigned SizeInBytes);
527 DIVariable createVariablePiece(DIVariable Variable,
528 unsigned OffsetInBytes,
529 unsigned SizeInBytes);
514530
515531 /// createFunction - Create a new descriptor for the specified subprogram.
516532 /// See comments in DISubprogram for descriptions of these fields.
658674 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
659675 /// @param Storage llvm::Value of the variable
660676 /// @param VarInfo Variable's debug info descriptor.
661 /// @param Expr A complex location expression.
662677 /// @param InsertAtEnd Location for the new intrinsic.
663678 Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
664 DIExpression Expr, BasicBlock *InsertAtEnd);
679 BasicBlock *InsertAtEnd);
665680
666681 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
667682 /// @param Storage llvm::Value of the variable
668683 /// @param VarInfo Variable's debug info descriptor.
669 /// @param Expr A complex location expression.
670684 /// @param InsertBefore Location for the new intrinsic.
671685 Instruction *insertDeclare(llvm::Value *Storage, DIVariable VarInfo,
672 DIExpression Expr, Instruction *InsertBefore);
686 Instruction *InsertBefore);
687
673688
674689 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
675690 /// @param Val llvm::Value of the variable
676691 /// @param Offset Offset
677692 /// @param VarInfo Variable's debug info descriptor.
678 /// @param Expr A complex location expression.
679693 /// @param InsertAtEnd Location for the new intrinsic.
680694 Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
681 DIVariable VarInfo, DIExpression Expr,
695 DIVariable VarInfo,
682696 BasicBlock *InsertAtEnd);
683697
684698 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
685699 /// @param Val llvm::Value of the variable
686700 /// @param Offset Offset
687701 /// @param VarInfo Variable's debug info descriptor.
688 /// @param Expr A complex location expression.
689702 /// @param InsertBefore Location for the new intrinsic.
690703 Instruction *insertDbgValueIntrinsic(llvm::Value *Val, uint64_t Offset,
691 DIVariable VarInfo, DIExpression Expr,
704 DIVariable VarInfo,
692705 Instruction *InsertBefore);
693706 };
694707 } // end namespace llvm
149149 bool isTemplateValueParameter() const;
150150 bool isObjCProperty() const;
151151 bool isImportedEntity() const;
152 bool isExpression() const;
153152
154153 /// print - print descriptor.
155154 void print(raw_ostream &OS) const;
720719 /// Verify - Verify that a variable descriptor is well formed.
721720 bool Verify() const;
722721
722 /// HasComplexAddr - Return true if the variable has a complex address.
723 bool hasComplexAddress() const { return getNumAddrElements() > 0; }
724
725 /// \brief Return the size of this variable's complex address or
726 /// zero if there is none.
727 unsigned getNumAddrElements() const {
728 if (DbgNode->getNumOperands() < 9)
729 return 0;
730 return getDescriptorField(8)->getNumOperands();
731 }
732
733 /// \brief return the Idx'th complex address element.
734 uint64_t getAddrElement(unsigned Idx) const;
735
723736 /// isBlockByrefVariable - Return true if the variable was declared as
724737 /// a "__block" variable (Apple Blocks).
725738 bool isBlockByrefVariable(const DITypeIdentifierMap &Map) const {
729742 /// isInlinedFnArgument - Return true if this variable provides debugging
730743 /// information for an inlined function arguments.
731744 bool isInlinedFnArgument(const Function *CurFn);
732
733 /// Return the size reported by the variable's type.
734 unsigned getSizeInBits(const DITypeIdentifierMap &Map);
735
736 void printExtendedName(raw_ostream &OS) const;
737 };
738
739 /// DIExpression - A complex location expression.
740 class DIExpression : public DIDescriptor {
741 friend class DIDescriptor;
742 void printInternal(raw_ostream &OS) const;
743
744 public:
745 explicit DIExpression(const MDNode *N = nullptr) : DIDescriptor(N) {}
746
747 /// Verify - Verify that a variable descriptor is well formed.
748 bool Verify() const;
749
750 /// \brief Return the number of elements in the complex expression.
751 unsigned getNumElements() const {
752 if (!DbgNode)
753 return 0;
754 unsigned N = DbgNode->getNumOperands();
755 assert(N > 0 && "missing tag");
756 return N - 1;
757 }
758
759 /// \brief return the Idx'th complex address element.
760 uint64_t getElement(unsigned Idx) const;
761745
762746 /// isVariablePiece - Return whether this is a piece of an aggregate
763747 /// variable.
766750 uint64_t getPieceOffset() const;
767751 /// getPieceSize - Return the size of this piece in bytes.
768752 uint64_t getPieceSize() const;
753
754 /// Return the size reported by the variable's type.
755 unsigned getSizeInBits(const DITypeIdentifierMap &Map);
756
757 void printExtendedName(raw_ostream &OS) const;
769758 };
770759
771760 /// DILocation - This object holds location information. This object
882871 /// cleanseInlinedVariable - Remove inlined scope from the variable.
883872 DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext);
884873
874 /// getEntireVariable - Remove OpPiece exprs from the variable.
875 DIVariable getEntireVariable(DIVariable DV);
876
885877 /// Construct DITypeIdentifierMap by going through retained types of each CU.
886878 DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes);
887879
8181 public:
8282 Value *getAddress() const;
8383 MDNode *getVariable() const { return cast(getArgOperand(1)); }
84 MDNode *getExpression() const { return cast(getArgOperand(2)); }
8584
8685 // Methods for support type inquiry through isa, cast, and dyn_cast:
8786 static inline bool classof(const IntrinsicInst *I) {
103102 const_cast(getArgOperand(1)))->getZExtValue();
104103 }
105104 MDNode *getVariable() const { return cast(getArgOperand(2)); }
106 MDNode *getExpression() const { return cast(getArgOperand(3)); }
107105
108106 // Methods for support type inquiry through isa, cast, and dyn_cast:
109107 static inline bool classof(const IntrinsicInst *I) {
372372 // places.
373373 let Properties = [IntrNoMem] in {
374374 def int_dbg_declare : Intrinsic<[],
375 [llvm_metadata_ty,
376 llvm_metadata_ty,
377 llvm_metadata_ty]>;
375 [llvm_metadata_ty, llvm_metadata_ty]>;
378376 def int_dbg_value : Intrinsic<[],
379377 [llvm_metadata_ty, llvm_i64_ty,
380 llvm_metadata_ty,
381378 llvm_metadata_ty]>;
382379 }
383380
5252
5353 DW_TAG_auto_variable = 0x100, // Tag for local (auto) variables.
5454 DW_TAG_arg_variable = 0x101, // Tag for argument variables.
55 DW_TAG_expression = 0x102, // Tag for complex address expressions.
5655
5756 DW_TAG_user_base = 0x1000, // Recommended base for user tags.
5857
613613 /// of DBG_VALUE, returning true if it was able to do so. A false return
614614 /// means the target will need to handle MI in EmitInstruction.
615615 static bool emitDebugValueComment(const MachineInstr *MI, AsmPrinter &AP) {
616 // This code handles only the 4-operand target-independent form.
617 if (MI->getNumOperands() != 4)
616 // This code handles only the 3-operand target-independent form.
617 if (MI->getNumOperands() != 3)
618618 return false;
619619
620620 SmallString<128> Str;
628628 OS << Name << ":";
629629 }
630630 OS << V.getName();
631
632 DIExpression Expr = MI->getDebugExpression();
633 if (Expr.isVariablePiece())
634 OS << " [piece offset=" << Expr.getPieceOffset()
635 << " size=" << Expr.getPieceSize() << "]";
631 if (V.isVariablePiece())
632 OS << " [piece offset=" << V.getPieceOffset()
633 << " size="<
636634 OS << " <- ";
637635
638636 // The second operand is only an offset if it's an immediate.
2626 // In the other case, returns 0.
2727 static unsigned isDescribedByReg(const MachineInstr &MI) {
2828 assert(MI.isDebugValue());
29 assert(MI.getNumOperands() == 4);
29 assert(MI.getNumOperands() == 3);
3030 // If location of variable is described using a register (directly or
3131 // indirecltly), this register is always a first operand.
3232 return MI.getOperand(0).isReg() ? MI.getOperand(0).getReg() : 0;
3636 const MachineInstr &MI) {
3737 // Instruction range should start with a DBG_VALUE instruction for the
3838 // variable.
39 assert(MI.isDebugValue() && "not a DBG_VALUE");
39 assert(MI.isDebugValue() && getEntireVariable(MI.getDebugVariable()) == Var);
4040 auto &Ranges = VarInstrRanges[Var];
4141 if (!Ranges.empty() && Ranges.back().second == nullptr &&
4242 Ranges.back().first->isIdenticalTo(&MI)) {
192192 // Use the base variable (without any DW_OP_piece expressions)
193193 // as index into History. The full variables including the
194194 // piece expressions are attached to the MI.
195 DIVariable Var = MI.getDebugVariable();
195 DIVariable Var = getEntireVariable(MI.getDebugVariable());
196196
197197 if (unsigned PrevReg = Result.getRegisterForVar(Var))
198198 dropRegDescribedVar(RegVars, PrevReg, Var);
2525 public:
2626 /// A single location or constant.
2727 struct Value {
28 Value(const MDNode *Var, const MDNode *Expr, int64_t i)
29 : Variable(Var), Expression(Expr), EntryKind(E_Integer) {
28 Value(const MDNode *Var, int64_t i)
29 : Variable(Var), EntryKind(E_Integer) {
3030 Constant.Int = i;
3131 }
32 Value(const MDNode *Var, const MDNode *Expr, const ConstantFP *CFP)
33 : Variable(Var), Expression(Expr), EntryKind(E_ConstantFP) {
32 Value(const MDNode *Var, const ConstantFP *CFP)
33 : Variable(Var), EntryKind(E_ConstantFP) {
3434 Constant.CFP = CFP;
3535 }
36 Value(const MDNode *Var, const MDNode *Expr, const ConstantInt *CIP)
37 : Variable(Var), Expression(Expr), EntryKind(E_ConstantInt) {
36 Value(const MDNode *Var, const ConstantInt *CIP)
37 : Variable(Var), EntryKind(E_ConstantInt) {
3838 Constant.CIP = CIP;
3939 }
40 Value(const MDNode *Var, const MDNode *Expr, MachineLocation Loc)
41 : Variable(Var), Expression(Expr), EntryKind(E_Location), Loc(Loc) {
42 assert(DIVariable(Var).Verify());
43 assert(DIExpression(Expr).Verify());
40 Value(const MDNode *Var, MachineLocation Loc)
41 : Variable(Var), EntryKind(E_Location), Loc(Loc) {
4442 }
4543
4644 // The variable to which this location entry corresponds.
4745 const MDNode *Variable;
48
49 // Any complex address location expression for this Value.
50 const MDNode *Expression;
5146
5247 // Type of entry that this represents.
5348 enum EntryType { E_Location, E_Integer, E_ConstantFP, E_ConstantInt };
7368 MachineLocation getLoc() const { return Loc; }
7469 const MDNode *getVariableNode() const { return Variable; }
7570 DIVariable getVariable() const { return DIVariable(Variable); }
76 bool isVariablePiece() const { return getExpression().isVariablePiece(); }
77 DIExpression getExpression() const { return DIExpression(Expression); }
71 bool isVariablePiece() const { return getVariable().isVariablePiece(); }
7872 friend bool operator==(const Value &, const Value &);
7973 friend bool operator<(const Value &, const Value &);
8074 };
9589 // list of values.
9690 // Return true if the merge was successful.
9791 bool MergeValues(const DebugLocEntry &Next) {
98 if (Begin == Next.Begin) {
99 DIExpression Expr(Values[0].Expression);
92 if (Begin == Next.Begin && Values.size() > 0 && Next.Values.size() > 0) {
10093 DIVariable Var(Values[0].Variable);
101 DIExpression NextExpr(Next.Values[0].Expression);
10294 DIVariable NextVar(Next.Values[0].Variable);
103 if (Var == NextVar && Expr.isVariablePiece() &&
104 NextExpr.isVariablePiece()) {
95 if (Var.getName() == NextVar.getName() &&
96 Var.isVariablePiece() && NextVar.isVariablePiece()) {
10597 addValues(Next.Values);
10698 End = Next.End;
10799 return true;
140132 std::sort(Values.begin(), Values.end());
141133 Values.erase(std::unique(Values.begin(), Values.end(),
142134 [](const Value &A, const Value &B) {
143 return A.getVariable() == B.getVariable() &&
144 A.getExpression() == B.getExpression();
145 }),
146 Values.end());
135 return A.getVariable() == B.getVariable();
136 }), Values.end());
147137 }
148138 };
149139
153143 if (A.EntryKind != B.EntryKind)
154144 return false;
155145
156 if (A.Expression != B.Expression)
157 return false;
158
159 if (A.Variable != B.Variable)
146 if (A.getVariable() != B.getVariable())
160147 return false;
161148
162149 switch (A.EntryKind) {
175162 /// Compare two pieces based on their offset.
176163 inline bool operator<(const DebugLocEntry::Value &A,
177164 const DebugLocEntry::Value &B) {
178 return A.getExpression().getPieceOffset() <
179 B.getExpression().getPieceOffset();
165 return A.getVariable().getPieceOffset() < B.getVariable().getPieceOffset();
180166 }
181167
182168 }
900900 for (unsigned vi = 0, ve = Variables.getNumElements(); vi != ve; ++vi) {
901901 DIVariable DV(Variables.getElement(vi));
902902 assert(DV.isVariable());
903 DbgVariable NewVar(DV, DIExpression(nullptr), this);
903 DbgVariable NewVar(DV, this);
904904 auto VariableDie = SPCU->constructVariableDIE(NewVar);
905905 SPCU->applyVariableAttributes(NewVar, *VariableDie);
906906 SPDIE->addChild(std::move(VariableDie));
11201120
11211121 void DwarfDebug::createAbstractVariable(const DIVariable &Var,
11221122 LexicalScope *Scope) {
1123 auto AbsDbgVariable = make_unique(Var, DIExpression(), this);
1123 auto AbsDbgVariable = make_unique(Var, this);
11241124 addScopeVariable(Scope, AbsDbgVariable.get());
11251125 AbstractVariables[Var] = std::move(AbsDbgVariable);
11261126 }
11761176 continue;
11771177 Processed.insert(VI.Var);
11781178 DIVariable DV(VI.Var);
1179 DIExpression Expr(VI.Expr);
11801179 LexicalScope *Scope = LScopes.findLexicalScope(VI.Loc);
11811180
11821181 // If variable scope is not found then skip this variable.
11841183 continue;
11851184
11861185 ensureAbstractVariableIsCreatedIfScoped(DV, Scope->getScopeNode());
1187 ConcreteVariables.push_back(make_unique(DV, Expr, this));
1186 ConcreteVariables.push_back(make_unique(DV, this));
11881187 DbgVariable *RegVar = ConcreteVariables.back().get();
11891188 RegVar->setFrameIndex(VI.Slot);
11901189 addScopeVariable(Scope, RegVar);
11931192
11941193 // Get .debug_loc entry for the instruction range starting at MI.
11951194 static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) {
1196 const MDNode *Expr = MI->getDebugExpression();
11971195 const MDNode *Var = MI->getDebugVariable();
11981196
1199 assert(MI->getNumOperands() == 4);
1197 assert(MI->getNumOperands() == 3);
12001198 if (MI->getOperand(0).isReg()) {
12011199 MachineLocation MLoc;
12021200 // If the second operand is an immediate, this is a
12051203 MLoc.set(MI->getOperand(0).getReg());
12061204 else
12071205 MLoc.set(MI->getOperand(0).getReg(), MI->getOperand(1).getImm());
1208 return DebugLocEntry::Value(Var, Expr, MLoc);
1206 return DebugLocEntry::Value(Var, MLoc);
12091207 }
12101208 if (MI->getOperand(0).isImm())
1211 return DebugLocEntry::Value(Var, Expr, MI->getOperand(0).getImm());
1209 return DebugLocEntry::Value(Var, MI->getOperand(0).getImm());
12121210 if (MI->getOperand(0).isFPImm())
1213 return DebugLocEntry::Value(Var, Expr, MI->getOperand(0).getFPImm());
1211 return DebugLocEntry::Value(Var, MI->getOperand(0).getFPImm());
12141212 if (MI->getOperand(0).isCImm())
1215 return DebugLocEntry::Value(Var, Expr, MI->getOperand(0).getCImm());
1216
1217 llvm_unreachable("Unexpected 4-operand DBG_VALUE instruction!");
1213 return DebugLocEntry::Value(Var, MI->getOperand(0).getCImm());
1214
1215 llvm_unreachable("Unexpected 3 operand DBG_VALUE instruction!");
12181216 }
12191217
12201218 /// Determine whether two variable pieces overlap.
1221 static bool piecesOverlap(DIExpression P1, DIExpression P2) {
1219 static bool piecesOverlap(DIVariable P1, DIVariable P2) {
12221220 if (!P1.isVariablePiece() || !P2.isVariablePiece())
12231221 return true;
12241222 unsigned l1 = P1.getPieceOffset();
12691267 }
12701268
12711269 // If this piece overlaps with any open ranges, truncate them.
1272 DIExpression DIExpr = Begin->getDebugExpression();
1270 DIVariable DIVar = Begin->getDebugVariable();
12731271 auto Last = std::remove_if(OpenRanges.begin(), OpenRanges.end(),
12741272 [&](DebugLocEntry::Value R) {
1275 return piecesOverlap(DIExpr, R.getExpression());
1276 });
1273 return piecesOverlap(DIVar, R.getVariable());
1274 });
12771275 OpenRanges.erase(Last, OpenRanges.end());
12781276
12791277 const MCSymbol *StartLabel = getLabelBeforeInsn(Begin);
12951293 bool couldMerge = false;
12961294
12971295 // If this is a piece, it may belong to the current DebugLocEntry.
1298 if (DIExpr.isVariablePiece()) {
1296 if (DIVar.isVariablePiece()) {
12991297 // Add this value to the list of open ranges.
13001298 OpenRanges.push_back(Value);
13011299
13211319 if (PrevEntry != DebugLoc.rend() && PrevEntry->MergeRanges(*CurEntry))
13221320 DebugLoc.pop_back();
13231321
1324 DEBUG({
1325 dbgs() << CurEntry->getValues().size() << " Values:\n";
1326 for (auto Value : CurEntry->getValues()) {
1327 Value.getVariable()->dump();
1328 Value.getExpression()->dump();
1329 }
1330 dbgs() << "-----\n";
1331 });
1322 DEBUG(dbgs() << "Values:\n";
1323 for (auto Value : CurEntry->getValues())
1324 Value.getVariable()->dump();
1325 dbgs() << "-----\n");
13321326 }
13331327 }
13341328
13631357 if (!Scope)
13641358 continue;
13651359
1366 Processed.insert(DV);
1360 Processed.insert(getEntireVariable(DV));
13671361 const MachineInstr *MInsn = Ranges.front().first;
13681362 assert(MInsn->isDebugValue() && "History must begin with debug value");
13691363 ensureAbstractVariableIsCreatedIfScoped(DV, Scope->getScopeNode());
13971391 continue;
13981392 if (LexicalScope *Scope = LScopes.findLexicalScope(DV.getContext())) {
13991393 ensureAbstractVariableIsCreatedIfScoped(DV, Scope->getScopeNode());
1400 DIExpression NoExpr;
1401 ConcreteVariables.push_back(make_unique(DV, NoExpr, this));
1394 ConcreteVariables.push_back(make_unique(DV, this));
14021395 addScopeVariable(Scope, ConcreteVariables.back().get());
14031396 }
14041397 }
15861579
15871580 // The first mention of a function argument gets the FunctionBeginSym
15881581 // label, so arguments are visible when breaking at function entry.
1589 DIVariable DIVar(Ranges.front().first->getDebugVariable());
1590 if (DIVar.isVariable() && DIVar.getTag() == dwarf::DW_TAG_arg_variable &&
1591 getDISubprogram(DIVar.getContext()).describes(MF->getFunction())) {
1592 LabelsBeforeInsn[Ranges.front().first] = FunctionBeginSym;
1593 if (Ranges.front().first->getDebugExpression().isVariablePiece()) {
1582 DIVariable DV(Ranges.front().first->getDebugVariable());
1583 if (DV.isVariable() && DV.getTag() == dwarf::DW_TAG_arg_variable &&
1584 getDISubprogram(DV.getContext()).describes(MF->getFunction())) {
1585 if (!DV.isVariablePiece())
1586 LabelsBeforeInsn[Ranges.front().first] = FunctionBeginSym;
1587 else {
15941588 // Mark all non-overlapping initial pieces.
15951589 for (auto I = Ranges.begin(); I != Ranges.end(); ++I) {
1596 DIExpression Piece = I->first->getDebugExpression();
1590 DIVariable Piece = I->first->getDebugVariable();
15971591 if (std::all_of(Ranges.begin(), I,
1598 [&](DbgValueHistoryMap::InstrRange Pred) {
1599 return !piecesOverlap(Piece, Pred.first->getDebugExpression());
1592 [&](DbgValueHistoryMap::InstrRange Pred){
1593 return !piecesOverlap(Piece, Pred.first->getDebugVariable());
16001594 }))
16011595 LabelsBeforeInsn[I->first] = FunctionBeginSym;
16021596 else
20942088
20952089 unsigned Offset = 0;
20962090 for (auto Piece : Values) {
2097 DIExpression Expr = Piece.getExpression();
2098 unsigned PieceOffset = Expr.getPieceOffset();
2099 unsigned PieceSize = Expr.getPieceSize();
2091 DIVariable Var = Piece.getVariable();
2092 unsigned PieceOffset = Var.getPieceOffset();
2093 unsigned PieceSize = Var.getPieceSize();
21002094 assert(Offset <= PieceOffset && "overlapping or duplicate pieces");
21012095 if (Offset < PieceOffset) {
21022096 // The DWARF spec seriously mandates pieces with no locations for gaps.
21072101 Offset += PieceSize;
21082102
21092103 const unsigned SizeOfByte = 8;
2104 assert(!Var.isIndirect() && "indirect address for piece");
21102105 #ifndef NDEBUG
2111 DIVariable Var = Piece.getVariable();
2112 assert(!Var.isIndirect() && "indirect address for piece");
21132106 unsigned VarSize = Var.getSizeInBits(Map);
21142107 assert(PieceSize+PieceOffset <= VarSize/SizeOfByte
21152108 && "piece is larger than or outside of variable");
21552148 }
21562149 } else if (Value.isLocation()) {
21572150 MachineLocation Loc = Value.getLoc();
2158 DIExpression Expr = Value.getExpression();
2159 if (!Expr)
2151 if (!DV.hasComplexAddress())
21602152 // Regular entry.
21612153 Asm->EmitDwarfRegOp(Streamer, Loc, DV.isIndirect());
21622154 else {
21632155 // Complex address entry.
2164 unsigned N = Expr.getNumElements();
2156 unsigned N = DV.getNumAddrElements();
21652157 unsigned i = 0;
2166 if (N >= 2 && Expr.getElement(0) == dwarf::DW_OP_plus) {
2158 if (N >= 2 && DV.getAddrElement(0) == DIBuilder::OpPlus) {
21672159 if (Loc.getOffset()) {
21682160 i = 2;
21692161 Asm->EmitDwarfRegOp(Streamer, Loc, DV.isIndirect());
21702162 Streamer.EmitInt8(dwarf::DW_OP_deref, "DW_OP_deref");
21712163 Streamer.EmitInt8(dwarf::DW_OP_plus_uconst, "DW_OP_plus_uconst");
2172 Streamer.EmitSLEB128(Expr.getElement(1));
2164 Streamer.EmitSLEB128(DV.getAddrElement(1));
21732165 } else {
21742166 // If first address element is OpPlus then emit
21752167 // DW_OP_breg + Offset instead of DW_OP_reg + Offset.
2176 MachineLocation TLoc(Loc.getReg(), Expr.getElement(1));
2168 MachineLocation TLoc(Loc.getReg(), DV.getAddrElement(1));
21772169 Asm->EmitDwarfRegOp(Streamer, TLoc, DV.isIndirect());
21782170 i = 2;
21792171 }
21832175
21842176 // Emit remaining complex address elements.
21852177 for (; i < N; ++i) {
2186 uint64_t Element = Expr.getElement(i);
2187 if (Element == dwarf::DW_OP_plus) {
2178 uint64_t Element = DV.getAddrElement(i);
2179 if (Element == DIBuilder::OpPlus) {
21882180 Streamer.EmitInt8(dwarf::DW_OP_plus_uconst, "DW_OP_plus_uconst");
2189 Streamer.EmitULEB128(Expr.getElement(++i));
2190 } else if (Element == dwarf::DW_OP_deref) {
2181 Streamer.EmitULEB128(DV.getAddrElement(++i));
2182 } else if (Element == DIBuilder::OpDeref) {
21912183 if (!Loc.isReg())
21922184 Streamer.EmitInt8(dwarf::DW_OP_deref, "DW_OP_deref");
2193 } else if (Element == dwarf::DW_OP_piece) {
2185 } else if (Element == DIBuilder::OpPiece) {
21942186 i += 3;
21952187 // handled in emitDebugLocEntry.
21962188 } else
6969 /// \brief This class is used to track local variable information.
7070 class DbgVariable {
7171 DIVariable Var; // Variable Descriptor.
72 DIExpression Expr; // Complex address location expression.
7372 DIE *TheDIE; // Variable DIE.
7473 unsigned DotDebugLocOffset; // Offset in DotDebugLocEntries.
7574 const MachineInstr *MInsn; // DBG_VALUE instruction of the variable.
7877
7978 public:
8079 /// Construct a DbgVariable from a DIVariable.
81 DbgVariable(DIVariable V, DIExpression E, DwarfDebug *DD)
82 : Var(V), Expr(E), TheDIE(nullptr), DotDebugLocOffset(~0U),
83 MInsn(nullptr), FrameIndex(~0), DD(DD) {
84 assert(Var.Verify() && Expr.Verify());
85 }
80 DbgVariable(DIVariable V, DwarfDebug *DD)
81 : Var(V), TheDIE(nullptr), DotDebugLocOffset(~0U), MInsn(nullptr),
82 FrameIndex(~0), DD(DD) {}
8683
8784 /// Construct a DbgVariable from a DEBUG_VALUE.
8885 /// AbstractVar may be NULL.
8986 DbgVariable(const MachineInstr *DbgValue, DwarfDebug *DD)
90 : Var(DbgValue->getDebugVariable()), Expr(DbgValue->getDebugExpression()),
91 TheDIE(nullptr), DotDebugLocOffset(~0U), MInsn(DbgValue),
92 FrameIndex(~0), DD(DD) {}
87 : Var(DbgValue->getDebugVariable()), TheDIE(nullptr),
88 DotDebugLocOffset(~0U), MInsn(DbgValue), FrameIndex(~0), DD(DD) {}
9389
9490 // Accessors.
9591 DIVariable getVariable() const { return Var; }
96 DIExpression getExpression() const { return Expr; }
9792 void setDIE(DIE &D) { TheDIE = &D; }
9893 DIE *getDIE() const { return TheDIE; }
9994 void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
128123
129124 bool variableHasComplexAddress() const {
130125 assert(Var.isVariable() && "Invalid complex DbgVariable!");
131 return Expr.getNumElements() > 0;
126 return Var.hasComplexAddress();
132127 }
133128 bool isBlockByrefVariable() const;
134129 unsigned getNumAddrElements() const {
135130 assert(Var.isVariable() && "Invalid complex DbgVariable!");
136 return Expr.getNumElements();
137 }
138 uint64_t getAddrElement(unsigned i) const { return Expr.getElement(i); }
131 return Var.getNumAddrElements();
132 }
133 uint64_t getAddrElement(unsigned i) const { return Var.getAddrElement(i); }
139134 DIType getType() const;
140135
141136 private:
606606 unsigned N = DV.getNumAddrElements();
607607 unsigned i = 0;
608608 if (Location.isReg()) {
609 if (N >= 2 && DV.getAddrElement(0) == dwarf::DW_OP_plus) {
610 assert(!DV.getVariable().isIndirect() &&
611 "double indirection not handled");
609 if (N >= 2 && DV.getAddrElement(0) == DIBuilder::OpPlus) {
612610 // If first address element is OpPlus then emit
613611 // DW_OP_breg + Offset instead of DW_OP_reg + Offset.
614612 addRegisterOffset(*Loc, Location.getReg(), DV.getAddrElement(1));
615613 i = 2;
616 } else if (N >= 2 && DV.getAddrElement(0) == dwarf::DW_OP_deref) {
617 assert(!DV.getVariable().isIndirect() &&
618 "double indirection not handled");
619 addRegisterOpPiece(*Loc, Location.getReg(),
620 DV.getExpression().getPieceSize(),
621 DV.getExpression().getPieceOffset());
622 i = 3;
614 } else if (N >= 2 && DV.getAddrElement(0) == DIBuilder::OpDeref) {
615 addRegisterOpPiece(*Loc, Location.getReg(),
616 DV.getVariable().getPieceSize(),
617 DV.getVariable().getPieceOffset());
618 i = 3;
623619 } else
624620 addRegisterOpPiece(*Loc, Location.getReg());
625621 } else
627623
628624 for (; i < N; ++i) {
629625 uint64_t Element = DV.getAddrElement(i);
630 if (Element == dwarf::DW_OP_plus) {
626 if (Element == DIBuilder::OpPlus) {
631627 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
632628 addUInt(*Loc, dwarf::DW_FORM_udata, DV.getAddrElement(++i));
633629
634 } else if (Element == dwarf::DW_OP_deref) {
630 } else if (Element == DIBuilder::OpDeref) {
635631 if (!Location.isReg())
636632 addUInt(*Loc, dwarf::DW_FORM_data1, dwarf::DW_OP_deref);
637633
638 } else if (Element == dwarf::DW_OP_piece) {
634 } else if (Element == DIBuilder::OpPiece) {
639635 const unsigned SizeOfByte = 8;
640636 unsigned PieceOffsetInBits = DV.getAddrElement(++i)*SizeOfByte;
641637 unsigned PieceSizeInBits = DV.getAddrElement(++i)*SizeOfByte;
18641860
18651861 // Check if variable is described by a DBG_VALUE instruction.
18661862 if (const MachineInstr *DVInsn = DV.getMInsn()) {
1867 assert(DVInsn->getNumOperands() == 4);
1863 assert(DVInsn->getNumOperands() == 3);
18681864 if (DVInsn->getOperand(0).isReg()) {
18691865 const MachineOperand RegOp = DVInsn->getOperand(0);
18701866 // If the second operand is an immediate, this is an indirect value.
12231223 // Modify DBG_VALUE now that the value is in a spill slot.
12241224 bool IsIndirect = MI->isIndirectDebugValue();
12251225 uint64_t Offset = IsIndirect ? MI->getOperand(1).getImm() : 0;
1226 const MDNode *Var = MI->getDebugVariable();
1227 const MDNode *Expr = MI->getDebugExpression();
1226 const MDNode *MDPtr = MI->getOperand(2).getMetadata();
12281227 DebugLoc DL = MI->getDebugLoc();
12291228 DEBUG(dbgs() << "Modifying debug info due to spill:" << "\t" << *MI);
12301229 MachineBasicBlock *MBB = MI->getParent();
12311230 BuildMI(*MBB, MBB->erase(MI), DL, TII.get(TargetOpcode::DBG_VALUE))
1232 .addFrameIndex(StackSlot)
1233 .addImm(Offset)
1234 .addMetadata(Var)
1235 .addMetadata(Expr);
1231 .addFrameIndex(StackSlot).addImm(Offset).addMetadata(MDPtr);
12361232 continue;
12371233 }
12381234
109109 namespace {
110110 class LDVImpl;
111111 class UserValue {
112 const MDNode *Variable; ///< The debug info variable we are part of.
113 const MDNode *Expression; ///< Any complex address expression.
112 const MDNode *variable; ///< The debug info variable we are part of.
114113 unsigned offset; ///< Byte offset into variable.
115114 bool IsIndirect; ///< true if this is a register-indirect+offset value.
116115 DebugLoc dl; ///< The debug location for the variable. This is
140139
141140 public:
142141 /// UserValue - Create a new UserValue.
143 UserValue(const MDNode *var, const MDNode *expr, unsigned o, bool i,
144 DebugLoc L, LocMap::Allocator &alloc)
145 : Variable(var), Expression(expr), offset(o), IsIndirect(i), dl(L),
146 leader(this), next(nullptr), locInts(alloc) {}
142 UserValue(const MDNode *var, unsigned o, bool i, DebugLoc L,
143 LocMap::Allocator &alloc)
144 : variable(var), offset(o), IsIndirect(i), dl(L), leader(this),
145 next(nullptr), locInts(alloc)
146 {}
147147
148148 /// getLeader - Get the leader of this value's equivalence class.
149149 UserValue *getLeader() {
157157 UserValue *getNext() const { return next; }
158158
159159 /// match - Does this UserValue match the parameters?
160 bool match(const MDNode *Var, const MDNode *Expr, unsigned Offset,
161 bool indirect) const {
162 return Var == Variable && Expr == Expression && Offset == offset &&
163 indirect == IsIndirect;
160 bool match(const MDNode *Var, unsigned Offset, bool indirect) const {
161 return Var == variable && Offset == offset && indirect == IsIndirect;
164162 }
165163
166164 /// merge - Merge equivalence classes.
308306 UVMap userVarMap;
309307
310308 /// getUserValue - Find or create a UserValue.
311 UserValue *getUserValue(const MDNode *Var, const MDNode *Expr,
312 unsigned Offset, bool IsIndirect, DebugLoc DL);
309 UserValue *getUserValue(const MDNode *Var, unsigned Offset,
310 bool IsIndirect, DebugLoc DL);
313311
314312 /// lookupVirtReg - Find the EC leader for VirtReg or null.
315313 UserValue *lookupVirtReg(unsigned VirtReg);
362360 } // namespace
363361
364362 void UserValue::print(raw_ostream &OS, const TargetMachine *TM) {
365 DIVariable DV(Variable);
363 DIVariable DV(variable);
366364 OS << "!\"";
367365 DV.printExtendedName(OS);
368366 OS << "\"\t";
423421 LDV->mapVirtReg(locations[i].getReg(), this);
424422 }
425423
426 UserValue *LDVImpl::getUserValue(const MDNode *Var, const MDNode *Expr,
427 unsigned Offset, bool IsIndirect,
428 DebugLoc DL) {
424 UserValue *LDVImpl::getUserValue(const MDNode *Var, unsigned Offset,
425 bool IsIndirect, DebugLoc DL) {
429426 UserValue *&Leader = userVarMap[Var];
430427 if (Leader) {
431428 UserValue *UV = Leader->getLeader();
432429 Leader = UV;
433430 for (; UV; UV = UV->getNext())
434 if (UV->match(Var, Expr, Offset, IsIndirect))
431 if (UV->match(Var, Offset, IsIndirect))
435432 return UV;
436433 }
437434
438435 userValues.push_back(
439 make_unique(Var, Expr, Offset, IsIndirect, DL, allocator));
436 make_unique(Var, Offset, IsIndirect, DL, allocator));
440437 UserValue *UV = userValues.back().get();
441438 Leader = UserValue::merge(Leader, UV);
442439 return UV;
456453
457454 bool LDVImpl::handleDebugValue(MachineInstr *MI, SlotIndex Idx) {
458455 // DBG_VALUE loc, offset, variable
459 if (MI->getNumOperands() != 4 ||
456 if (MI->getNumOperands() != 3 ||
460457 !(MI->getOperand(1).isReg() || MI->getOperand(1).isImm()) ||
461458 !MI->getOperand(2).isMetadata()) {
462459 DEBUG(dbgs() << "Can't handle " << *MI);
466463 // Get or create the UserValue for (variable,offset).
467464 bool IsIndirect = MI->isIndirectDebugValue();
468465 unsigned Offset = IsIndirect ? MI->getOperand(1).getImm() : 0;
469 const MDNode *Var = MI->getDebugVariable();
470 const MDNode *Expr = MI->getDebugExpression();
466 const MDNode *Var = MI->getOperand(2).getMetadata();
471467 //here.
472 UserValue *UV =
473 getUserValue(Var, Expr, Offset, IsIndirect, MI->getDebugLoc());
468 UserValue *UV = getUserValue(Var, Offset, IsIndirect, MI->getDebugLoc());
474469 UV->addDef(Idx, MI->getOperand(0));
475470 return true;
476471 }
955950
956951 if (Loc.isReg())
957952 BuildMI(*MBB, I, findDebugLoc(), TII.get(TargetOpcode::DBG_VALUE),
958 IsIndirect, Loc.getReg(), offset, Variable, Expression);
953 IsIndirect, Loc.getReg(), offset, variable);
959954 else
960955 BuildMI(*MBB, I, findDebugLoc(), TII.get(TargetOpcode::DBG_VALUE))
961 .addOperand(Loc)
962 .addImm(offset)
963 .addMetadata(Variable)
964 .addMetadata(Expression);
956 .addOperand(Loc).addImm(offset).addMetadata(variable);
965957 }
966958
967959 void UserValue::emitDebugValues(VirtRegMap *VRM, LiveIntervals &LIS,
16421642 if (isDebugValue() && MO.isMetadata()) {
16431643 // Pretty print DBG_VALUE instructions.
16441644 const MDNode *MD = MO.getMetadata();
1645 if (MD->getNumOperands() >= 2)
1646 if (const MDString *MDS = dyn_cast(MD->getOperand(2)))
1647 OS << "!\"" << MDS->getString() << '\"';
1648 else
1649 MO.print(OS, TM);
1645 if (const MDString *MDS = dyn_cast(MD->getOperand(2)))
1646 OS << "!\"" << MDS->getString() << '\"';
16501647 else
16511648 MO.print(OS, TM);
16521649 } else if (TM && (isInsertSubreg() || isRegSequence()) && MO.isImm()) {
17491746 OS << " ]";
17501747 }
17511748 }
1752 if (isIndirectDebugValue())
1753 OS << " indirect";
17541749 } else if (!debugLoc.isUnknown() && MF) {
17551750 if (!HaveSemi) OS << ";";
17561751 OS << " dbg:";
298298 LiveDbgValueMap[LRI->VirtReg];
299299 for (unsigned li = 0, le = LRIDbgValues.size(); li != le; ++li) {
300300 MachineInstr *DBG = LRIDbgValues[li];
301 const MDNode *Var = DBG->getDebugVariable();
302 const MDNode *Expr = DBG->getDebugExpression();
301 const MDNode *MDPtr = DBG->getOperand(2).getMetadata();
303302 bool IsIndirect = DBG->isIndirectDebugValue();
304303 uint64_t Offset = IsIndirect ? DBG->getOperand(1).getImm() : 0;
305304 DebugLoc DL;
311310 DL = MI->getDebugLoc();
312311 MachineInstr *NewDV =
313312 BuildMI(*MBB, MI, DL, TII->get(TargetOpcode::DBG_VALUE))
314 .addFrameIndex(FI)
315 .addImm(Offset)
316 .addMetadata(Var)
317 .addMetadata(Expr);
313 .addFrameIndex(FI).addImm(Offset).addMetadata(MDPtr);
318314 assert(NewDV->getParent() == MBB && "dangling parent pointer");
319315 (void)NewDV;
320316 DEBUG(dbgs() << "Inserting debug info due to spill:" << "\n" << *NewDV);
866862 // Modify DBG_VALUE now that the value is in a spill slot.
867863 bool IsIndirect = MI->isIndirectDebugValue();
868864 uint64_t Offset = IsIndirect ? MI->getOperand(1).getImm() : 0;
869 const MDNode *Var = MI->getDebugVariable();
870 const MDNode *Expr = MI->getDebugExpression();
865 const MDNode *MDPtr =
866 MI->getOperand(MI->getNumOperands()-1).getMetadata();
871867 DebugLoc DL = MI->getDebugLoc();
872868 MachineBasicBlock *MBB = MI->getParent();
873869 MachineInstr *NewDV = BuildMI(*MBB, MBB->erase(MI), DL,
874870 TII->get(TargetOpcode::DBG_VALUE))
875 .addFrameIndex(SS)
876 .addImm(Offset)
877 .addMetadata(Var)
878 .addMetadata(Expr);
871 .addFrameIndex(SS).addImm(Offset).addMetadata(MDPtr);
879872 DEBUG(dbgs() << "Modifying debug info due to spill:"
880873 << "\t" << *NewDV);
881874 // Scan NewDV operands from the beginning.
11241124 Op->setIsDebug(true);
11251125 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
11261126 TII.get(TargetOpcode::DBG_VALUE), false, Op->getReg(), 0,
1127 DI->getVariable(), DI->getExpression());
1127 DI->getVariable());
11281128 } else
11291129 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
11301130 TII.get(TargetOpcode::DBG_VALUE))
11311131 .addOperand(*Op)
11321132 .addImm(0)
1133 .addMetadata(DI->getVariable())
1134 .addMetadata(DI->getExpression());
1133 .addMetadata(DI->getVariable());
11351134 } else {
11361135 // We can't yet handle anything else here because it would require
11371136 // generating code, thus altering codegen because of debug info.
11501149 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
11511150 .addReg(0U)
11521151 .addImm(DI->getOffset())
1153 .addMetadata(DI->getVariable())
1154 .addMetadata(DI->getExpression());
1152 .addMetadata(DI->getVariable());
11551153 } else if (const auto *CI = dyn_cast(V)) {
11561154 if (CI->getBitWidth() > 64)
11571155 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
11581156 .addCImm(CI)
11591157 .addImm(DI->getOffset())
1160 .addMetadata(DI->getVariable())
1161 .addMetadata(DI->getExpression());
1158 .addMetadata(DI->getVariable());
11621159 else
11631160 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
11641161 .addImm(CI->getZExtValue())
11651162 .addImm(DI->getOffset())
1166 .addMetadata(DI->getVariable())
1167 .addMetadata(DI->getExpression());
1163 .addMetadata(DI->getVariable());
11681164 } else if (const auto *CF = dyn_cast(V)) {
11691165 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II)
11701166 .addFPImm(CF)
11711167 .addImm(DI->getOffset())
1172 .addMetadata(DI->getVariable())
1173 .addMetadata(DI->getExpression());
1168 .addMetadata(DI->getVariable());
11741169 } else if (unsigned Reg = lookUpRegForValue(V)) {
11751170 // FIXME: This does not handle register-indirect values at offset 0.
11761171 bool IsIndirect = DI->getOffset() != 0;
11771172 BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II, IsIndirect, Reg,
1178 DI->getOffset(), DI->getVariable(), DI->getExpression());
1173 DI->getOffset(), DI->getVariable());
11791174 } else {
11801175 // We can't yet handle anything else here because it would require
11811176 // generating code, thus altering codegen because of debug info.
21852180 }
21862181
21872182 return Predicate;
2188 }
2183 }
196196 StaticAllocaMap.find(AI);
197197 if (SI != StaticAllocaMap.end()) { // Check for VLAs.
198198 int FI = SI->second;
199 MMI.setVariableDbgInfo(DI->getVariable(), DI->getExpression(),
199 MMI.setVariableDbgInfo(DI->getVariable(),
200200 FI, DI->getDebugLoc());
201201 }
202202 }
648648 InstrEmitter::EmitDbgValue(SDDbgValue *SD,
649649 DenseMap &VRBaseMap) {
650650 uint64_t Offset = SD->getOffset();
651 MDNode *Var = SD->getVariable();
652 MDNode *Expr = SD->getExpression();
651 MDNode* MDPtr = SD->getMDPtr();
653652 DebugLoc DL = SD->getDebugLoc();
654653
655654 if (SD->getKind() == SDDbgValue::FRAMEIX) {
656655 // Stack address; this needs to be lowered in target-dependent fashion.
657656 // EmitTargetCodeForFrameDebugValue is responsible for allocation.
658657 return BuildMI(*MF, DL, TII->get(TargetOpcode::DBG_VALUE))
659 .addFrameIndex(SD->getFrameIx())
660 .addImm(Offset)
661 .addMetadata(Var)
662 .addMetadata(Expr);
658 .addFrameIndex(SD->getFrameIx()).addImm(Offset).addMetadata(MDPtr);
663659 }
664660 // Otherwise, we're going to create an instruction here.
665661 const MCInstrDesc &II = TII->get(TargetOpcode::DBG_VALUE);
705701 MIB.addReg(0U, RegState::Debug);
706702 }
707703
708 MIB.addMetadata(Var);
709 MIB.addMetadata(Expr);
704 MIB.addMetadata(MDPtr);
710705
711706 return &*MIB;
712707 }
4343 const Value *Const; // valid for constants
4444 unsigned FrameIx; // valid for stack objects
4545 } u;
46 MDNode *Var;
47 MDNode *Expr;
46 MDNode *mdPtr;
4847 bool IsIndirect;
4948 uint64_t Offset;
5049 DebugLoc DL;
5251 bool Invalid;
5352 public:
5453 // Constructor for non-constants.
55 SDDbgValue(MDNode *Var, MDNode *Expr, SDNode *N, unsigned R, bool indir,
56 uint64_t off, DebugLoc dl, unsigned O)
57 : Var(Var), Expr(Expr), IsIndirect(indir), Offset(off), DL(dl), Order(O),
58 Invalid(false) {
54 SDDbgValue(MDNode *mdP, SDNode *N, unsigned R,
55 bool indir, uint64_t off, DebugLoc dl,
56 unsigned O) : mdPtr(mdP), IsIndirect(indir),
57 Offset(off), DL(dl), Order(O),
58 Invalid(false) {
5959 kind = SDNODE;
6060 u.s.Node = N;
6161 u.s.ResNo = R;
6262 }
6363
6464 // Constructor for constants.
65 SDDbgValue(MDNode *Var, MDNode *Expr, const Value *C, uint64_t off,
66 DebugLoc dl, unsigned O)
67 : Var(Var), Expr(Expr), IsIndirect(false), Offset(off), DL(dl), Order(O),
68 Invalid(false) {
65 SDDbgValue(MDNode *mdP, const Value *C, uint64_t off, DebugLoc dl,
66 unsigned O) :
67 mdPtr(mdP), IsIndirect(false), Offset(off), DL(dl), Order(O),
68 Invalid(false) {
6969 kind = CONST;
7070 u.Const = C;
7171 }
7272
7373 // Constructor for frame indices.
74 SDDbgValue(MDNode *Var, MDNode *Expr, unsigned FI, uint64_t off, DebugLoc dl,
75 unsigned O)
76 : Var(Var), Expr(Expr), IsIndirect(false), Offset(off), DL(dl), Order(O),
77 Invalid(false) {
74 SDDbgValue(MDNode *mdP, unsigned FI, uint64_t off, DebugLoc dl, unsigned O) :
75 mdPtr(mdP), IsIndirect(false), Offset(off), DL(dl), Order(O),
76 Invalid(false) {
7877 kind = FRAMEIX;
7978 u.FrameIx = FI;
8079 }
8281 // Returns the kind.
8382 DbgValueKind getKind() { return kind; }
8483
85 // Returns the MDNode pointer for the variable.
86 MDNode *getVariable() { return Var; }
87
88 // Returns the MDNode pointer for the expression.
89 MDNode *getExpression() { return Expr; }
84 // Returns the MDNode pointer.
85 MDNode *getMDPtr() { return mdPtr; }
9086
9187 // Returns the SDNode* for a register ref
9288 SDNode *getSDNode() { assert (kind==SDNODE); return u.s.Node; }
57635763 /// getDbgValue - Creates a SDDbgValue node.
57645764 ///
57655765 /// SDNode
5766 SDDbgValue *SelectionDAG::getDbgValue(MDNode *Var, MDNode *Expr, SDNode *N,
5767 unsigned R, bool IsIndirect, uint64_t Off,
5768 DebugLoc DL, unsigned O) {
5769 return new (Allocator) SDDbgValue(Var, Expr, N, R, IsIndirect, Off, DL, O);
5766 SDDbgValue *
5767 SelectionDAG::getDbgValue(MDNode *MDPtr, SDNode *N, unsigned R,
5768 bool IsIndirect, uint64_t Off,
5769 DebugLoc DL, unsigned O) {
5770 return new (Allocator) SDDbgValue(MDPtr, N, R, IsIndirect, Off, DL, O);
57705771 }
57715772
57725773 /// Constant
5773 SDDbgValue *SelectionDAG::getConstantDbgValue(MDNode *Var, MDNode *Expr,
5774 const Value *C, uint64_t Off,
5775 DebugLoc DL, unsigned O) {
5776 return new (Allocator) SDDbgValue(Var, Expr, C, Off, DL, O);
5774 SDDbgValue *
5775 SelectionDAG::getConstantDbgValue(MDNode *MDPtr, const Value *C,
5776 uint64_t Off,
5777 DebugLoc DL, unsigned O) {
5778 return new (Allocator) SDDbgValue(MDPtr, C, Off, DL, O);
57775779 }
57785780
57795781 /// FrameIndex
5780 SDDbgValue *SelectionDAG::getFrameIndexDbgValue(MDNode *Var, MDNode *Expr,
5781 unsigned FI, uint64_t Off,
5782 DebugLoc DL, unsigned O) {
5783 return new (Allocator) SDDbgValue(Var, Expr, FI, Off, DL, O);
5782 SDDbgValue *
5783 SelectionDAG::getFrameIndexDbgValue(MDNode *MDPtr, unsigned FI, uint64_t Off,
5784 DebugLoc DL, unsigned O) {
5785 return new (Allocator) SDDbgValue(MDPtr, FI, Off, DL, O);
57845786 }
57855787
57865788 namespace {
61866188 I != E; ++I) {
61876189 SDDbgValue *Dbg = *I;
61886190 if (Dbg->getKind() == SDDbgValue::SDNODE) {
6189 SDDbgValue *Clone =
6190 getDbgValue(Dbg->getVariable(), Dbg->getExpression(), ToNode,
6191 To.getResNo(), Dbg->isIndirect(), Dbg->getOffset(),
6192 Dbg->getDebugLoc(), Dbg->getOrder());
6191 SDDbgValue *Clone = getDbgValue(Dbg->getMDPtr(), ToNode, To.getResNo(),
6192 Dbg->isIndirect(),
6193 Dbg->getOffset(), Dbg->getDebugLoc(),
6194 Dbg->getOrder());
61936195 ClonedDVs.push_back(Clone);
61946196 }
61956197 }
992992 DebugLoc dl = DDI.getdl();
993993 unsigned DbgSDNodeOrder = DDI.getSDNodeOrder();
994994 MDNode *Variable = DI->getVariable();
995 MDNode *Expr = DI->getExpression();
996995 uint64_t Offset = DI->getOffset();
997996 // A dbg.value for an alloca is always indirect.
998997 bool IsIndirect = isa(V) || Offset != 0;
999998 SDDbgValue *SDV;
1000999 if (Val.getNode()) {
1001 if (!EmitFuncArgumentDbgValue(V, Variable, Expr, Offset, IsIndirect,
1002 Val)) {
1003 SDV = DAG.getDbgValue(Variable, Expr, Val.getNode(), Val.getResNo(),
1004 IsIndirect, Offset, dl, DbgSDNodeOrder);
1000 if (!EmitFuncArgumentDbgValue(V, Variable, Offset, IsIndirect, Val)) {
1001 SDV = DAG.getDbgValue(Variable, Val.getNode(),
1002 Val.getResNo(), IsIndirect,
1003 Offset, dl, DbgSDNodeOrder);
10051004 DAG.AddDbgValue(SDV, Val.getNode(), false);
10061005 }
10071006 } else
46034602 /// EmitFuncArgumentDbgValue - If the DbgValueInst is a dbg_value of a function
46044603 /// argument, create the corresponding DBG_VALUE machine instruction for it now.
46054604 /// At the end of instruction selection, they will be inserted to the entry BB.
4606 bool SelectionDAGBuilder::EmitFuncArgumentDbgValue(const Value *V,
4607 MDNode *Variable,
4608 MDNode *Expr, int64_t Offset,
4609 bool IsIndirect,
4610 const SDValue &N) {
4605 bool
4606 SelectionDAGBuilder::EmitFuncArgumentDbgValue(const Value *V, MDNode *Variable,
4607 int64_t Offset, bool IsIndirect,
4608 const SDValue &N) {
46114609 const Argument *Arg = dyn_cast(V);
46124610 if (!Arg)
46134611 return false;
46594657 return false;
46604658
46614659 if (Op->isReg())
4662 FuncInfo.ArgDbgValues.push_back(
4663 BuildMI(MF, getCurDebugLoc(), TII->get(TargetOpcode::DBG_VALUE),
4664 IsIndirect, Op->getReg(), Offset, Variable, Expr));
4660 FuncInfo.ArgDbgValues.push_back(BuildMI(MF, getCurDebugLoc(),
4661 TII->get(TargetOpcode::DBG_VALUE),
4662 IsIndirect,
4663 Op->getReg(), Offset, Variable));
46654664 else
46664665 FuncInfo.ArgDbgValues.push_back(
4667 BuildMI(MF, getCurDebugLoc(), TII->get(TargetOpcode::DBG_VALUE))
4668 .addOperand(*Op)
4669 .addImm(Offset)
4670 .addMetadata(Variable)
4671 .addMetadata(Expr));
4666 BuildMI(MF, getCurDebugLoc(), TII->get(TargetOpcode::DBG_VALUE))
4667 .addOperand(*Op).addImm(Offset).addMetadata(Variable));
46724668
46734669 return true;
46744670 }
47884784 case Intrinsic::dbg_declare: {
47894785 const DbgDeclareInst &DI = cast(I);
47904786 MDNode *Variable = DI.getVariable();
4791 MDNode *Expression = DI.getExpression();
47924787 const Value *Address = DI.getAddress();
47934788 DIVariable DIVar(Variable);
47944789 assert((!DIVar || DIVar.isVariable()) &&
48244819 FrameIndexSDNode *FINode = dyn_cast(N.getNode());
48254820 if (FINode)
48264821 // Byval parameter. We have a frame index at this point.
4827 SDV = DAG.getFrameIndexDbgValue(
4828 Variable, Expression, FINode->getIndex(), 0, dl, SDNodeOrder);
4822 SDV = DAG.getFrameIndexDbgValue(Variable, FINode->getIndex(),
4823 0, dl, SDNodeOrder);
48294824 else {
48304825 // Address is an argument, so try to emit its dbg value using
48314826 // virtual register info from the FuncInfo.ValueMap.
4832 EmitFuncArgumentDbgValue(Address, Variable, Expression, 0, false, N);
4827 EmitFuncArgumentDbgValue(Address, Variable, 0, false, N);
48334828 return nullptr;
48344829 }
48354830 } else if (AI)
4836 SDV = DAG.getDbgValue(Variable, Expression, N.getNode(), N.getResNo(),
4831 SDV = DAG.getDbgValue(Variable, N.getNode(), N.getResNo(),
48374832 true, 0, dl, SDNodeOrder);
48384833 else {
48394834 // Can't do anything with other non-AI cases yet.
48464841 } else {
48474842 // If Address is an argument then try to emit its dbg value using
48484843 // virtual register info from the FuncInfo.ValueMap.
4849 if (!EmitFuncArgumentDbgValue(Address, Variable, Expression, 0, false,
4850 N)) {
4844 if (!EmitFuncArgumentDbgValue(Address, Variable, 0, false, N)) {
48514845 // If variable is pinned by a alloca in dominating bb then
48524846 // use StaticAllocaMap.
48534847 if (const AllocaInst *AI = dyn_cast(Address)) {
48554849 DenseMap::iterator SI =
48564850 FuncInfo.StaticAllocaMap.find(AI);
48574851 if (SI != FuncInfo.StaticAllocaMap.end()) {
4858 SDV = DAG.getFrameIndexDbgValue(Variable, Expression, SI->second,
4852 SDV = DAG.getFrameIndexDbgValue(Variable, SI->second,
48594853 0, dl, SDNodeOrder);
48604854 DAG.AddDbgValue(SDV, nullptr, false);
48614855 return nullptr;
48764870 return nullptr;
48774871
48784872 MDNode *Variable = DI.getVariable();
4879 MDNode *Expression = DI.getExpression();
48804873 uint64_t Offset = DI.getOffset();
48814874 const Value *V = DI.getValue();
48824875 if (!V)
48844877
48854878 SDDbgValue *SDV;
48864879 if (isa(V) || isa(V) || isa(V)) {
4887 SDV = DAG.getConstantDbgValue(Variable, Expression, V, Offset, dl,
4888 SDNodeOrder);
4880 SDV = DAG.getConstantDbgValue(Variable, V, Offset, dl, SDNodeOrder);
48894881 DAG.AddDbgValue(SDV, nullptr, false);
48904882 } else {
48914883 // Do not use getValue() in here; we don't want to generate code at
48974889 if (N.getNode()) {
48984890 // A dbg.value for an alloca is always indirect.
48994891 bool IsIndirect = isa(V) || Offset != 0;
4900 if (!EmitFuncArgumentDbgValue(V, Variable, Expression, Offset,
4901 IsIndirect, N)) {
4902 SDV = DAG.getDbgValue(Variable, Expression, N.getNode(), N.getResNo(),
4903 IsIndirect, Offset, dl, SDNodeOrder);
4892 if (!EmitFuncArgumentDbgValue(V, Variable, Offset, IsIndirect, N)) {
4893 SDV = DAG.getDbgValue(Variable, N.getNode(),
4894 N.getResNo(), IsIndirect,
4895 Offset, dl, SDNodeOrder);
49044896 DAG.AddDbgValue(SDV, N.getNode(), false);
49054897 }
49064898 } else if (!V->use_empty() ) {
790790 /// EmitFuncArgumentDbgValue - If V is an function argument then create
791791 /// corresponding DBG_VALUE machine instruction for it now. At the end of
792792 /// instruction selection, they will be inserted to the entry BB.
793 bool EmitFuncArgumentDbgValue(const Value *V, MDNode *Variable, MDNode *Expr,
793 bool EmitFuncArgumentDbgValue(const Value *V, MDNode *Variable,
794794 int64_t Offset, bool IsIndirect,
795795 const SDValue &N);
796796 };
485485 "- add if needed");
486486 MachineInstr *Def = RegInfo->getVRegDef(LDI->second);
487487 MachineBasicBlock::iterator InsertPos = Def;
488 const MDNode *Variable = MI->getDebugVariable();
489 const MDNode *Expr = MI->getDebugExpression();
488 const MDNode *Variable =
489 MI->getOperand(MI->getNumOperands()-1).getMetadata();
490490 bool IsIndirect = MI->isIndirectDebugValue();
491491 unsigned Offset = IsIndirect ? MI->getOperand(1).getImm() : 0;
492492 // Def is never a terminator here, so it is ok to increment InsertPos.
493493 BuildMI(*EntryMBB, ++InsertPos, MI->getDebugLoc(),
494 TII.get(TargetOpcode::DBG_VALUE), IsIndirect, LDI->second, Offset,
495 Variable, Expr);
494 TII.get(TargetOpcode::DBG_VALUE),
495 IsIndirect,
496 LDI->second, Offset, Variable);
496497
497498 // If this vreg is directly copied into an exported register then
498499 // that COPY instructions also need DBG_VALUE, if it is the only
511512 }
512513 if (CopyUseMI) {
513514 MachineInstr *NewMI =
514 BuildMI(*MF, CopyUseMI->getDebugLoc(),
515 TII.get(TargetOpcode::DBG_VALUE), IsIndirect,
516 CopyUseMI->getOperand(0).getReg(), Offset, Variable, Expr);
515 BuildMI(*MF, CopyUseMI->getDebugLoc(),
516 TII.get(TargetOpcode::DBG_VALUE),
517 IsIndirect,
518 CopyUseMI->getOperand(0).getReg(),
519 Offset, Variable);
517520 MachineBasicBlock::iterator Pos = CopyUseMI;
518521 EntryMBB->insertAfter(Pos, NewMI);
519522 }
1616 #include "llvm/IR/Constants.h"
1717 #include "llvm/IR/DebugInfo.h"
1818 #include "llvm/IR/DiagnosticInfo.h"
19 #include "llvm/IR/DIBuilder.h"
2019 #include "llvm/IR/Function.h"
2120 #include "llvm/IR/IRBuilder.h"
2221 #include "llvm/IR/Instruction.h"
106105 }
107106 break;
108107 }
109 case 'd': {
110 if (Name.startswith("dbg.declare") && F->arg_size() == 2) {
111 F->setName(Name + ".old");
112 NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::dbg_declare);
113 return true;
114 }
115 if (Name.startswith("dbg.value") && F->arg_size() == 3) {
116 F->setName(Name + ".old");
117 NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::dbg_value);
118 return true;
119 }
120 break;
121 }
122
123108 case 'o':
124109 // We only need to change the name to match the mangling including the
125110 // address space.
251236 bool llvm::UpgradeGlobalVariable(GlobalVariable *GV) {
252237 // Nothing to do yet.
253238 return false;
254 }
255
256 static MDNode *getNodeField(const MDNode *DbgNode, unsigned Elt) {
257 if (!DbgNode || Elt >= DbgNode->getNumOperands())
258 return nullptr;
259 return dyn_cast_or_null(DbgNode->getOperand(Elt));
260 }
261
262 static DIExpression getExpression(Value *VarOperand, Function *F) {
263 // Old-style DIVariables have an optional expression as the 8th element.
264 DIExpression Expr(getNodeField(cast(VarOperand), 8));
265 if (!Expr) {
266 DIBuilder DIB(*F->getParent());
267 Expr = DIB.createExpression();
268 }
269 return Expr;
270239 }
271240
272241 // UpgradeIntrinsicCall - Upgrade a call to an old intrinsic to be a call the
432401 }
433402
434403 std::string Name = CI->getName().str();
435 if (!Name.empty())
436 CI->setName(Name + ".old");
404 CI->setName(Name + ".old");
437405
438406 switch (NewFn->getIntrinsicID()) {
439407 default:
440408 llvm_unreachable("Unknown function for CallInst upgrade.");
441409
442 // Upgrade debug intrinsics to use an additional DIExpression argument.
443 case Intrinsic::dbg_declare: {
444 auto NewCI =
445 Builder.CreateCall3(NewFn, CI->getArgOperand(0), CI->getArgOperand(1),
446 getExpression(CI->getArgOperand(1), F), Name);
447 NewCI->setDebugLoc(CI->getDebugLoc());
448 CI->replaceAllUsesWith(NewCI);
449 CI->eraseFromParent();
450 return;
451 }
452 case Intrinsic::dbg_value: {
453 auto NewCI = Builder.CreateCall4(
454 NewFn, CI->getArgOperand(0), CI->getArgOperand(1), CI->getArgOperand(2),
455 getExpression(CI->getArgOperand(2), F), Name);
456 NewCI->setDebugLoc(CI->getDebugLoc());
457 CI->replaceAllUsesWith(NewCI);
458 CI->eraseFromParent();
459 return;
460 }
461410 case Intrinsic::ctlz:
462411 case Intrinsic::cttz:
463412 assert(CI->getNumArgOperands() == 1 &&
10411041 return RetVar;
10421042 }
10431043
1044 /// createExpression - Create a new descriptor for the specified
1045 /// variable which has a complex address expression for its address.
1046 /// @param Addr An array of complex address operations.
1047 DIExpression DIBuilder::createExpression(ArrayRef Addr) {
1048 SmallVector Elts;
1049 Elts.push_back(GetTagConstant(VMContext, DW_TAG_expression));
1050 Elts.insert(Elts.end(), Addr.begin(), Addr.end());
1051 return DIExpression(MDNode::get(VMContext, Elts));
1044 /// createComplexVariable - Create a new descriptor for the specified variable
1045 /// which has a complex address expression for its address.
1046 DIVariable DIBuilder::createComplexVariable(unsigned Tag, DIDescriptor Scope,
1047 StringRef Name, DIFile F,
1048 unsigned LineNo,
1049 DITypeRef Ty,
1050 ArrayRef Addr,
1051 unsigned ArgNo) {
1052 assert(Addr.size() > 0 && "complex address is empty");
1053 Value *Elts[] = {
1054 GetTagConstant(VMContext, Tag),
1055 getNonCompileUnitScope(Scope),
1056 MDString::get(VMContext, Name),
1057 F,
1058 ConstantInt::get(Type::getInt32Ty(VMContext),
1059 (LineNo | (ArgNo << 24))),
1060 Ty,
1061 Constant::getNullValue(Type::getInt32Ty(VMContext)),
1062 Constant::getNullValue(Type::getInt32Ty(VMContext)),
1063 MDNode::get(VMContext, Addr)
1064 };
1065 return DIVariable(MDNode::get(VMContext, Elts));
10521066 }
10531067
10541068 /// createVariablePiece - Create a descriptor to describe one part
10551069 /// of aggregate variable that is fragmented across multiple Values.
1056 DIExpression DIBuilder::createPieceExpression(unsigned OffsetInBytes,
1057 unsigned SizeInBytes) {
1070 DIVariable DIBuilder::createVariablePiece(DIVariable Variable,
1071 unsigned OffsetInBytes,
1072 unsigned SizeInBytes) {
10581073 assert(SizeInBytes > 0 && "zero-size piece");
10591074 Value *Addr[] = {
1060 GetTagConstant(VMContext, DW_TAG_expression),
1061 ConstantInt::get(Type::getInt64Ty(VMContext), dwarf::DW_OP_piece),
1062 ConstantInt::get(Type::getInt64Ty(VMContext), OffsetInBytes),
1063 ConstantInt::get(Type::getInt64Ty(VMContext), SizeInBytes)};
1064
1065 return DIExpression(MDNode::get(VMContext, Addr));
1075 ConstantInt::get(Type::getInt32Ty(VMContext), OpPiece),
1076 ConstantInt::get(Type::getInt32Ty(VMContext), OffsetInBytes),
1077 ConstantInt::get(Type::getInt32Ty(VMContext), SizeInBytes)
1078 };
1079
1080 assert((Variable->getNumOperands() == 8 || Variable.isVariablePiece()) &&
1081 "variable already has a complex address");
1082 SmallVector Elts;
1083 for (unsigned i = 0; i < 8; ++i)
1084 Elts.push_back(Variable->getOperand(i));
1085
1086 Elts.push_back(MDNode::get(VMContext, Addr));
1087 return DIVariable(MDNode::get(VMContext, Elts));
10661088 }
10671089
10681090 /// createFunction - Create a new descriptor for the specified function.
12691291
12701292 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
12711293 Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
1272 DIExpression Expr,
12731294 Instruction *InsertBefore) {
12741295 assert(Storage && "no storage passed to dbg.declare");
12751296 assert(VarInfo.isVariable() &&
12771298 if (!DeclareFn)
12781299 DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
12791300
1280 Value *Args[] = {MDNode::get(Storage->getContext(), Storage), VarInfo, Expr};
1301 Value *Args[] = { MDNode::get(Storage->getContext(), Storage), VarInfo };
12811302 return CallInst::Create(DeclareFn, Args, "", InsertBefore);
12821303 }
12831304
12841305 /// insertDeclare - Insert a new llvm.dbg.declare intrinsic call.
12851306 Instruction *DIBuilder::insertDeclare(Value *Storage, DIVariable VarInfo,
1286 DIExpression Expr,
12871307 BasicBlock *InsertAtEnd) {
12881308 assert(Storage && "no storage passed to dbg.declare");
12891309 assert(VarInfo.isVariable() &&
12911311 if (!DeclareFn)
12921312 DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare);
12931313
1294 Value *Args[] = {MDNode::get(Storage->getContext(), Storage), VarInfo, Expr};
1314 Value *Args[] = { MDNode::get(Storage->getContext(), Storage), VarInfo };
12951315
12961316 // If this block already has a terminator then insert this intrinsic
12971317 // before the terminator.
13041324 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
13051325 Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
13061326 DIVariable VarInfo,
1307 DIExpression Expr,
13081327 Instruction *InsertBefore) {
13091328 assert(V && "no value passed to dbg.value");
13101329 assert(VarInfo.isVariable() &&
13121331 if (!ValueFn)
13131332 ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
13141333
1315 Value *Args[] = {MDNode::get(V->getContext(), V),
1316 ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
1317 VarInfo, Expr};
1334 Value *Args[] = { MDNode::get(V->getContext(), V),
1335 ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
1336 VarInfo };
13181337 return CallInst::Create(ValueFn, Args, "", InsertBefore);
13191338 }
13201339
13211340 /// insertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
13221341 Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset,
13231342 DIVariable VarInfo,
1324 DIExpression Expr,
13251343 BasicBlock *InsertAtEnd) {
13261344 assert(V && "no value passed to dbg.value");
13271345 assert(VarInfo.isVariable() &&
13291347 if (!ValueFn)
13301348 ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);
13311349
1332 Value *Args[] = {MDNode::get(V->getContext(), V),
1333 ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
1334 VarInfo, Expr};
1350 Value *Args[] = { MDNode::get(V->getContext(), V),
1351 ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
1352 VarInfo };
13351353 return CallInst::Create(ValueFn, Args, "", InsertAtEnd);
13361354 }
4848 DIObjCProperty(DbgNode).Verify() ||
4949 DITemplateTypeParameter(DbgNode).Verify() ||
5050 DITemplateValueParameter(DbgNode).Verify() ||
51 DIImportedEntity(DbgNode).Verify() || DIExpression(DbgNode).Verify());
51 DIImportedEntity(DbgNode).Verify());
5252 }
5353
5454 static Value *getField(const MDNode *DbgNode, unsigned Elt) {
137137 }
138138 }
139139
140 uint64_t DIVariable::getAddrElement(unsigned Idx) const {
141 DIDescriptor ComplexExpr = getDescriptorField(8);
142 if (Idx < ComplexExpr->getNumOperands())
143 if (auto *CI = dyn_cast_or_null(ComplexExpr->getOperand(Idx)))
144 return CI->getZExtValue();
145
146 assert(false && "non-existing complex address element requested");
147 return 0;
148 }
149
140150 /// getInlinedAt - If this variable is inlined then return inline location.
141151 MDNode *DIVariable::getInlinedAt() const { return getNodeField(DbgNode, 7); }
152
153 bool DIVariable::isVariablePiece() const {
154 return hasComplexAddress() && getAddrElement(0) == DIBuilder::OpPiece;
155 }
156
157 uint64_t DIVariable::getPieceOffset() const {
158 assert(isVariablePiece());
159 return getAddrElement(1);
160 }
161
162 uint64_t DIVariable::getPieceSize() const {
163 assert(isVariablePiece());
164 return getAddrElement(2);
165 }
142166
143167 /// Return the size reported by the variable's type.
144168 unsigned DIVariable::getSizeInBits(const DITypeIdentifierMap &Map) {
153177 return Ty.getSizeInBits();
154178 }
155179
156 uint64_t DIExpression::getElement(unsigned Idx) const {
157 unsigned I = Idx + 1;
158 if (I < DbgNode->getNumOperands())
159 if (auto *CI = dyn_cast_or_null(DbgNode->getOperand(I)))
160 return CI->getZExtValue();
161
162 assert(false && "non-existing complex address element requested");
163 return 0;
164 }
165
166 bool DIExpression::isVariablePiece() const {
167 return getNumElements() && getElement(0) == dwarf::DW_OP_piece;
168 }
169
170 uint64_t DIExpression::getPieceOffset() const {
171 assert(isVariablePiece());
172 return getElement(1);
173 }
174
175 uint64_t DIExpression::getPieceSize() const {
176 assert(isVariablePiece());
177 return getElement(2);
178 }
180
181
179182
180183 //===----------------------------------------------------------------------===//
181184 // Predicates
353356 getTag() == dwarf::DW_TAG_imported_declaration);
354357 }
355358
356 /// \brief Return true if the specified tag is DW_TAG_imported_module or
357 /// DW_TAG_imported_declaration.
358 bool DIDescriptor::isExpression() const {
359 return DbgNode && (getTag() == dwarf::DW_TAG_expression);
360 }
361
362359 //===----------------------------------------------------------------------===//
363360 // Simple Descriptor Constructors and other Methods
364361 //===----------------------------------------------------------------------===//
598595 if (!fieldIsTypeRef(DbgNode, 5))
599596 return false;
600597
601 // Variable without an inline location.
602 if (DbgNode->getNumOperands() == 7)
598 // Variable without a complex expression.
599 if (DbgNode->getNumOperands() == 8)
603600 return true;
604601
605 return DbgNode->getNumOperands() == 8;
606 }
607
608 /// Verify - Verify that a variable descriptor is well formed.
609 bool DIExpression::Verify() const { return isExpression(); }
602 // Make sure the complex expression is an MDNode.
603 return (DbgNode->getNumOperands() == 9 && fieldIsMDNode(DbgNode, 8));
604 }
610605
611606 /// Verify - Verify that a location descriptor is well formed.
612607 bool DILocation::Verify() const {
938933 i == 7 ? Elts.push_back(Constant::getNullValue(Type::getInt32Ty(VMContext)))
939934 : Elts.push_back(DV->getOperand(i));
940935 return DIVariable(MDNode::get(VMContext, Elts));
936 }
937
938
939 /// getEntireVariable - Remove OpPiece exprs from the variable.
940 DIVariable llvm::getEntireVariable(DIVariable DV) {
941 if (!DV.isVariablePiece())
942 return DV;
943
944 SmallVector Elts;
945 for (unsigned i = 0; i < 8; ++i)
946 Elts.push_back(DV->getOperand(i));
947
948 return DIVariable(MDNode::get(DV->getContext(), Elts));
941949 }
942950
943951 /// getDISubprogram - Find subprogram that is enclosing this scope.
12841292 DINameSpace(DbgNode).printInternal(OS);
12851293 } else if (this->isScope()) {
12861294 DIScope(DbgNode).printInternal(OS);
1287 } else if (this->isExpression()) {
1288 DIExpression(DbgNode).printInternal(OS);
12891295 }
12901296 }
12911297
14351441 OS << " [" << Res << ']';
14361442
14371443 OS << " [line " << getLineNumber() << ']';
1438 }
1439
1440 void DIExpression::printInternal(raw_ostream &OS) const {
1441 for (unsigned I = 0; I < getNumElements(); ++I) {
1442 uint64_t OpCode = getElement(I);
1443 OS << " [" << OperationEncodingString(OpCode);
1444 switch (OpCode) {
1445 case DW_OP_plus: {
1446 OS << " " << getElement(++I);
1447 break;
1448 }
1449 case DW_OP_piece: {
1450 unsigned Offset = getElement(++I);
1451 unsigned Size = getElement(++I);
1452 OS << " offset=" << Offset << ", size= " << Size;
1453 break;
1454 }
1455 default:
1456 break;
1457 }
1458 OS << "]";
1459 }
1444
1445 if (isVariablePiece())
1446 OS << " [piece, size " << getPieceSize()
1447 << ", offset " << getPieceOffset() << ']';
14601448 }
14611449
14621450 void DIObjCProperty::printInternal(raw_ostream &OS) const {
8181 case DW_TAG_hi_user: return "DW_TAG_hi_user";
8282 case DW_TAG_auto_variable: return "DW_TAG_auto_variable";
8383 case DW_TAG_arg_variable: return "DW_TAG_arg_variable";
84 case DW_TAG_expression:
85 return "DW_TAG_expression";
8684 case DW_TAG_rvalue_reference_type: return "DW_TAG_rvalue_reference_type";
8785 case DW_TAG_template_alias: return "DW_TAG_template_alias";
8886 case DW_TAG_coarray_type: return "DW_TAG_coarray_type";
14431443 }
14441444 }
14451445
1446 MachineInstr *AArch64InstrInfo::emitFrameIndexDebugValue(
1447 MachineFunction &MF, int FrameIx, uint64_t Offset, const MDNode *Var,
1448 const MDNode *Expr, DebugLoc DL) const {
1446 MachineInstr *AArch64InstrInfo::emitFrameIndexDebugValue(MachineFunction &MF,
1447 int FrameIx,
1448 uint64_t Offset,
1449 const MDNode *MDPtr,
1450 DebugLoc DL) const {
14491451 MachineInstrBuilder MIB = BuildMI(MF, DL, get(AArch64::DBG_VALUE))
14501452 .addFrameIndex(FrameIx)
14511453 .addImm(0)
14521454 .addImm(Offset)
1453 .addMetadata(Var)
1454 .addMetadata(Expr);
1455 .addMetadata(MDPtr);
14551456 return &*MIB;
14561457 }
14571458
106106 MachineInstr *Second) const override;
107107
108108 MachineInstr *emitFrameIndexDebugValue(MachineFunction &MF, int FrameIx,
109 uint64_t Offset, const MDNode *Var,
110 const MDNode *Expr, DebugLoc DL) const;
109 uint64_t Offset, const MDNode *MDPtr,
110 DebugLoc DL) const;
111111 void copyPhysRegTuple(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
112112 DebugLoc DL, unsigned DestReg, unsigned SrcReg,
113113 bool KillSrc, unsigned Opcode,
22482248 const MCInstrDesc &II = TII.get(TargetOpcode::DBG_VALUE);
22492249 // FIXME may need to add RegState::Debug to any registers produced,
22502250 // although ESP/EBP should be the only ones at the moment.
2251 addFullAddress(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II), AM)
2252 .addImm(0)
2253 .addMetadata(DI->getVariable())
2254 .addMetadata(DI->getExpression());
2251 addFullAddress(BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc, II), AM).
2252 addImm(0).addMetadata(DI->getVariable());
22552253 return true;
22562254 }
22572255 case Intrinsic::trap: {
890890 continue;
891891 }
892892 Instruction *DbgVal =
893 DIB.insertDbgValueIntrinsic(Arg, 0, DIVariable(DVI->getVariable()),
894 DIExpression(DVI->getExpression()), Inst);
893 DIB.insertDbgValueIntrinsic(Arg, 0, DIVariable(DVI->getVariable()),
894 Inst);
895895 DbgVal->setDebugLoc(DVI->getDebugLoc());
896896 }
897897 }
11231123 } else {
11241124 continue;
11251125 }
1126 Instruction *DbgVal = DIB->insertDbgValueIntrinsic(
1127 Arg, 0, DIVariable(DVI->getVariable()),
1128 DIExpression(DVI->getExpression()), Inst);
1126 Instruction *DbgVal =
1127 DIB->insertDbgValueIntrinsic(Arg, 0, DIVariable(DVI->getVariable()),
1128 Inst);
11291129 DbgVal->setDebugLoc(DVI->getDebugLoc());
11301130 }
11311131 }
992992 bool llvm::ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI,
993993 StoreInst *SI, DIBuilder &Builder) {
994994 DIVariable DIVar(DDI->getVariable());
995 DIExpression DIExpr(DDI->getExpression());
996995 assert((!DIVar || DIVar.isVariable()) &&
997996 "Variable in DbgDeclareInst should be either null or a DIVariable.");
998997 if (!DIVar)
10101009 if (SExtInst *SExt = dyn_cast(SI->getOperand(0)))
10111010 ExtendedArg = dyn_cast(SExt->getOperand(0));
10121011 if (ExtendedArg)
1013 DbgVal = Builder.insertDbgValueIntrinsic(ExtendedArg, 0, DIVar, DIExpr, SI);
1012 DbgVal = Builder.insertDbgValueIntrinsic(ExtendedArg, 0, DIVar, SI);
10141013 else
1015 DbgVal = Builder.insertDbgValueIntrinsic(SI->getOperand(0), 0, DIVar,
1016 DIExpr, SI);
1014 DbgVal = Builder.insertDbgValueIntrinsic(SI->getOperand(0), 0, DIVar, SI);
10171015 DbgVal->setDebugLoc(DDI->getDebugLoc());
10181016 return true;
10191017 }
10231021 bool llvm::ConvertDebugDeclareToDebugValue(DbgDeclareInst *DDI,
10241022 LoadInst *LI, DIBuilder &Builder) {
10251023 DIVariable DIVar(DDI->getVariable());
1026 DIExpression DIExpr(DDI->getExpression());
10271024 assert((!DIVar || DIVar.isVariable()) &&
10281025 "Variable in DbgDeclareInst should be either null or a DIVariable.");
10291026 if (!DIVar)
10331030 return true;
10341031
10351032 Instruction *DbgVal =
1036 Builder.insertDbgValueIntrinsic(LI->getOperand(0), 0, DIVar, DIExpr, LI);
1033 Builder.insertDbgValueIntrinsic(LI->getOperand(0), 0,
1034 DIVar, LI);
10371035 DbgVal->setDebugLoc(DDI->getDebugLoc());
10381036 return true;
10391037 }
10761074 // This is a call by-value or some other instruction that
10771075 // takes a pointer to the variable. Insert a *value*
10781076 // intrinsic that describes the alloca.
1079 auto DbgVal = DIB.insertDbgValueIntrinsic(
1080 AI, 0, DIVariable(DDI->getVariable()),
1081 DIExpression(DDI->getExpression()), CI);
1082 DbgVal->setDebugLoc(DDI->getDebugLoc());
1083 }
1077 auto DbgVal =
1078 DIB.insertDbgValueIntrinsic(AI, 0,
1079 DIVariable(DDI->getVariable()), CI);
1080 DbgVal->setDebugLoc(DDI->getDebugLoc());
1081 }
10841082 DDI->eraseFromParent();
10851083 }
10861084 }
11041102 if (!DDI)
11051103 return false;
11061104 DIVariable DIVar(DDI->getVariable());
1107 DIExpression DIExpr(DDI->getExpression());
11081105 assert((!DIVar || DIVar.isVariable()) &&
11091106 "Variable in DbgDeclareInst should be either null or a DIVariable.");
11101107 if (!DIVar)
11151112 // will take a value storing address of the memory for variable, not
11161113 // alloca itself.
11171114 Type *Int64Ty = Type::getInt64Ty(AI->getContext());
1118 SmallVector NewDIExpr;
1119 if (DIExpr) {
1120 for (unsigned i = 0, n = DIExpr.getNumElements(); i < n; ++i) {
1121 NewDIExpr.push_back(ConstantInt::get(Int64Ty, DIExpr.getElement(i)));
1122 }
1123 }
1124 NewDIExpr.push_back(ConstantInt::get(Int64Ty, dwarf::DW_OP_deref));
1115 SmallVector NewDIVarAddress;
1116 if (DIVar.hasComplexAddress()) {
1117 for (unsigned i = 0, n = DIVar.getNumAddrElements(); i < n; ++i) {
1118 NewDIVarAddress.push_back(
1119 ConstantInt::get(Int64Ty, DIVar.getAddrElement(i)));
1120 }
1121 }
1122 NewDIVarAddress.push_back(ConstantInt::get(Int64Ty, DIBuilder::OpDeref));
1123 DIVariable NewDIVar = Builder.createComplexVariable(
1124 DIVar.getTag(), DIVar.getContext(), DIVar.getName(),
1125 DIVar.getFile(), DIVar.getLineNumber(), DIVar.getType(),
1126 NewDIVarAddress, DIVar.getArgNumber());
11251127
11261128 // Insert llvm.dbg.declare in the same basic block as the original alloca,
11271129 // and remove old llvm.dbg.declare.
11281130 BasicBlock *BB = AI->getParent();
1129 Builder.insertDeclare(NewAllocaAddress, DIVar,
1130 Builder.createExpression(NewDIExpr), BB);
1131 Builder.insertDeclare(NewAllocaAddress, NewDIVar, BB);
11311132 DDI->eraseFromParent();
11321133 return true;
11331134 }
2525
2626 define void @bar2(i32* %foo) {
2727 store i32 0, i32* %foo, align 4
28 tail call void @llvm.dbg.value(metadata !{}, i64 0, metadata !{}, metadata !{})
28 tail call void @llvm.dbg.value(metadata !{}, i64 0, metadata !{})
2929 ret void
3030 }
3131
32 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
32 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
1111
1212 define i32 @main() nounwind readonly {
1313 %diff1 = alloca i64 ; [#uses=2]
14 call void @llvm.dbg.declare(metadata !{i64* %diff1}, metadata !0, metadata !{})
14 call void @llvm.dbg.declare(metadata !{i64* %diff1}, metadata !0)
1515 store i64 72, i64* %diff1, align 8
1616 %v1 = load %struct.test** @TestArrayPtr, align 8 ; <%struct.test*> [#uses=1]
1717 %v2 = ptrtoint %struct.test* %v1 to i64 ; [#uses=1]
2020 ret i32 4
2121 }
2222
23 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
23 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
2424
2525 !7 = metadata !{metadata !1}
2626 !6 = metadata !{i32 786449, metadata !8, i32 12, metadata !"clang version 3.0 (trunk 131941)", i1 true, metadata !"", i32 0, metadata !9, metadata !9, metadata !7, null, null, metadata !""} ; [ DW_TAG_compile_unit ]
22
33 define void @Foo(i32 %a, i32 %b) {
44 entry:
5 call void @llvm.dbg.value(metadata !{ i32* %1 }, i64 16, metadata !2, metadata !{})
6 ; CHECK: call void @llvm.dbg.value(metadata !{i32* %1}, i64 16, metadata ![[ID2:[0-9]+]], metadata {{.*}})
5 call void @llvm.dbg.value(metadata !{ i32* %1 }, i64 16, metadata !2)
6 ; CHECK: call void @llvm.dbg.value(metadata !{i32* %1}, i64 16, metadata ![[ID2:[0-9]+]])
77 %0 = add i32 %a, 1 ; [#uses=1]
88 %two = add i32 %b, %0 ; [#uses=0]
99 %1 = alloca i32 ; [#uses=1]
1010
11 call void @llvm.dbg.declare(metadata !{i32* %1}, metadata !{i32* %1}, metadata !{})
12 ; CHECK: call void @llvm.dbg.declare(metadata !{i32* %1}, metadata !{i32* %1}, metadata {{.*}})
13 call void @llvm.dbg.declare(metadata !{i32 %two}, metadata !{i32 %0}, metadata !{})
14 ; CHECK: call void @llvm.dbg.declare(metadata !{i32 %two}, metadata !{i32 %0}, metadata {{.*}})
15 call void @llvm.dbg.declare(metadata !{i32 %0}, metadata !{i32* %1, i32 %0}, metadata !{})
16 ; CHECK: call void @llvm.dbg.declare(metadata !{i32 %0}, metadata !{i32* %1, i32 %0}, metadata {{.*}})
17 call void @llvm.dbg.declare(metadata !{i32* %1}, metadata !{i32 %b, i32 %0}, metadata !{})
18 ; CHECK: call void @llvm.dbg.declare(metadata !{i32* %1}, metadata !{i32 %b, i32 %0}, metadata {{.*}})
19 call void @llvm.dbg.declare(metadata !{i32 %a}, metadata !{i32 %a, metadata !"foo"}, metadata !{})
20 ; CHECK: call void @llvm.dbg.declare(metadata !{i32 %a}, metadata !{i32 %a, metadata !"foo"}, metadata {{.*}})
21 call void @llvm.dbg.declare(metadata !{i32 %b}, metadata !{metadata !0, i32 %two}, metadata !{})
22 ; CHECK: call void @llvm.dbg.declare(metadata !{i32 %b}, metadata !{metadata ![[ID0:[0-9]+]], i32 %two}, metadata {{.*}})
11 call void @llvm.dbg.declare(metadata !{i32* %1}, metadata !{i32* %1})
12 ; CHECK: metadata !{i32* %1}, metadata !{i32* %1}
13 call void @llvm.dbg.declare(metadata !{i32 %two}, metadata !{i32 %0})
14 ; CHECK: metadata !{i32 %two}, metadata !{i32 %0}
15 call void @llvm.dbg.declare(metadata !{i32 %0}, metadata !{i32* %1, i32 %0})
16 ; CHECK: metadata !{i32 %0}, metadata !{i32* %1, i32 %0}
17 call void @llvm.dbg.declare(metadata !{i32* %1}, metadata !{i32 %b, i32 %0})
18 ; CHECK: metadata !{i32* %1}, metadata !{i32 %b, i32 %0}
19 call void @llvm.dbg.declare(metadata !{i32 %a}, metadata !{i32 %a, metadata !"foo"})
20 ; CHECK: metadata !{i32 %a}, metadata !{i32 %a, metadata !"foo"}
21 call void @llvm.dbg.declare(metadata !{i32 %b}, metadata !{metadata !0, i32 %two})
22 ; CHECK: metadata !{i32 %b}, metadata !{metadata ![[ID0:[0-9]+]], i32 %two}
2323
24 call void @llvm.dbg.value(metadata !{ i32 %a }, i64 0, metadata !1, metadata !{})
25 ; CHECK: call void @llvm.dbg.value(metadata !{i32 %a}, i64 0, metadata ![[ID1:[0-9]+]], metadata {{.*}})
26 call void @llvm.dbg.value(metadata !{ i32 %0 }, i64 25, metadata !0, metadata !{})
27 ; CHECK: call void @llvm.dbg.value(metadata !{i32 %0}, i64 25, metadata ![[ID0]], metadata {{.*}})
28 call void @llvm.dbg.value(metadata !{ i32* %1 }, i64 16, metadata !3, metadata !{})
29 ; CHECK: call void @llvm.dbg.value(metadata !{i32* %1}, i64 16, metadata ![[ID3:[0-9]+]], metadata {{.*}})
30 call void @llvm.dbg.value(metadata !3, i64 12, metadata !2, metadata !{})
31 ; CHECK: call void @llvm.dbg.value(metadata ![[ID3]], i64 12, metadata ![[ID2]], metadata {{.*}})
24 call void @llvm.dbg.value(metadata !{ i32 %a }, i64 0, metadata !1)
25 ; CHECK: metadata !{i32 %a}, i64 0, metadata ![[ID1:[0-9]+]]
26 call void @llvm.dbg.value(metadata !{ i32 %0 }, i64 25, metadata !0)
27 ; CHECK: metadata !{i32 %0}, i64 25, metadata ![[ID0]]
28 call void @llvm.dbg.value(metadata !{ i32* %1 }, i64 16, metadata !3)
29 ; CHECK: call void @llvm.dbg.value(metadata !{i32* %1}, i64 16, metadata ![[ID3:[0-9]+]])
30 call void @llvm.dbg.value(metadata !3, i64 12, metadata !2)
31 ; CHECK: metadata ![[ID3]], i64 12, metadata ![[ID2]]
3232
3333 ret void, !foo !0, !bar !1
3434 ; CHECK: ret void, !foo ![[FOO:[0-9]+]], !bar ![[BAR:[0-9]+]]
4242 !3 = metadata !{metadata !"foo"}
4343 !4 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
4444
45 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
46 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
45 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
46 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
4747
4848 !foo = !{ !0 }
4949 !bar = !{ !1 }
1515 %add53 = add nsw i64 %n1, 0, !dbg !52
1616 %add55 = add nsw i64 %n1, 0, !dbg !53
1717 %mul63 = mul nsw i64 %add53, -20995, !dbg !54
18 tail call void @llvm.dbg.value(metadata !{i64 %mul63}, i64 0, metadata !30, metadata !{}), !dbg !55
18 tail call void @llvm.dbg.value(metadata !{i64 %mul63}, i64 0, metadata !30), !dbg !55
1919 %mul65 = mul nsw i64 %add55, -3196, !dbg !56
2020 %add67 = add nsw i64 0, %mul65, !dbg !57
2121 %add80 = add i64 0, 1024, !dbg !58
3434 }
3535
3636 ; Function Attrs: nounwind readnone
37 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
37 declare void @llvm.dbg.value(metadata, i64, metadata) #1
3838
3939 attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
4040 attributes #1 = { nounwind readnone }
1010 unreachable
1111
1212 if.else295: ; preds = %entry
13 call void @llvm.dbg.declare(metadata !{i32* %do_tab_convert}, metadata !16, metadata !{}), !dbg !18
13 call void @llvm.dbg.declare(metadata !{i32* %do_tab_convert}, metadata !16), !dbg !18
1414 store i32 0, i32* %do_tab_convert, align 4, !dbg !19
1515 unreachable
1616 }
1717
18 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
18 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
1919
2020 !llvm.dbg.gv = !{!0}
2121 !llvm.dbg.sp = !{!1, !7, !10, !11, !12}
88 br label %do.body, !dbg !0
99
1010 do.body: ; preds = %entry
11 call void @llvm.dbg.declare(metadata !{i32* %count_}, metadata !4, metadata !{})
11 call void @llvm.dbg.declare(metadata !{i32* %count_}, metadata !4)
1212 %conv = ptrtoint i32* %count_ to i32, !dbg !0 ; [#uses=1]
1313 %call = call i32 @foo(i32 %conv) ssp, !dbg !0 ; [#uses=0]
1414 br label %do.end, !dbg !0
1717 ret void, !dbg !7
1818 }
1919
20 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
20 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
2121
2222 declare i32 @foo(i32) ssp
2323
44
55 define hidden i32 @__addvsi3(i32 %a, i32 %b) nounwind {
66 entry:
7 tail call void @llvm.dbg.value(metadata !{i32 %b}, i64 0, metadata !0, metadata !{})
7 tail call void @llvm.dbg.value(metadata !{i32 %b}, i64 0, metadata !0)
88 %0 = add nsw i32 %b, %a, !dbg !9 ; [#uses=1]
99 ret i32 %0, !dbg !11
1010 }
1111
12 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
12 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
1313
1414 !llvm.dbg.cu = !{!3}
1515 !llvm.module.flags = !{!15}
66
77 define void @x0(i8* nocapture %buf, i32 %nbytes) nounwind optsize {
88 entry:
9 tail call void @llvm.dbg.value(metadata !{i8* %buf}, i64 0, metadata !0, metadata !{}), !dbg !15
10 tail call void @llvm.dbg.value(metadata !{i32 %nbytes}, i64 0, metadata !8, metadata !{}), !dbg !16
9 tail call void @llvm.dbg.value(metadata !{i8* %buf}, i64 0, metadata !0), !dbg !15
10 tail call void @llvm.dbg.value(metadata !{i32 %nbytes}, i64 0, metadata !8), !dbg !16
1111 %tmp = load i32* @length, !dbg !17 ; [#uses=3]
1212 %cmp = icmp eq i32 %tmp, -1, !dbg !17 ; [#uses=1]
1313 %cmp.not = xor i1 %cmp, true ; [#uses=1]
1414 %cmp3 = icmp ult i32 %tmp, %nbytes, !dbg !17 ; [#uses=1]
1515 %or.cond = and i1 %cmp.not, %cmp3 ; [#uses=1]
16 tail call void @llvm.dbg.value(metadata !{i32 %tmp}, i64 0, metadata !8, metadata !{}), !dbg !17
16 tail call void @llvm.dbg.value(metadata !{i32 %tmp}, i64 0, metadata !8), !dbg !17
1717 %nbytes.addr.0 = select i1 %or.cond, i32 %tmp, i32 %nbytes ; [#uses=1]
18 tail call void @llvm.dbg.value(metadata !18, i64 0, metadata !10, metadata !{}), !dbg !19
18 tail call void @llvm.dbg.value(metadata !18, i64 0, metadata !10), !dbg !19
1919 br label %while.cond, !dbg !20
2020
2121 while.cond: ; preds = %while.body, %entry
4141
4242 declare i32 @x1() optsize
4343
44 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
44 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
4545
4646 !llvm.dbg.lv.fn = !{!0, !8, !10, !12}
4747 !llvm.dbg.gv = !{!14}
55 define i32 @_Z3fooi4SVal(i32 %i, %struct.SVal* noalias %location) nounwind ssp {
66 entry:
77 %"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
8 call void @llvm.dbg.value(metadata !{i32 %i}, i64 0, metadata !23, metadata !{}), !dbg !24
9 call void @llvm.dbg.value(metadata !{%struct.SVal* %location}, i64 0, metadata !25, metadata !{}), !dbg !24
8 call void @llvm.dbg.value(metadata !{i32 %i}, i64 0, metadata !23), !dbg !24
9 call void @llvm.dbg.value(metadata !{%struct.SVal* %location}, i64 0, metadata !25), !dbg !24
1010 %0 = icmp ne i32 %i, 0, !dbg !27 ; [#uses=1]
1111 br i1 %0, label %bb, label %bb1, !dbg !27
1212
3333 define linkonce_odr void @_ZN4SValC1Ev(%struct.SVal* %this) nounwind ssp align 2 {
3434 entry:
3535 %"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
36 call void @llvm.dbg.value(metadata !{%struct.SVal* %this}, i64 0, metadata !31, metadata !{}), !dbg !34
36 call void @llvm.dbg.value(metadata !{%struct.SVal* %this}, i64 0, metadata !31), !dbg !34
3737 %0 = getelementptr inbounds %struct.SVal* %this, i32 0, i32 0, !dbg !34 ; [#uses=1]
3838 store i8* null, i8** %0, align 8, !dbg !34
3939 %1 = getelementptr inbounds %struct.SVal* %this, i32 0, i32 1, !dbg !34 ; [#uses=1]
4444 ret void, !dbg !35
4545 }
4646
47 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
47 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
4848
4949 define i32 @main() nounwind ssp {
5050 entry:
5151 %0 = alloca %struct.SVal ; <%struct.SVal*> [#uses=3]
5252 %v = alloca %struct.SVal ; <%struct.SVal*> [#uses=4]
5353 %"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
54 call void @llvm.dbg.declare(metadata !{%struct.SVal* %v}, metadata !38, metadata !{}), !dbg !41
54 call void @llvm.dbg.declare(metadata !{%struct.SVal* %v}, metadata !38), !dbg !41
5555 call void @_ZN4SValC1Ev(%struct.SVal* %v) nounwind, !dbg !41
5656 %1 = getelementptr inbounds %struct.SVal* %v, i32 0, i32 1, !dbg !42 ; [#uses=1]
5757 store i32 1, i32* %1, align 8, !dbg !42
6464 %7 = load i32* %6, align 8, !dbg !43 ; [#uses=1]
6565 store i32 %7, i32* %5, align 8, !dbg !43
6666 %8 = call i32 @_Z3fooi4SVal(i32 2, %struct.SVal* noalias %0) nounwind, !dbg !43 ; [#uses=0]
67 call void @llvm.dbg.value(metadata !{i32 %8}, i64 0, metadata !44, metadata !{}), !dbg !43
67 call void @llvm.dbg.value(metadata !{i32 %8}, i64 0, metadata !44), !dbg !43
6868 br label %return, !dbg !45
6969
7070 return: ; preds = %entry
7171 ret i32 0, !dbg !45
7272 }
7373
74 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
74 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
7575
7676 !llvm.dbg.cu = !{!3}
7777 !llvm.module.flags = !{!49}
2929
3030 define zeroext i8 @get1(i8 zeroext %a) nounwind optsize {
3131 entry:
32 tail call void @llvm.dbg.value(metadata !{i8 %a}, i64 0, metadata !10, metadata !{}), !dbg !30
32 tail call void @llvm.dbg.value(metadata !{i8 %a}, i64 0, metadata !10), !dbg !30
3333 %0 = load i8* @x1, align 4, !dbg !30
34 tail call void @llvm.dbg.value(metadata !{i8 %0}, i64 0, metadata !11, metadata !{}), !dbg !30
34 tail call void @llvm.dbg.value(metadata !{i8 %0}, i64 0, metadata !11), !dbg !30
3535 store i8 %a, i8* @x1, align 4, !dbg !30
3636 ret i8 %0, !dbg !31
3737 }
3838
39 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
39 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
4040
4141 define zeroext i8 @get2(i8 zeroext %a) nounwind optsize {
4242 entry:
43 tail call void @llvm.dbg.value(metadata !{i8 %a}, i64 0, metadata !18, metadata !{}), !dbg !32
43 tail call void @llvm.dbg.value(metadata !{i8 %a}, i64 0, metadata !18), !dbg !32
4444 %0 = load i8* @x2, align 4, !dbg !32
45 tail call void @llvm.dbg.value(metadata !{i8 %0}, i64 0, metadata !19, metadata !{}), !dbg !32
45 tail call void @llvm.dbg.value(metadata !{i8 %0}, i64 0, metadata !19), !dbg !32
4646 store i8 %a, i8* @x2, align 4, !dbg !32
4747 ret i8 %0, !dbg !33
4848 }
4949
5050 define zeroext i8 @get3(i8 zeroext %a) nounwind optsize {
5151 entry:
52 tail call void @llvm.dbg.value(metadata !{i8 %a}, i64 0, metadata !21, metadata !{}), !dbg !34
52 tail call void @llvm.dbg.value(metadata !{i8 %a}, i64 0, metadata !21), !dbg !34
5353 %0 = load i8* @x3, align 4, !dbg !34
54 tail call void @llvm.dbg.value(metadata !{i8 %0}, i64 0, metadata !22, metadata !{}), !dbg !34
54 tail call void @llvm.dbg.value(metadata !{i8 %0}, i64 0, metadata !22), !dbg !34
5555 store i8 %a, i8* @x3, align 4, !dbg !34
5656 ret i8 %0, !dbg !35
5757 }
5858
5959 define zeroext i8 @get4(i8 zeroext %a) nounwind optsize {
6060 entry:
61 tail call void @llvm.dbg.value(metadata !{i8 %a}, i64 0, metadata !24, metadata !{}), !dbg !36
61 tail call void @llvm.dbg.value(metadata !{i8 %a}, i64 0, metadata !24), !dbg !36
6262 %0 = load i8* @x4, align 4, !dbg !36
63 tail call void @llvm.dbg.value(metadata !{i8 %0}, i64 0, metadata !25, metadata !{}), !dbg !36
63 tail call void @llvm.dbg.value(metadata !{i8 %0}, i64 0, metadata !25), !dbg !36
6464 store i8 %a, i8* @x4, align 4, !dbg !36
6565 ret i8 %0, !dbg !37
6666 }
6767
6868 define zeroext i8 @get5(i8 zeroext %a) nounwind optsize {
6969 entry:
70 tail call void @llvm.dbg.value(metadata !{i8 %a}, i64 0, metadata !27, metadata !{}), !dbg !38
70 tail call void @llvm.dbg.value(metadata !{i8 %a}, i64 0, metadata !27), !dbg !38
7171 %0 = load i8* @x5, align 4, !dbg !38
72 tail call void @llvm.dbg.value(metadata !{i8 %0}, i64 0, metadata !28, metadata !{}), !dbg !38
72 tail call void @llvm.dbg.value(metadata !{i8 %0}, i64 0, metadata !28), !dbg !38
7373 store i8 %a, i8* @x5, align 4, !dbg !38
7474 ret i8 %0, !dbg !39
7575 }
2828 @x5 = global i32 0, align 4
2929
3030 define i32 @get1(i32 %a) nounwind optsize ssp {
31 tail call void @llvm.dbg.value(metadata !{i32 %a}, i64 0, metadata !10, metadata !{}), !dbg !30
31 tail call void @llvm.dbg.value(metadata !{i32 %a}, i64 0, metadata !10), !dbg !30
3232 %1 = load i32* @x1, align 4, !dbg !31
33 tail call void @llvm.dbg.value(metadata !{i32 %1}, i64 0, metadata !11, metadata !{}), !dbg !31
33 tail call void @llvm.dbg.value(metadata !{i32 %1}, i64 0, metadata !11), !dbg !31
3434 store i32 %a, i32* @x1, align 4, !dbg !31
3535 ret i32 %1, !dbg !31
3636 }
3737
3838 define i32 @get2(i32 %a) nounwind optsize ssp {
39 tail call void @llvm.dbg.value(metadata !{i32 %a}, i64 0, metadata !13, metadata !{}), !dbg !32
39 tail call void @llvm.dbg.value(metadata !{i32 %a}, i64 0, metadata !13), !dbg !32
4040 %1 = load i32* @x2, align 4, !dbg !33
41 tail call void @llvm.dbg.value(metadata !{i32 %1}, i64 0, metadata !14, metadata !{}), !dbg !33
41 tail call void @llvm.dbg.value(metadata !{i32 %1}, i64 0, metadata !14), !dbg !33
4242 store i32 %a, i32* @x2, align 4, !dbg !33
4343 ret i32 %1, !dbg !33
4444 }
4545
4646 define i32 @get3(i32 %a) nounwind optsize ssp {
47 tail call void @llvm.dbg.value(metadata !{i32 %a}, i64 0, metadata !16, metadata !{}), !dbg !34
47 tail call void @llvm.dbg.value(metadata !{i32 %a}, i64 0, metadata !16), !dbg !34
4848 %1 = load i32* @x3, align 4, !dbg !35
49 tail call void @llvm.dbg.value(metadata !{i32 %1}, i64 0, metadata !17, metadata !{}), !dbg !35
49 tail call void @llvm.dbg.value(metadata !{i32 %1}, i64 0, metadata !17), !dbg !35
5050 store i32 %a, i32* @x3, align 4, !dbg !35
5151 ret i32 %1, !dbg !35
5252 }
5353
5454 define i32 @get4(i32 %a) nounwind optsize ssp {
55 tail call void @llvm.dbg.value(metadata !{i32 %a}, i64 0, metadata !19, metadata !{}), !dbg !36
55 tail call void @llvm.dbg.value(metadata !{i32 %a}, i64 0, metadata !19), !dbg !36
5656 %1 = load i32* @x4, align 4, !dbg !37
57 tail call void @llvm.dbg.value(metadata !{i32 %1}, i64 0, metadata !20, metadata !{}), !dbg !37
57 tail call void @llvm.dbg.value(metadata !{i32 %1}, i64 0, metadata !20), !dbg !37
5858 store i32 %a, i32* @x4, align 4, !dbg !37
5959 ret i32 %1, !dbg !37
6060 }
6161
6262 define i32 @get5(i32 %a) nounwind optsize ssp {
63 tail call void @llvm.dbg.value(metadata !{i32 %a}, i64 0, metadata !27, metadata !{}), !dbg !38
63 tail call void @llvm.dbg.value(metadata !{i32 %a}, i64 0, metadata !27), !dbg !38
6464 %1 = load i32* @x5, align 4, !dbg !39
65 tail call void @llvm.dbg.value(metadata !{i32 %1}, i64 0, metadata !28, metadata !{}), !dbg !39
65 tail call void @llvm.dbg.value(metadata !{i32 %1}, i64 0, metadata !28), !dbg !39
6666 store i32 %a, i32* @x5, align 4, !dbg !39
6767 ret i32 %1, !dbg !39
6868 }
6969
70 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
70 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
7171
7272 !llvm.dbg.cu = !{!0}
7373 !llvm.module.flags = !{!49}
2626
2727 for.body2: ; preds = %for.cond1
2828 store i32 %storemerge11, i32* @b, align 4, !dbg !26
29 tail call void @llvm.dbg.value(metadata !27, i64 0, metadata !11, metadata !{}), !dbg !28
29 tail call void @llvm.dbg.value(metadata !27, i64 0, metadata !11), !dbg !28
3030 %0 = load i64* @a, align 8, !dbg !29
3131 %xor = xor i64 %0, %e.1.ph, !dbg !29
3232 %conv3 = trunc i64 %xor to i32, !dbg !29
33 tail call void @llvm.dbg.value(metadata !{i32 %conv3}, i64 0, metadata !10, metadata !{}), !dbg !29
33 tail call void @llvm.dbg.value(metadata !{i32 %conv3}, i64 0, metadata !10), !dbg !29
3434 %tobool4 = icmp eq i32 %conv3, 0, !dbg !29
3535 br i1 %tobool4, label %land.end, label %land.rhs, !dbg !29
3636
6868 declare i32 @fn3(...) #1
6969
7070 ; Function Attrs: nounwind readnone
71 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #2
71 declare void @llvm.dbg.value(metadata, i64, metadata) #2
7272
7373 attributes #0 = { nounwind ssp "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
7474 attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
66 %struct.tag_s = type { i32, i32, i32 }
77
88 define void @foo(%struct.tag_s* nocapture %this, %struct.tag_s* %c, i64 %x, i64 %y, %struct.tag_s* nocapture %ptr1, %struct.tag_s* nocapture %ptr2) nounwind ssp {
9 tail call void @llvm.dbg.value(metadata !{%struct.tag_s* %this}, i64 0, metadata !5, metadata !{}), !dbg !20
10 tail call void @llvm.dbg.value(metadata !{%struct.tag_s* %c}, i64 0, metadata !13, metadata !{}), !dbg !21
11 tail call void @llvm.dbg.value(metadata !{i64 %x}, i64 0, metadata !14, metadata !{}), !dbg !22
12 tail call void @llvm.dbg.value(metadata !{i64 %y}, i64 0, metadata !17, metadata !{}), !dbg !23
9 tail call void @llvm.dbg.value(metadata !{%struct.tag_s* %this}, i64 0, metadata !5), !dbg !20
10 tail call void @llvm.dbg.value(metadata !{%struct.tag_s* %c}, i64 0, metadata !13), !dbg !21
11 tail call void @llvm.dbg.value(metadata !{i64 %x}, i64 0, metadata !14), !dbg !22
12 tail call void @llvm.dbg.value(metadata !{i64 %y}, i64 0, metadata !17), !dbg !23
1313 ;CHECK: @DEBUG_VALUE: foo:y <- [R7+8]
14 tail call void @llvm.dbg.value(metadata !{%struct.tag_s* %ptr1}, i64 0, metadata !18, metadata !{}), !dbg !24
15 tail call void @llvm.dbg.value(metadata !{%struct.tag_s* %ptr2}, i64 0, metadata !19, metadata !{}), !dbg !25
14 tail call void @llvm.dbg.value(metadata !{%struct.tag_s* %ptr1}, i64 0, metadata !18), !dbg !24
15 tail call void @llvm.dbg.value(metadata !{%struct.tag_s* %ptr2}, i64 0, metadata !19), !dbg !25
1616 %1 = icmp eq %struct.tag_s* %c, null, !dbg !26
1717 br i1 %1, label %3, label %2, !dbg !26
1818
2626
2727 declare void @foobar(i64, i64)
2828
29 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
29 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
3030
3131 !llvm.dbg.cu = !{!0}
3232 !llvm.module.flags = !{!33}
1818 @"OBJC_IVAR_$_MyWork._data" = external hidden global i32, section "__DATA, __objc_const", align 4
1919 @"\01L_OBJC_SELECTOR_REFERENCES_222" = external hidden global i8*, section "__DATA, __objc_selrefs, literal_pointers, no_dead_strip"
2020
21 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
21 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
2222
2323 declare i8* @objc_msgSend(i8*, i8*, ...)
2424
25 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
25 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
2626
2727 declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
2828
3030 %1 = alloca %0*, align 4
3131 %bounds = alloca %struct.CR, align 4
3232 %data = alloca %struct.CR, align 4
33 call void @llvm.dbg.value(metadata !{i8* %.block_descriptor}, i64 0, metadata !27, metadata !{}), !dbg !129
33 call void @llvm.dbg.value(metadata !{i8* %.block_descriptor}, i64 0, metadata !27), !dbg !129
3434 store %0* %loadedMydata, %0** %1, align 4
35 call void @llvm.dbg.declare(metadata !{%0** %1}, metadata !130, metadata !{}), !dbg !131
35 call void @llvm.dbg.declare(metadata !{%0** %1}, metadata !130), !dbg !131
3636 %2 = bitcast %struct.CR* %bounds to %1*
3737 %3 = getelementptr %1* %2, i32 0, i32 0
3838 store [4 x i32] %bounds.coerce0, [4 x i32]* %3
39 call void @llvm.dbg.declare(metadata !{%struct.CR* %bounds}, metadata !132, metadata !{}), !dbg !133
39 call void @llvm.dbg.declare(metadata !{%struct.CR* %bounds}, metadata !132), !dbg !133
4040 %4 = bitcast %struct.CR* %data to %1*
4141 %5 = getelementptr %1* %4, i32 0, i32 0
4242 store [4 x i32] %data.coerce0, [4 x i32]* %5
43 call void @llvm.dbg.declare(metadata !{%struct.CR* %data}, metadata !134, metadata !{}), !dbg !135
43 call void @llvm.dbg.declare(metadata !{%struct.CR* %data}, metadata !134), !dbg !135
4444 %6 = bitcast i8* %.block_descriptor to %2*
4545 %7 = getelementptr inbounds %2* %6, i32 0, i32 6
46 call void @llvm.dbg.declare(metadata !{%2* %6}, metadata !136, metadata !163), !dbg !137
47 call void @llvm.dbg.declare(metadata !{%2* %6}, metadata !138, metadata !164), !dbg !137
48 call void @llvm.dbg.declare(metadata !{%2* %6}, metadata !139, metadata !165), !dbg !140
46 call void @llvm.dbg.declare(metadata !{%2* %6}, metadata !136), !dbg !137
47 call void @llvm.dbg.declare(metadata !{%2* %6}, metadata !138), !dbg !137
48 call void @llvm.dbg.declare(metadata !{%2* %6}, metadata !139), !dbg !140
4949 %8 = load %0** %1, align 4, !dbg !141
5050 %9 = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_13", !dbg !141
5151 %10 = bitcast %0* %8 to i8*, !dbg !141
230230 !133 = metadata !{i32 609, i32 175, metadata !23, null}
231231 !134 = metadata !{i32 786689, metadata !23, metadata !"data", metadata !24, i32 67109473, metadata !108, i32 0, null} ; [ DW_TAG_arg_variable ]
232232 !135 = metadata !{i32 609, i32 190, metadata !23, null}
233 !136 = metadata !{i32 786688, metadata !23, metadata !"mydata", metadata !24, i32 604, metadata !50, i32 0, null} ;; [ DW_TAG_auto_variable ]
233 !136 = metadata !{i32 786688, metadata !23, metadata !"mydata", metadata !24, i32 604, metadata !50, i32 0, null, metadata !163} ; [ DW_TAG_auto_variable ]
234234 !137 = metadata !{i32 604, i32 49, metadata !23, null}
235 !138 = metadata !{i32 786688, metadata !23, metadata !"self", metadata !40, i32 604, metadata !90, i32 0, null} ;; [ DW_TAG_auto_variable ]
236 !139 = metadata !{i32 786688, metadata !23, metadata !"semi", metadata !24, i32 607, metadata !125, i32 0, null} ;; [ DW_TAG_auto_variable ]
235 !138 = metadata !{i32 786688, metadata !23, metadata !"self", metadata !40, i32 604, metadata !90, i32 0, null, metadata !164} ; [ DW_TAG_auto_variable ]
236 !139 = metadata !{i32 786688, metadata !23, metadata !"semi", metadata !24, i32 607, metadata !125, i32 0, null, metadata !165} ; [ DW_TAG_auto_variable ]
237237 !140 = metadata !{i32 607, i32 30, metadata !23, null}
238238 !141 = metadata !{i32 610, i32 17, metadata !142, null}
239239 !142 = metadata !{i32 786443, metadata !152, metadata !23, i32 609, i32 200, i32 94} ; [ DW_TAG_lexical_block ]
257257 !160 = metadata !{metadata !"header.h", metadata !"/Volumes/Sandbox/llvm"}
258258 !161 = metadata !{metadata !"header2.h", metadata !"/Volumes/Sandbox/llvm"}
259259 !162 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}
260 !163 = metadata !{i32 786690, i64 34, i64 20, i64 6, i64 34, i64 4, i64 6, i64 34, i64 24} ; [DW_OP_plus 20 DW_OP_deref DW_OP_plus 4 DW_OP_deref DW_OP_plus 24]
261 !164 = metadata !{i32 786690, i64 34, i64 24} ; [DW_OP_plus 24]
262 !165 = metadata !{i32 786690, i64 34, i64 28} ; [DW_OP_plus 28]
260 !163 = metadata !{i64 1, i64 20, i64 2, i64 1, i64 4, i64 2, i64 1, i64 24}
261 !164 = metadata !{i64 1, i64 24}
262 !165 = metadata !{i64 1, i64 28}
1919
2020 for.body9: ; preds = %for.body9, %entry
2121 %add19 = fadd <4 x float> undef, , !dbg !39
22 tail call void @llvm.dbg.value(metadata !{<4 x float> %add19}, i64 0, metadata !27, metadata !{}), !dbg !39
22 tail call void @llvm.dbg.value(metadata !{<4 x float> %add19}, i64 0, metadata !27), !dbg !39
2323 %add20 = fadd <4 x float> undef, , !dbg !39
24 tail call void @llvm.dbg.value(metadata !{<4 x float> %add20}, i64 0, metadata !28, metadata !{}), !dbg !39
24 tail call void @llvm.dbg.value(metadata !{<4 x float> %add20}, i64 0, metadata !28), !dbg !39
2525 br i1 %cond, label %for.end54, label %for.body9, !dbg !44
2626
2727 for.end54: ; preds = %for.body9
3636
3737 declare i32 @printf(i8* nocapture, ...) nounwind
3838
39 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
39 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
4040
4141 !llvm.module.flags = !{!56}
4242 !llvm.dbg.cu = !{!2}
1111
1212 define i32 @inlineprinter(i8* %ptr, double %val, i8 zeroext %c) nounwind optsize {
1313 entry:
14 tail call void @llvm.dbg.value(metadata !{i8* %ptr}, i64 0, metadata !19, metadata !{}), !dbg !26
15 tail call void @llvm.dbg.value(metadata !{double %val}, i64 0, metadata !20, metadata !{}), !dbg !26
16 tail call void @llvm.dbg.value(metadata !{i8 %c}, i64 0, metadata !21, metadata !{}), !dbg !26
14 tail call void @llvm.dbg.value(metadata !{i8* %ptr}, i64 0, metadata !19), !dbg !26
15 tail call void @llvm.dbg.value(metadata !{double %val}, i64 0, metadata !20), !dbg !26
16 tail call void @llvm.dbg.value(metadata !{i8 %c}, i64 0, metadata !21), !dbg !26
1717 %0 = zext i8 %c to i32, !dbg !27
1818 %1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([11 x i8]* @.str, i32 0, i32 0), i8* %ptr, double %val, i32 %0) nounwind, !dbg !27
1919 ret i32 0, !dbg !29
2121
2222 define i32 @printer(i8* %ptr, double %val, i8 zeroext %c) nounwind optsize noinline {
2323 entry:
24 tail call void @llvm.dbg.value(metadata !{i8* %ptr}, i64 0, metadata !16, metadata !{}), !dbg !30
25 tail call void @llvm.dbg.value(metadata !{double %val}, i64 0, metadata !17, metadata !{}), !dbg !30
26 tail call void @llvm.dbg.value(metadata !{i8 %c}, i64 0, metadata !18, metadata !{}), !dbg !30
24 tail call void @llvm.dbg.value(metadata !{i8* %ptr}, i64 0, metadata !16), !dbg !30
25 tail call void @llvm.dbg.value(metadata !{double %val}, i64 0, metadata !17), !dbg !30
26 tail call void @llvm.dbg.value(metadata !{i8 %c}, i64 0, metadata !18), !dbg !30
2727 %0 = zext i8 %c to i32, !dbg !31
2828 %1 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([11 x i8]* @.str, i32 0, i32 0), i8* %ptr, double %val, i32 %0) nounwind, !dbg !31
2929 ret i32 0, !dbg !33
3131
3232 declare i32 @printf(i8* nocapture, ...) nounwind
3333
34 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
34 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
3535
3636 define i32 @main(i32 %argc, i8** nocapture %argv) nounwind optsize {
3737 entry:
38 tail call void @llvm.dbg.value(metadata !{i32 %argc}, i64 0, metadata !22, metadata !{}), !dbg !34
39 tail call void @llvm.dbg.value(metadata !{i8** %argv}, i64 0, metadata !23, metadata !{}), !dbg !34
38 tail call void @llvm.dbg.value(metadata !{i32 %argc}, i64 0, metadata !22), !dbg !34
39 tail call void @llvm.dbg.value(metadata !{i8** %argv}, i64 0, metadata !23), !dbg !34
4040 %0 = sitofp i32 %argc to double, !dbg !35
4141 %1 = fadd double %0, 5.555552e+05, !dbg !35
42 tail call void @llvm.dbg.value(metadata !{double %1}, i64 0, metadata !24, metadata !{}), !dbg !35
42 tail call void @llvm.dbg.value(metadata !{double %1}, i64 0, metadata !24), !dbg !35
4343 %2 = tail call i32 @puts(i8* getelementptr inbounds ([6 x i8]* @.str1, i32 0, i32 0)) nounwind, !dbg !36
4444 %3 = getelementptr inbounds i8* bitcast (i32 (i32, i8**)* @main to i8*), i32 %argc, !dbg !37
4545 %4 = trunc i32 %argc to i8, !dbg !37
4646 %5 = add i8 %4, 97, !dbg !37
47 tail call void @llvm.dbg.value(metadata !{i8* %3}, i64 0, metadata !19, metadata !{}) nounwind, !dbg !38
48 tail call void @llvm.dbg.value(metadata !{double %1}, i64 0, metadata !20, metadata !{}) nounwind, !dbg !38
49 tail call void @llvm.dbg.value(metadata !{i8 %5}, i64 0, metadata !21, metadata !{}) nounwind, !dbg !38
47 tail call void @llvm.dbg.value(metadata !{i8* %3}, i64 0, metadata !19) nounwind, !dbg !38
48 tail call void @llvm.dbg.value(metadata !{double %1}, i64 0, metadata !20) nounwind, !dbg !38
49 tail call void @llvm.dbg.value(metadata !{i8 %5}, i64 0, metadata !21) nounwind, !dbg !38
5050 %6 = zext i8 %5 to i32, !dbg !39
5151 %7 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([11 x i8]* @.str, i32 0, i32 0), i8* %3, double %1, i32 %6) nounwind, !dbg !39
5252 %8 = tail call i32 @printer(i8* %3, double %1, i8 zeroext %5) nounwind, !dbg !40
2525 br i1 undef, label %for.end54, label %for.body9, !dbg !44
2626
2727 for.end54: ; preds = %for.body9
28 tail call void @llvm.dbg.value(metadata !{<4 x float> %add19}, i64 0, metadata !27, metadata !{}), !dbg !39
28 tail call void @llvm.dbg.value(metadata !{<4 x float> %add19}, i64 0, metadata !27), !dbg !39
2929 %tmp115 = extractelement <4 x float> %add19, i32 1
3030 %conv6.i75 = fpext float %tmp115 to double, !dbg !45
3131 %call.i82 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([13 x i8]* @.str, i32 0, i32 0), double undef, double %conv6.i75, double undef, double undef) nounwind, !dbg !45
3434
3535 declare i32 @printf(i8* nocapture, ...) nounwind
3636
37 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
37 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
3838
3939 !llvm.dbg.cu = !{!2}
4040 !llvm.module.flags = !{!56}
1414
1515 define i32 @inlineprinter(i8* %ptr, float %val, i8 zeroext %c) nounwind optsize ssp {
1616 entry:
17 tail call void @llvm.dbg.value(metadata !{i8* %ptr}, i64 0, metadata !8, metadata !{}), !dbg !24
18 tail call void @llvm.dbg.value(metadata !{float %val}, i64 0, metadata !10, metadata !{}), !dbg !25
19 tail call void @llvm.dbg.value(metadata !{i8 %c}, i64 0, metadata !12, metadata !{}), !dbg !26
17 tail call void @llvm.dbg.value(metadata !{i8* %ptr}, i64 0, metadata !8), !dbg !24
18 tail call void @llvm.dbg.value(metadata !{float %val}, i64 0, metadata !10), !dbg !25
19 tail call void @llvm.dbg.value(metadata !{i8 %c}, i64 0, metadata !12), !dbg !26
2020 %conv = fpext float %val to double, !dbg !27
2121 %conv3 = zext i8 %c to i32, !dbg !27
2222 %call = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([11 x i8]* @.str, i32 0, i32 0), i8* %ptr, double %conv, i32 %conv3) nounwind optsize, !dbg !27
2727
2828 define i32 @printer(i8* %ptr, float %val, i8 zeroext %c) nounwind optsize noinline ssp {
2929 entry:
30 tail call void @llvm.dbg.value(metadata !{i8* %ptr}, i64 0, metadata !14, metadata !{}), !dbg !30
31 tail call void @llvm.dbg.value(metadata !{float %val}, i64 0, metadata !15, metadata !{}), !dbg !31
32 tail call void @llvm.dbg.value(metadata !{i8 %c}, i64 0, metadata !16, metadata !{}), !dbg !32
30 tail call void @llvm.dbg.value(metadata !{i8* %ptr}, i64 0, metadata !14), !dbg !30
31 tail call void @llvm.dbg.value(metadata !{float %val}, i64 0, metadata !15), !dbg !31
32 tail call void @llvm.dbg.value(metadata !{i8 %c}, i64 0, metadata !16), !dbg !32
3333 %conv = fpext float %val to double, !dbg !33
3434 %conv3 = zext i8 %c to i32, !dbg !33
3535 %call = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([11 x i8]* @.str, i32 0, i32 0), i8* %ptr, double %conv, i32 %conv3) nounwind optsize, !dbg !33
3838
3939 define i32 @main(i32 %argc, i8** nocapture %argv) nounwind optsize ssp {
4040 entry:
41 tail call void @llvm.dbg.value(metadata !{i32 %argc}, i64 0, metadata !17, metadata !{}), !dbg !36
42 tail call void @llvm.dbg.value(metadata !{i8** %argv}, i64 0, metadata !18, metadata !{}), !dbg !37
41 tail call void @llvm.dbg.value(metadata !{i32 %argc}, i64 0, metadata !17), !dbg !36
42 tail call void @llvm.dbg.value(metadata !{i8** %argv}, i64 0, metadata !18), !dbg !37
4343 %conv = sitofp i32 %argc to double, !dbg !38
4444 %add = fadd double %conv, 5.555552e+05, !dbg !38
4545 %conv1 = fptrunc double %add to float, !dbg !38
46 tail call void @llvm.dbg.value(metadata !{float %conv1}, i64 0, metadata !22, metadata !{}), !dbg !38
46 tail call void @llvm.dbg.value(metadata !{float %conv1}, i64 0, metadata !22), !dbg !38
4747 %call = tail call i32 @puts(i8* getelementptr inbounds ([6 x i8]* @.str1, i32 0, i32 0)) nounwind optsize, !dbg !39
4848 %add.ptr = getelementptr i8* bitcast (i32 (i32, i8**)* @main to i8*), i32 %argc, !dbg !40
4949 %add5 = add nsw i32 %argc, 97, !dbg !40
5050 %conv6 = trunc i32 %add5 to i8, !dbg !40
51 tail call void @llvm.dbg.value(metadata !{i8* %add.ptr}, i64 0, metadata !8, metadata !{}) nounwind, !dbg !41
52 tail call void @llvm.dbg.value(metadata !{float %conv1}, i64 0, metadata !10, metadata !{}) nounwind, !dbg !42
53 tail call void @llvm.dbg.value(metadata !{i8 %conv6}, i64 0, metadata !12, metadata !{}) nounwind, !dbg !43
51 tail call void @llvm.dbg.value(metadata !{i8* %add.ptr}, i64 0, metadata !8) nounwind, !dbg !41
52 tail call void @llvm.dbg.value(metadata !{float %conv1}, i64 0, metadata !10) nounwind, !dbg !42
53 tail call void @llvm.dbg.value(metadata !{i8 %conv6}, i64 0, metadata !12) nounwind, !dbg !43
5454 %conv.i = fpext float %conv1 to double, !dbg !44
5555 %conv3.i = and i32 %add5, 255, !dbg !44
5656 %call.i = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([11 x i8]* @.str, i32 0, i32 0), i8* %add.ptr, double %conv.i, i32 %conv3.i) nounwind optsize, !dbg !44
6060
6161 declare i32 @puts(i8* nocapture) nounwind optsize
6262
63 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
63 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
6464
6565 !llvm.dbg.cu = !{!2}
6666 !llvm.module.flags = !{!53}
1414 define void @_Z3foov() optsize ssp {
1515 entry:
1616 %call = tail call float @_Z3barv() optsize, !dbg !11
17 tail call void @llvm.dbg.value(metadata !{float %call}, i64 0, metadata !5, metadata !{}), !dbg !11
17 tail call void @llvm.dbg.value(metadata !{float %call}, i64 0, metadata !5), !dbg !11
1818 %call16 = tail call float @_Z2f2v() optsize, !dbg !12
1919 %cmp7 = fcmp olt float %call, %call16, !dbg !12
2020 br i1 %cmp7, label %for.body, label %for.end, !dbg !12
3737
3838 declare float @_Z2f3f(float) optsize
3939
40 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
40 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
4141
4242 !llvm.dbg.cu = !{!0}
4343 !llvm.module.flags = !{!20}
33 %0 = type { i32, i32 }
44
55 define void @t(%0*, i32, i32, i32, i32) nounwind {
6 tail call void @llvm.dbg.value(metadata !{%0* %0}, i64 0, metadata !0, metadata !{})
6 tail call void @llvm.dbg.value(metadata !{%0* %0}, i64 0, metadata !0)
77 unreachable
88 }
99
10 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
10 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
1111
1212 ; !0 should conform to the format of DIVariable.
1313 !0 = metadata !{i32 786689, null, metadata !"a", null, i32 0, null, i32 0, i32 0} ;
44
55 define void @foo(i32* nocapture %a, i32* nocapture %b) nounwind {
66 entry:
7 tail call void @llvm.dbg.value(metadata !{i32* %a}, i64 0, metadata !13, metadata !{}), !dbg !17
8 tail call void @llvm.dbg.value(metadata !{i32* %b}, i64 0, metadata !14, metadata !{}), !dbg !18
9 tail call void @llvm.dbg.value(metadata !30, i64 0, metadata !15, metadata !{}), !dbg !19
7 tail call void @llvm.dbg.value(metadata !{i32* %a}, i64 0, metadata !13), !dbg !17
8 tail call void @llvm.dbg.value(metadata !{i32* %b}, i64 0, metadata !14), !dbg !18
9 tail call void @llvm.dbg.value(metadata !30, i64 0, metadata !15), !dbg !19
1010 br label %for.body, !dbg !19
1111
1212 for.body: ; preds = %for.body, %entry
1717 %i.02 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
1818 %b.addr.01 = phi i32* [ %b, %entry ], [ %incdec.ptr, %for.body ]
1919 %incdec.ptr = getelementptr inbounds i32* %b.addr.01, i32 1, !dbg !21
20 tail call void @llvm.dbg.value(metadata !{i32* %incdec.ptr}, i64 0, metadata !14, metadata !{}), !dbg !21
20 tail call void @llvm.dbg.value(metadata !{i32* %incdec.ptr}, i64 0, metadata !14), !dbg !21
2121 %0 = load i32* %b.addr.01, align 4, !dbg !21
2222 store i32 %0, i32* %arrayidx.phi, align 4, !dbg !21
2323 %inc = add nsw i32 %i.02, 1, !dbg !26
24 tail call void @llvm.dbg.value(metadata !{i32 %inc}, i64 0, metadata !15, metadata !{}), !dbg !26
24 tail call void @llvm.dbg.value(metadata !{i32 %inc}, i64 0, metadata !15), !dbg !26
2525 %exitcond = icmp eq i32 %inc, 10, !dbg !19
2626 %arrayidx.inc = getelementptr i32* %arrayidx.phi, i32 1
2727 br i1 %exitcond, label %for.end, label %for.body, !dbg !19
3030 ret void, !dbg !27
3131 }
3232
33 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
33 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
3434
3535
3636 !llvm.dbg.cu = !{!0}
22 define i32 @main() nounwind ssp {
33 entry:
44 ; CHECK: DEBUG_VALUE
5 call void @llvm.dbg.value(metadata !6, i64 0, metadata !7, metadata !{}), !dbg !9
5 call void @llvm.dbg.value(metadata !6, i64 0, metadata !7), !dbg !9
66 ret i32 0, !dbg !10
77 }
88
9 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
9 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
1010
11 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
11 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
1212
1313 !llvm.dbg.cu = !{!2}
1414 !llvm.module.flags = !{!13}
55
66 define i32 @main(i32 %argc, i8** nocapture %argv) nounwind readnone {
77 entry:
8 tail call void @llvm.dbg.value(metadata !{i32 %argc}, i64 0, metadata !15, metadata !{}), !dbg !17
9 tail call void @llvm.dbg.value(metadata !{i8** %argv}, i64 0, metadata !16, metadata !{}), !dbg !18
8 tail call void @llvm.dbg.value(metadata !{i32 %argc}, i64 0, metadata !15), !dbg !17
9 tail call void @llvm.dbg.value(metadata !{i8** %argv}, i64 0, metadata !16), !dbg !18
1010 %add = add nsw i32 %argc, 1, !dbg !19
1111 ret i32 %add, !dbg !19
1212 }
1313
14 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
14 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
1515
1616 !llvm.dbg.cu = !{!0}
1717 !llvm.module.flags = !{!22}
2424 for.end1042: ; preds = %for.cond968.preheader, %for.cond964.preheader, %entry
2525 %0 = phi i32 [ undef, %for.cond964.preheader ], [ undef, %for.cond968.preheader ], [ undef, %entry ]
2626 %1 = load i32* getelementptr inbounds ([3 x i32]* @grid_points, i64 0, i64 0), align 4, !dbg !443, !tbaa !444
27 tail call void @llvm.dbg.value(metadata !447, i64 0, metadata !119, metadata !{}), !dbg !448
27 tail call void @llvm.dbg.value(metadata !447, i64 0, metadata !119), !dbg !448
2828 %sub10454270 = add nsw i32 %0, -1, !dbg !448
2929 %cmp10464271 = icmp sgt i32 %sub10454270, 1, !dbg !448
3030 %sub11134263 = add nsw i32 %1, -1, !dbg !450
4545 }
4646
4747 ; Function Attrs: nounwind readnone
48 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
48 declare void @llvm.dbg.value(metadata, i64, metadata) #1
4949
5050 attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
5151 attributes #1 = { nounwind readnone }
2424 %storemerge = phi double [ -1.000000e+00, %4 ], [ 1.000000e+00, %3 ], [ 1.000000e+00, %3 ] ; [#uses=1]
2525 %v_6 = icmp slt i32 %1, 2 ; [#uses=1]
2626 %storemerge1 = select i1 %v_6, double 1.000000e+00, double -1.000000e+00 ; [#uses=3]
27 call void @llvm.dbg.value(metadata !{double %storemerge}, i64 0, metadata !91, metadata !{}), !dbg !0
27 call void @llvm.dbg.value(metadata !{double %storemerge}, i64 0, metadata !91), !dbg !0
2828 %v_7 = icmp eq i32 %2, 1, !dbg !92 ; [#uses=1]
2929 %storemerge2 = select i1 %v_7, double 1.000000e+00, double -1.000000e+00 ; [#uses=3]
3030 %v_8 = getelementptr inbounds %0* %0, i32 0, i32 0, i32 0 ; [#uses=1]
3939 ret void, !dbg !98
4040 }
4141
42 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
42 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
4343
4444 declare double @sqrt(double) nounwind readonly
4545
46 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
46 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
4747
4848 !llvm.dbg.cu = !{!5}
4949 !llvm.module.flags = !{!104}
1313 %2 = alloca i64 ; [#uses=1]
1414 %3 = alloca i64 ; [#uses=6]
1515 %"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
16 call void @llvm.dbg.declare(metadata !{i8** %s1_addr}, metadata !0, metadata !{}), !dbg !7
16 call void @llvm.dbg.declare(metadata !{i8** %s1_addr}, metadata !0), !dbg !7
1717 store i8* %s1, i8** %s1_addr
18 call void @llvm.dbg.declare(metadata !{[0 x i8]** %str.0}, metadata !8, metadata !{}), !dbg !7
18 call void @llvm.dbg.declare(metadata !{[0 x i8]** %str.0}, metadata !8), !dbg !7
1919 %4 = call i8* @llvm.stacksave(), !dbg !7 ; [#uses=1]
2020 store i8* %4, i8** %saved_stack.1, align 8, !dbg !7
2121 %5 = load i8** %s1_addr, align 8, !dbg !13 ; [#uses=1]
5757 ret i8 %retval12, !dbg !16
5858 }
5959
60 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
60 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
6161
6262 declare i8* @llvm.stacksave() nounwind
6363
88 br label %do.body, !dbg !0
99
1010 do.body: ; preds = %entry
11 call void @llvm.dbg.declare(metadata !{i32* %count_}, metadata !4, metadata !{})
11 call void @llvm.dbg.declare(metadata !{i32* %count_}, metadata !4)
1212 %conv = ptrtoint i32* %count_ to i32, !dbg !0 ; [#uses=1]
1313 %call = call i32 @foo(i32 %conv) ssp, !dbg !0 ; [#uses=0]
1414 br label %do.end, !dbg !0
1717 ret void, !dbg !7
1818 }
1919
20 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
20 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
2121
2222 declare i32 @foo(i32) ssp
2323
1111 %retval = alloca double ; [#uses=2]
1212 %0 = alloca double ; [#uses=2]
1313 %"alloca point" = bitcast i32 0 to i32 ; [#uses=0]
14 call void @llvm.dbg.declare(metadata !{%struct.Rect* %my_r0}, metadata !0, metadata !{}), !dbg !15
14 call void @llvm.dbg.declare(metadata !{%struct.Rect* %my_r0}, metadata !0), !dbg !15
1515 %1 = getelementptr inbounds %struct.Rect* %my_r0, i32 0, i32 0, !dbg !16 ; <%struct.Pt*> [#uses=1]
1616 %2 = getelementptr inbounds %struct.Pt* %1, i32 0, i32 0, !dbg !16 ; [#uses=1]
1717 %3 = load double* %2, align 8, !dbg !16 ; [#uses=1]
2525 ret double %retval1, !dbg !16
2626 }
2727
28 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
28 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
2929
3030 !llvm.dbg.cu = !{!3}
3131 !llvm.module.flags = !{!21}
77
88 define i32 @"main(tart.core.String[])->int32"(i32 %args) {
99 entry:
10 tail call void @llvm.dbg.value(metadata !14, i64 0, metadata !8, metadata !{})
10 tail call void @llvm.dbg.value(metadata !14, i64 0, metadata !8)
1111 tail call void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType* @.type.SwitchStmtTest) ; <%tart.core.Object*> [#uses=2]
1212 ret i32 3
1313 }
1414
15 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
15 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
1616 declare void @"tart.reflect.ComplexType.create->tart.core.Object"(%tart.reflect.ComplexType*) nounwind readnone
1717
1818 !0 = metadata !{i32 458769, metadata !15, i32 1, metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, metadata !"", i32 0, metadata !16, metadata !16, null, null, null, i32 0} ; [ DW_TAG_compile_unit ]
1010
1111 define hidden %0 @__divsc3(float %a, float %b, float %c, float %d) nounwind readnone {
1212 entry:
13 tail call void @llvm.dbg.value(metadata !{float %a}, i64 0, metadata !0, metadata !{})
14 tail call void @llvm.dbg.value(metadata !{float %b}, i64 0, metadata !11, metadata !{})
15 tail call void @llvm.dbg.value(metadata !{float %c}, i64 0, metadata !12, metadata !{})
16 tail call void @llvm.dbg.value(metadata !{float %d}, i64 0, metadata !13, metadata !{})
13 tail call void @llvm.dbg.value(metadata !{float %a}, i64 0, metadata !0)
14 tail call void @llvm.dbg.value(metadata !{float %b}, i64 0, metadata !11)
15 tail call void @llvm.dbg.value(metadata !{float %c}, i64 0, metadata !12)
16 tail call void @llvm.dbg.value(metadata !{float %d}, i64 0, metadata !13)
1717 %0 = tail call float @fabsf(float %c) nounwind readnone, !dbg !19 ; [#uses=1]
1818 %1 = tail call float @fabsf(float %d) nounwind readnone, !dbg !19 ; [#uses=1]
1919 %2 = fcmp olt float %0, %1, !dbg !19 ; [#uses=1]
2121
2222 bb: ; preds = %entry
2323 %3 = fdiv float %c, %d, !dbg !20 ; [#uses=3]
24 tail call void @llvm.dbg.value(metadata !{float %3}, i64 0, metadata !16, metadata !{}), !dbg !20
24 tail call void @llvm.dbg.value(metadata !{float %3}, i64 0, metadata !16), !dbg !20
2525 %4 = fmul float %3, %c, !dbg !21 ; [#uses=1]
2626 %5 = fadd float %4, %d, !dbg !21 ; [#uses=2]
27 tail call void @llvm.dbg.value(metadata !{float %5}, i64 0, metadata !14, metadata !{}), !dbg !21
27 tail call void @llvm.dbg.value(metadata !{float %5}, i64 0, metadata !14), !dbg !21
2828 %6 = fmul float %3, %a, !dbg !22 ; [#uses=1]
2929 %7 = fadd float %6, %b, !dbg !22 ; [#uses=1]
3030 %8 = fdiv float %7, %5, !dbg !22 ; [#uses=1]
31 tail call void @llvm.dbg.value(metadata !{float %8}, i64 0, metadata !17, metadata !{}), !dbg !22
31 tail call void @llvm.dbg.value(metadata !{float %8}, i64 0, metadata !17), !dbg !22
3232 %9 = fmul float %3, %b, !dbg !23 ; [#uses=1]
3333 %10 = fsub float %9, %a, !dbg !23 ; [#uses=1]
3434 %11 = fdiv float %10, %5, !dbg !23 ; [#uses=1]
35 tail call void @llvm.dbg.value(metadata !{float %11}, i64 0, metadata !18, metadata !{}), !dbg !23
35 tail call void @llvm.dbg.value(metadata !{float %11}, i64 0, metadata !18), !dbg !23
3636 br label %bb2, !dbg !23
3737
3838 bb1: ; preds = %entry
3939 %12 = fdiv float %d, %c, !dbg !24 ; [#uses=3]
40 tail call void @llvm.dbg.value(metadata !{float %12}, i64 0, metadata !16, metadata !{}), !dbg !24
40 tail call void @llvm.dbg.value(metadata !{float %12}, i64 0, metadata !16), !dbg !24
4141 %13 = fmul float %12, %d, !dbg !25 ; [#uses=1]
4242 %14 = fadd float %13, %c, !dbg !25 ; [#uses=2]
43 tail call void @llvm.dbg.value(metadata !{float %14}, i64 0, metadata !14, metadata !{}), !dbg !25
43 tail call void @llvm.dbg.value(metadata !{float %14}, i64 0, metadata !14), !dbg !25
4444 %15 = fmul float %12, %b, !dbg !26 ; [#uses=1]
4545 %16 = fadd float %15, %a, !dbg !26 ; [#uses=1]
4646 %17 = fdiv float %16, %14, !dbg !26 ; [#uses=1]
47 tail call void @llvm.dbg.value(metadata !{float %17}, i64 0, metadata !17, metadata !{}), !dbg !26
47 tail call void @llvm.dbg.value(metadata !{float %17}, i64 0, metadata !17), !dbg !26
4848 %18 = fmul float %12, %a, !dbg !27 ; [#uses=1]
4949 %19 = fsub float %b, %18, !dbg !27 ; [#uses=1]
5050 %20 = fdiv float %19, %14, !dbg !27 ; [#uses=1]
51 tail call void @llvm.dbg.value(metadata !{float %20}, i64 0, metadata !18, metadata !{}), !dbg !27
51 tail call void @llvm.dbg.value(metadata !{float %20}, i64 0, metadata !18), !dbg !27
5252 br label %bb2, !dbg !27
5353
5454 bb2: ; preds = %bb1, %bb
7474 bb8: ; preds = %bb6
7575 %27 = tail call float @copysignf(float 0x7FF0000000000000, float %c) nounwind readnone, !dbg !30 ; [#uses=2]
7676 %28 = fmul float %27, %a, !dbg !30 ; [#uses=1]
77 tail call void @llvm.dbg.value(metadata !{float %28}, i64 0, metadata !17, metadata !{}), !dbg !30
77 tail call void @llvm.dbg.value(metadata !{float %28}, i64 0, metadata !17), !dbg !30
7878 %29 = fmul float %27, %b, !dbg !31 ; [#uses=1]
79 tail call void @llvm.dbg.value(metadata !{float %29}, i64 0, metadata !18, metadata !{}), !dbg !31
79 tail call void @llvm.dbg.value(metadata !{float %29}, i64 0, metadata !18), !dbg !31
8080 br label %bb46, !dbg !31
8181
8282 bb9: ; preds = %bb6, %bb4
106106 bb16: ; preds = %bb15
107107 %iftmp.0.0 = select i1 %33, float 1.000000e+00, float 0.000000e+00 ; [#uses=1]
108108 %42 = tail call float @copysignf(float %iftmp.0.0, float %a) nounwind readnone, !dbg !33 ; [#uses=2]
109 tail call void @llvm.dbg.value(metadata !{float %42}, i64 0, metadata !0, metadata !{}), !dbg !33
109 tail call void @llvm.dbg.value(metadata !{float %42}, i64 0, metadata !0), !dbg !33
110110 %43 = fcmp ord float %b, 0.000000e+00 ; [#uses=1]
111111 %44 = fsub float %b, %b, !dbg !34 ; [#uses=1]
112112 %45 = fcmp uno float %44, 0.000000e+00 ; [#uses=1]
113113 %46 = and i1 %43, %45, !dbg !34 ; [#uses=1]
114114 %iftmp.1.0 = select i1 %46, float 1.000000e+00, float 0.000000e+00 ; [#uses=1]
115115 %47 = tail call float @copysignf(float %iftmp.1.0, float %b) nounwind readnone, !dbg !34 ; [#uses=2]
116 tail call void @llvm.dbg.value(metadata !{float %47}, i64 0, metadata !11, metadata !{}), !dbg !34
116 tail call void @llvm.dbg.value(metadata !{float %47}, i64 0, metadata !11), !dbg !34
117117 %48 = fmul float %42, %c, !dbg !35 ; [#uses=1]
118118 %49 = fmul float %47, %d, !dbg !35 ; [#uses=1]
119119 %50 = fadd float %48, %49, !dbg !35 ; [#uses=1]
120120 %51 = fmul float %50, 0x7FF0000000000000, !dbg !35 ; [#uses=1]
121 tail call void @llvm.dbg.value(metadata !{float %51}, i64 0, metadata !17, metadata !{}), !dbg !35
121 tail call void @llvm.dbg.value(metadata !{float %51}, i64 0, metadata !17), !dbg !35
122122 %52 = fmul float %47, %c, !dbg !36 ; [#uses=1]
123123 %53 = fmul float %42, %d, !dbg !36 ; [#uses=1]
124124 %54 = fsub float %52, %53, !dbg !36 ; [#uses=1]
125125 %55 = fmul float %54, 0x7FF0000000000000, !dbg !36 ; [#uses=1]
126 tail call void @llvm.dbg.value(metadata !{float %55}, i64 0, metadata !18, metadata !{}), !dbg !36
126 tail call void @llvm.dbg.value(metadata !{float %55}, i64 0, metadata !18), !dbg !36
127127 br label %bb46, !dbg !36
128128
129129 bb27: ; preds = %bb15, %bb14, %bb11
154154 bb35: ; preds = %bb34
155155 %iftmp.2.0 = select i1 %59, float 1.000000e+00, float 0.000000e+00 ; [#uses=1]
156156 %67 = tail call float @copysignf(float %iftmp.2.0, float %c) nounwind readnone, !dbg !38 ; [#uses=2]
157 tail call void @llvm.dbg.value(metadata !{float %67}, i64 0, metadata !12, metadata !{}), !dbg !38
157 tail call void @llvm.dbg.value(metadata !{float %67}, i64 0, metadata !12), !dbg !38
158158 %68 = fcmp ord float %d, 0.000000e+00 ; [#uses=1]
159159 %69 = fsub float %d, %d, !dbg !39 ; [#uses=1]
160160 %70 = fcmp uno float %69, 0.000000e+00 ; [#uses=1]
161161 %71 = and i1 %68, %70, !dbg !39 ; [#uses=1]
162162 %iftmp.3.0 = select i1 %71, float 1.000000e+00, float 0.000000e+00 ; [#uses=1]
163163 %72 = tail call float @copysignf(float %iftmp.3.0, float %d) nounwind readnone, !dbg !39 ; [#uses=2]
164 tail call void @llvm.dbg.value(metadata !{float %72}, i64 0, metadata !13, metadata !{}), !dbg !39
164 tail call void @llvm.dbg.value(metadata !{float %72}, i64 0, metadata !13), !dbg !39
165165 %73 = fmul float %67, %a, !dbg !40 ; [#uses=1]
166166 %74 = fmul float %72, %b, !dbg !40 ; [#uses=1]
167167 %75 = fadd float %73, %74, !dbg !40 ; [#uses=1]
168168 %76 = fmul float %75, 0.000000e+00, !dbg !40 ; [#uses=1]
169 tail call void @llvm.dbg.value(metadata !{float %76}, i64 0, metadata !17, metadata !{}), !dbg !40
169 tail call void @llvm.dbg.value(metadata !{float %76}, i64 0, metadata !17), !dbg !40
170170 %77 = fmul float %67, %b, !dbg !41 ; [#uses=1]
171171 %78 = fmul float %72, %a, !dbg !41 ; [#uses=1]
172172 %79 = fsub float %77, %78, !dbg !41 ; [#uses=1]
173173 %80 = fmul float %79, 0.000000e+00, !dbg !41 ; [#uses=1]
174 tail call void @llvm.dbg.value(metadata !{float %80}, i64 0, metadata !18, metadata !{}), !dbg !41
174 tail call void @llvm.dbg.value(metadata !{float %80}, i64 0, metadata !18), !dbg !41
175175 br label %bb46, !dbg !41
176176
177177 bb46: ; preds = %bb35, %bb34, %bb33, %bb30, %bb16, %bb8, %bb2
195195
196196 declare float @copysignf(float, float) nounwind readnone
197197
198 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
198 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
199199
200200 !llvm.dbg.cu = !{!3}
201201 !llvm.module.flags = !{!48}
88
99 define i8* @bar(%struct.a* %myvar) nounwind optsize noinline ssp {
1010 entry:
11 tail call void @llvm.dbg.value(metadata !{%struct.a* %myvar}, i64 0, metadata !8, metadata !{})
11 tail call void @llvm.dbg.value(metadata !{%struct.a* %myvar}, i64 0, metadata !8)
1212 %0 = getelementptr inbounds %struct.a* %myvar, i64 0, i32 0, !dbg !28 ; [#uses=1]
1313 %1 = load i32* %0, align 8, !dbg !28 ; [#uses=1]
1414 tail call void @foo(i32 %1) nounwind optsize noinline ssp, !dbg !28
1818
1919 declare void @foo(i32) nounwind optsize noinline ssp
2020
21 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
21 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
2222
2323 !llvm.dbg.cu = !{!2}
2424 !llvm.module.flags = !{!38}
33
44 define i32 @foo(i32 %y) nounwind optsize ssp {
55 entry:
6 tail call void @llvm.dbg.value(metadata !{i32 %y}, i64 0, metadata !0, metadata !{})
6 tail call void @llvm.dbg.value(metadata !{i32 %y}, i64 0, metadata !0)
77 %0 = tail call i32 (...)* @zoo(i32 %y) nounwind, !dbg !9 ; [#uses=1]
88 ret i32 %0, !dbg !9
99 }
1010
1111 declare i32 @zoo(...)
1212
13 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
13 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
1414
1515