Verifier: Check debug info intrinsic arguments

Verify that debug info intrinsic arguments are valid.  (These checks
will not recurse through the full debug info graph, so they don't need
to be cordoned of in `DebugInfoVerifier`.)

With those checks in place, changing the `DbgIntrinsicInst` accessors to
downcast to `MDLocalVariable` and `MDExpression` is natural (added isa
specializations in `Metadata.h` to support this).

Added tests to `test/Verifier` for the new -verify checks, and fixed the
debug info in all the in-tree tests.

If you have out-of-tree testcases that have started to fail to -verify,
hopefully the verify checks are helpful.  The most likely problem is
that the expression argument is `!{}` (instead of `!MDExpression()`).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232296 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2015-03-15 01:21:30 +00:00
parent 48248ac8a0
commit 08e687e684
30 changed files with 210 additions and 88 deletions

View File

@ -82,13 +82,14 @@ namespace llvm {
class DbgDeclareInst : public DbgInfoIntrinsic {
public:
Value *getAddress() const;
MDNode *getVariable() const {
return cast<MDNode>(
cast<MetadataAsValue>(getArgOperand(1))->getMetadata());
MDNode *getVariable() const { return cast<MDNode>(getRawVariable()); }
MDNode *getExpression() const { return cast<MDNode>(getRawExpression()); }
Metadata *getRawVariable() const {
return cast<MetadataAsValue>(getArgOperand(1))->getMetadata();
}
MDNode *getExpression() const {
return cast<MDNode>(
cast<MetadataAsValue>(getArgOperand(2))->getMetadata());
Metadata *getRawExpression() const {
return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
}
// Methods for support type inquiry through isa, cast, and dyn_cast:
@ -110,13 +111,14 @@ namespace llvm {
return cast<ConstantInt>(
const_cast<Value*>(getArgOperand(1)))->getZExtValue();
}
MDNode *getVariable() const {
return cast<MDNode>(
cast<MetadataAsValue>(getArgOperand(2))->getMetadata());
MDNode *getVariable() const { return cast<MDNode>(getRawVariable()); }
MDNode *getExpression() const { return cast<MDNode>(getRawExpression()); }
Metadata *getRawVariable() const {
return cast<MetadataAsValue>(getArgOperand(2))->getMetadata();
}
MDNode *getExpression() const {
return cast<MDNode>(
cast<MetadataAsValue>(getArgOperand(3))->getMetadata());
Metadata *getRawExpression() const {
return cast<MetadataAsValue>(getArgOperand(3))->getMetadata();
}
// Methods for support type inquiry through isa, cast, and dyn_cast:

View File

@ -329,6 +329,8 @@ private:
void visitUserOp1(Instruction &I);
void visitUserOp2(Instruction &I) { visitUserOp1(I); }
void visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI);
template <class DbgIntrinsicTy>
void visitDbgIntrinsic(StringRef Kind, DbgIntrinsicTy &DII);
void visitAtomicCmpXchgInst(AtomicCmpXchgInst &CXI);
void visitAtomicRMWInst(AtomicRMWInst &RMWI);
void visitFenceInst(FenceInst &FI);
@ -2798,6 +2800,10 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
case Intrinsic::dbg_declare: // llvm.dbg.declare
Assert(isa<MetadataAsValue>(CI.getArgOperand(0)),
"invalid llvm.dbg.declare intrinsic call 1", &CI);
visitDbgIntrinsic("declare", cast<DbgDeclareInst>(CI));
break;
case Intrinsic::dbg_value: // llvm.dbg.value
visitDbgIntrinsic("value", cast<DbgValueInst>(CI));
break;
case Intrinsic::memcpy:
case Intrinsic::memmove:
@ -3012,6 +3018,24 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
};
}
template <class DbgIntrinsicTy>
void Verifier::visitDbgIntrinsic(StringRef Kind, DbgIntrinsicTy &DII) {
auto *MD = cast<MetadataAsValue>(DII.getArgOperand(0))->getMetadata();
Assert(isa<ValueAsMetadata>(MD) ||
(isa<MDNode>(MD) && !cast<MDNode>(MD)->getNumOperands()),
"invalid llvm.dbg." + Kind + " intrinsic address/value", &DII, MD);
Assert(isa<MDLocalVariable>(DII.getRawVariable()),
"invalid llvm.dbg." + Kind + " intrinsic variable", &DII,
DII.getRawVariable());
Assert(isa<MDExpression>(DII.getRawExpression()),
"invalid llvm.dbg." + Kind + " intrinsic expression", &DII,
DII.getRawExpression());
// Don't call visitMDNode(), since that will recurse through operands.
visitMDLocalVariable(*cast<MDLocalVariable>(DII.getVariable()));
visitMDExpression(*cast<MDExpression>(DII.getExpression()));
}
void DebugInfoVerifier::verifyDebugInfo() {
if (!VerifyDebugInfo)
return;

View File

@ -12,7 +12,7 @@ entry:
!2 = !MDCompileUnit(language: DW_LANG_Mips_Assembler, producer: "clang version 3.3 ", isOptimized: false, emissionKind: 1, file: !4, enums: !3, retainedTypes: !3, subprograms: !3, globals: !3, imports: !3)
!3 = !{}
!0 = !MDLocation(line: 662302, column: 26, scope: !1)
!1 = !{i32 4, !"foo"}
!1 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "foo")
!4 = !MDFile(filename: "scratch.cpp", directory: "/usr/local/google/home/blaikie/dev/scratch")
declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone

View File

@ -17,7 +17,7 @@ entry:
%retval = alloca i32, align 4
%i.addr = alloca i64, align 8
store i64 %i, i64* %i.addr, align 8
call void @llvm.dbg.declare(metadata i64* %i.addr, metadata !13, metadata !{}), !dbg !14
call void @llvm.dbg.declare(metadata i64* %i.addr, metadata !13, metadata !MDExpression()), !dbg !14
%0 = load i64, i64* %i.addr, align 8, !dbg !15
; CHECK: %0 = load i64, i64* %i.addr, align 8, !dbg ![[ENTRY:[0-9]+]]
%cmp = icmp slt i64 %0, 5, !dbg !15

View File

@ -4,10 +4,10 @@
define i8* @vfs_addname(i8* %name, i32 %len, i32 %hash, i32 %flags) nounwind ssp {
entry:
call void @llvm.dbg.value(metadata i8* %name, i64 0, metadata !0, metadata !{})
call void @llvm.dbg.value(metadata i32 %len, i64 0, metadata !10, metadata !{})
call void @llvm.dbg.value(metadata i32 %hash, i64 0, metadata !11, metadata !{})
call void @llvm.dbg.value(metadata i32 %flags, i64 0, metadata !12, metadata !{})
call void @llvm.dbg.value(metadata i8* %name, i64 0, metadata !0, metadata !MDExpression())
call void @llvm.dbg.value(metadata i32 %len, i64 0, metadata !10, metadata !MDExpression())
call void @llvm.dbg.value(metadata i32 %hash, i64 0, metadata !11, metadata !MDExpression())
call void @llvm.dbg.value(metadata i32 %flags, i64 0, metadata !12, metadata !MDExpression())
; CHECK: call fastcc i8* @add_name_internal(i8* %name, i32 %hash) [[NUW:#[0-9]+]], !dbg !{{[0-9]+}}
%0 = call fastcc i8* @add_name_internal(i8* %name, i32 %len, i32 %hash, i8 zeroext 0, i32 %flags) nounwind, !dbg !13 ; <i8*> [#uses=1]
ret i8* %0, !dbg !13
@ -17,11 +17,11 @@ declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
define internal fastcc i8* @add_name_internal(i8* %name, i32 %len, i32 %hash, i8 zeroext %extra, i32 %flags) noinline nounwind ssp {
entry:
call void @llvm.dbg.value(metadata i8* %name, i64 0, metadata !15, metadata !{})
call void @llvm.dbg.value(metadata i32 %len, i64 0, metadata !20, metadata !{})
call void @llvm.dbg.value(metadata i32 %hash, i64 0, metadata !21, metadata !{})
call void @llvm.dbg.value(metadata i8 %extra, i64 0, metadata !22, metadata !{})
call void @llvm.dbg.value(metadata i32 %flags, i64 0, metadata !23, metadata !{})
call void @llvm.dbg.value(metadata i8* %name, i64 0, metadata !15, metadata !MDExpression())
call void @llvm.dbg.value(metadata i32 %len, i64 0, metadata !20, metadata !MDExpression())
call void @llvm.dbg.value(metadata i32 %hash, i64 0, metadata !21, metadata !MDExpression())
call void @llvm.dbg.value(metadata i8 %extra, i64 0, metadata !22, metadata !MDExpression())
call void @llvm.dbg.value(metadata i32 %flags, i64 0, metadata !23, metadata !MDExpression())
%0 = icmp eq i32 %hash, 0, !dbg !24 ; <i1> [#uses=1]
br i1 %0, label %bb, label %bb1, !dbg !24

View File

@ -118,7 +118,7 @@ entry:
; Insert a meaningless dbg.value intrinsic; it should have no
; effect on the working of DSE in any way.
call void @llvm.dbg.value(metadata i32* undef, i64 0, metadata !10, metadata !{})
call void @llvm.dbg.value(metadata i32* undef, i64 0, metadata !10, metadata !MDExpression())
; CHECK: store i32 -1, i32* @x, align 4
store i32 -1, i32* @x, align 4
@ -255,7 +255,7 @@ declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
!7 = !{!8}
!8 = !MDBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
!9 = !{!10}
!10 = !MDGlobalVariable(name: "x", line: 1, isLocal: false, isDefinition: true, scope: null, file: !5, type: !8, variable: i32* @x)
!10 = !MDLocalVariable(tag: DW_TAG_auto_variable, name: "x", scope: !4, type: !8)
!11 = !{i32 2, !"Dwarf Version", i32 4}
!12 = !{i32* undef}

View File

@ -18,17 +18,17 @@ entry:
%__begin = alloca i8*, align 8
%__end = alloca i8*, align 8
%spec = alloca i8, align 1
call void @llvm.dbg.declare(metadata %struct.vector** %__range, metadata !27, metadata !{}), !dbg !30
call void @llvm.dbg.declare(metadata %struct.vector** %__range, metadata !27, metadata !MDExpression()), !dbg !30
br label %0
; <label>:0 ; preds = %entry
call void @_Z13TagFieldSpecsv(), !dbg !31
store %struct.vector* %ref.tmp, %struct.vector** %__range, align 8, !dbg !31
call void @llvm.dbg.declare(metadata i8** %__begin, metadata !32, metadata !{}), !dbg !30
call void @llvm.dbg.declare(metadata i8** %__begin, metadata !32, metadata !MDExpression()), !dbg !30
%1 = load %struct.vector*, %struct.vector** %__range, align 8, !dbg !31
%call = call i8* @_ZN6vector5beginEv(%struct.vector* %1), !dbg !31
store i8* %call, i8** %__begin, align 8, !dbg !31
call void @llvm.dbg.declare(metadata i8** %__end, metadata !33, metadata !{}), !dbg !30
call void @llvm.dbg.declare(metadata i8** %__end, metadata !33, metadata !MDExpression()), !dbg !30
%2 = load %struct.vector*, %struct.vector** %__range, align 8, !dbg !31
%call1 = call i8* @_ZN6vector3endEv(%struct.vector* %2), !dbg !31
store i8* %call1, i8** %__end, align 8, !dbg !31
@ -41,7 +41,7 @@ for.cond: ; preds = %for.inc, %0
br i1 %cmp, label %for.body, label %for.end, !dbg !34
for.body: ; preds = %for.cond
call void @llvm.dbg.declare(metadata i8* %spec, metadata !37, metadata !{}), !dbg !31
call void @llvm.dbg.declare(metadata i8* %spec, metadata !37, metadata !MDExpression()), !dbg !31
%5 = load i8*, i8** %__begin, align 8, !dbg !38
%6 = load i8, i8* %5, align 1, !dbg !38
store i8 %6, i8* %spec, align 1, !dbg !38

View File

@ -12,11 +12,11 @@ declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
define <4 x float> @inner_vectors(<4 x float> %a, <4 x float> %b) {
entry:
call void @llvm.dbg.value(metadata !{}, i64 0, metadata !{}, metadata !{})
call void @llvm.dbg.value(metadata i32 undef, i64 0, metadata !MDLocalVariable(tag: DW_TAG_auto_variable), metadata !MDExpression())
%mul = fmul <4 x float> %a, <float 3.000000e+00, float 3.000000e+00, float 3.000000e+00, float 3.000000e+00>
call void @llvm.dbg.value(metadata !{}, i64 0, metadata !{}, metadata !{})
call void @llvm.dbg.value(metadata i32 undef, i64 0, metadata !MDLocalVariable(tag: DW_TAG_auto_variable), metadata !MDExpression())
%mul1 = fmul <4 x float> %b, <float 5.000000e+00, float 5.000000e+00, float 5.000000e+00, float 5.000000e+00>
call void @llvm.dbg.value(metadata !{}, i64 0, metadata !{}, metadata !{})
call void @llvm.dbg.value(metadata i32 undef, i64 0, metadata !MDLocalVariable(tag: DW_TAG_auto_variable), metadata !MDExpression())
%add = fadd <4 x float> %mul, %mul1
ret <4 x float> %add
}
@ -27,10 +27,10 @@ define float @outer_vectors(<4 x float> %a, <4 x float> %b) {
; CHECK: ret float
entry:
call void @llvm.dbg.value(metadata !{}, i64 0, metadata !{}, metadata !{})
call void @llvm.dbg.value(metadata !{}, i64 0, metadata !{}, metadata !{})
call void @llvm.dbg.value(metadata i32 undef, i64 0, metadata !MDLocalVariable(tag: DW_TAG_auto_variable), metadata !MDExpression())
call void @llvm.dbg.value(metadata i32 undef, i64 0, metadata !MDLocalVariable(tag: DW_TAG_auto_variable), metadata !MDExpression())
%call = call <4 x float> @inner_vectors(<4 x float> %a, <4 x float> %b)
call void @llvm.dbg.value(metadata !{}, i64 0, metadata !{}, metadata !{})
call void @llvm.dbg.value(metadata i32 undef, i64 0, metadata !MDLocalVariable(tag: DW_TAG_auto_variable), metadata !MDExpression())
%vecext = extractelement <4 x float> %call, i32 0
%vecext1 = extractelement <4 x float> %call, i32 1
%add = fadd float %vecext, %vecext1

View File

@ -14,11 +14,11 @@ entry:
store i8* %__dest, i8** %__dest.addr, align 8
; CHECK-NOT: call void @llvm.dbg.declare
; CHECK: call void @llvm.dbg.value
call void @llvm.dbg.declare(metadata i8** %__dest.addr, metadata !0, metadata !{}), !dbg !16
call void @llvm.dbg.declare(metadata i8** %__dest.addr, metadata !0, metadata !MDExpression()), !dbg !16
store i32 %__val, i32* %__val.addr, align 4
call void @llvm.dbg.declare(metadata i32* %__val.addr, metadata !7, metadata !{}), !dbg !18
call void @llvm.dbg.declare(metadata i32* %__val.addr, metadata !7, metadata !MDExpression()), !dbg !18
store i64 %__len, i64* %__len.addr, align 8
call void @llvm.dbg.declare(metadata i64* %__len.addr, metadata !9, metadata !{}), !dbg !20
call void @llvm.dbg.declare(metadata i64* %__len.addr, metadata !9, metadata !MDExpression()), !dbg !20
%tmp = load i8*, i8** %__dest.addr, align 8, !dbg !21
%tmp1 = load i32, i32* %__val.addr, align 4, !dbg !21
%tmp2 = load i64, i64* %__len.addr, align 8, !dbg !21

View File

@ -15,7 +15,7 @@ if.then: ; preds = %for.body
if.then27: ; preds = %if.then
; CHECK: tail call void @llvm.dbg.value
tail call void @llvm.dbg.value(metadata double undef, i64 0, metadata !19, metadata !{}), !dbg !21
tail call void @llvm.dbg.value(metadata double undef, i64 0, metadata !19, metadata !MDExpression()), !dbg !21
br label %for.body61.us
if.end.if.end.split_crit_edge.critedge: ; preds = %if.then

View File

@ -5,8 +5,8 @@ target triple = "x86_64-apple-darwin10.0.0"
define void @foo(double* nocapture %a) nounwind ssp {
entry:
tail call void @llvm.dbg.value(metadata double* %a, i64 0, metadata !5, metadata !{}), !dbg !8
tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !10, metadata !{}), !dbg !14
tail call void @llvm.dbg.value(metadata double* %a, i64 0, metadata !5, metadata !MDExpression()), !dbg !8
tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !10, metadata !MDExpression()), !dbg !14
br label %for.body
for.body: ; preds = %entry, %for.body
@ -19,7 +19,7 @@ for.body: ; preds = %entry, %for.body
br i1 %exitcond, label %for.body, label %for.end, !dbg !14
for.end: ; preds = %for.body
tail call void @llvm.dbg.value(metadata !{null}, i64 0, metadata !10, metadata !{}), !dbg !16
tail call void @llvm.dbg.value(metadata !{null}, i64 0, metadata !10, metadata !MDExpression()), !dbg !16
ret void, !dbg !17
}

View File

@ -15,9 +15,9 @@ tailrecurse: ; preds = %if.then, %entry
%x.tr = phi i32 [ %x, %entry ], [ %call, %if.then ]
%y.tr = phi i32 [ %y, %entry ], [ %call9, %if.then ]
%z.tr = phi i32 [ %z, %entry ], [ %call14, %if.then ]
tail call void @llvm.dbg.value(metadata i32 %x.tr, i64 0, metadata !6, metadata !{}), !dbg !7
tail call void @llvm.dbg.value(metadata i32 %y.tr, i64 0, metadata !8, metadata !{}), !dbg !9
tail call void @llvm.dbg.value(metadata i32 %z.tr, i64 0, metadata !10, metadata !{}), !dbg !11
tail call void @llvm.dbg.value(metadata i32 %x.tr, i64 0, metadata !6, metadata !MDExpression()), !dbg !7
tail call void @llvm.dbg.value(metadata i32 %y.tr, i64 0, metadata !8, metadata !MDExpression()), !dbg !9
tail call void @llvm.dbg.value(metadata i32 %z.tr, i64 0, metadata !10, metadata !MDExpression()), !dbg !11
%cmp = icmp slt i32 %y.tr, %x.tr, !dbg !12
br i1 %cmp, label %if.then, label %if.end, !dbg !12
@ -72,7 +72,7 @@ for.body:
for.inc:
%dec = add i64 %i.0, -1
tail call void @llvm.dbg.value(metadata i64 %dec, i64 0, metadata !{!"undef"}, metadata !{})
tail call void @llvm.dbg.value(metadata i64 %dec, i64 0, metadata !MDLocalVariable(tag: DW_TAG_auto_variable), metadata !MDExpression())
br label %for.cond
for.end:

View File

@ -11,7 +11,7 @@ target triple = "x86_64-apple-macosx10.8.0"
; CHECK-LABEL: @test(
define i32 @test() #0 {
entry:
tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !9, metadata !{}), !dbg !18
tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !9, metadata !MDExpression()), !dbg !18
br label %for.body, !dbg !18
for.body:
@ -25,7 +25,7 @@ for.body:
%arrayidx4 = getelementptr inbounds [1024 x i32], [1024 x i32]* @A, i64 0, i64 %indvars.iv, !dbg !19
store i32 %add, i32* %arrayidx4, align 4, !dbg !19
%indvars.iv.next = add i64 %indvars.iv, 1, !dbg !18
tail call void @llvm.dbg.value(metadata !{null}, i64 0, metadata !9, metadata !{}), !dbg !18
tail call void @llvm.dbg.value(metadata !{null}, i64 0, metadata !9, metadata !MDExpression()), !dbg !18
%lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !18
%exitcond = icmp ne i32 %lftr.wideiv, 1024, !dbg !18
br i1 %exitcond, label %for.body, label %for.end, !dbg !18

View File

@ -19,10 +19,10 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
define i32 @f(i32* nocapture %a, i32 %size) #0 {
entry:
tail call void @llvm.dbg.value(metadata i32* %a, i64 0, metadata !13, metadata !{}), !dbg !19
tail call void @llvm.dbg.value(metadata i32 %size, i64 0, metadata !14, metadata !{}), !dbg !19
tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !15, metadata !{}), !dbg !20
tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !16, metadata !{}), !dbg !21
tail call void @llvm.dbg.value(metadata i32* %a, i64 0, metadata !13, metadata !MDExpression()), !dbg !19
tail call void @llvm.dbg.value(metadata i32 %size, i64 0, metadata !14, metadata !MDExpression()), !dbg !19
tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !15, metadata !MDExpression()), !dbg !20
tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !16, metadata !MDExpression()), !dbg !21
%cmp4 = icmp eq i32 %size, 0, !dbg !21
br i1 %cmp4, label %for.end, label %for.body.lr.ph, !dbg !21
@ -35,9 +35,9 @@ for.body: ; preds = %for.body.lr.ph, %fo
%arrayidx = getelementptr inbounds i32, i32* %a, i64 %indvars.iv, !dbg !22
%0 = load i32, i32* %arrayidx, align 4, !dbg !22
%add = add i32 %0, %sum.05, !dbg !22
tail call void @llvm.dbg.value(metadata i32 %add.lcssa, i64 0, metadata !15, metadata !{}), !dbg !22
tail call void @llvm.dbg.value(metadata i32 %add.lcssa, i64 0, metadata !15, metadata !MDExpression()), !dbg !22
%indvars.iv.next = add i64 %indvars.iv, 1, !dbg !21
tail call void @llvm.dbg.value(metadata !{null}, i64 0, metadata !16, metadata !{}), !dbg !21
tail call void @llvm.dbg.value(metadata !{null}, i64 0, metadata !16, metadata !MDExpression()), !dbg !21
%lftr.wideiv = trunc i64 %indvars.iv.next to i32, !dbg !21
%exitcond = icmp ne i32 %lftr.wideiv, %size, !dbg !21
br i1 %exitcond, label %for.body, label %for.cond.for.end_crit_edge, !dbg !21

View File

@ -7,13 +7,13 @@ entry:
%retval = alloca double ; <double*> [#uses=2]
%0 = alloca double ; <double*> [#uses=2]
%"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
call void @llvm.dbg.declare(metadata i32* %i_addr, metadata !0, metadata !{}), !dbg !8
call void @llvm.dbg.declare(metadata i32* %i_addr, metadata !0, metadata !MDExpression()), !dbg !8
; CHECK: call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata ![[IVAR:[0-9]*]], metadata {{.*}})
; CHECK: call void @llvm.dbg.value(metadata double %j, i64 0, metadata ![[JVAR:[0-9]*]], metadata {{.*}})
; CHECK: ![[IVAR]] = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "i"
; CHECK: ![[JVAR]] = !MDLocalVariable(tag: DW_TAG_arg_variable, name: "j"
store i32 %i, i32* %i_addr
call void @llvm.dbg.declare(metadata double* %j_addr, metadata !9, metadata !{}), !dbg !8
call void @llvm.dbg.declare(metadata double* %j_addr, metadata !9, metadata !MDExpression()), !dbg !8
store double %j, double* %j_addr
%1 = load i32, i32* %i_addr, align 4, !dbg !10 ; <i32> [#uses=1]
%2 = add nsw i32 %1, 1, !dbg !10 ; <i32> [#uses=1]

View File

@ -11,14 +11,14 @@ entry:
%z_addr.i = alloca i8* ; <i8**> [#uses=2]
%a_addr = alloca i32 ; <i32*> [#uses=2]
%"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
call void @llvm.dbg.declare(metadata i32* %a_addr, metadata !0, metadata !{}), !dbg !7
call void @llvm.dbg.declare(metadata i32* %a_addr, metadata !0, metadata !MDExpression()), !dbg !7
store i32 %a, i32* %a_addr
%0 = load i32, i32* %a_addr, align 4, !dbg !8 ; <i32> [#uses=1]
call void @llvm.dbg.declare(metadata i32* %x_addr.i, metadata !9, metadata !{}) nounwind, !dbg !15
call void @llvm.dbg.declare(metadata i32* %x_addr.i, metadata !9, metadata !MDExpression()) nounwind, !dbg !15
store i32 %0, i32* %x_addr.i
call void @llvm.dbg.declare(metadata i64* %y_addr.i, metadata !16, metadata !{}) nounwind, !dbg !15
call void @llvm.dbg.declare(metadata i64* %y_addr.i, metadata !16, metadata !MDExpression()) nounwind, !dbg !15
store i64 55, i64* %y_addr.i
call void @llvm.dbg.declare(metadata i8** %z_addr.i, metadata !17, metadata !{}) nounwind, !dbg !15
call void @llvm.dbg.declare(metadata i8** %z_addr.i, metadata !17, metadata !MDExpression()) nounwind, !dbg !15
store i8* bitcast (void (i32)* @baz to i8*), i8** %z_addr.i
%1 = load i32, i32* %x_addr.i, align 4, !dbg !18 ; <i32> [#uses=1]
%2 = load i64, i64* %y_addr.i, align 8, !dbg !18 ; <i64> [#uses=1]

View File

@ -2679,8 +2679,8 @@ define {<2 x float>, <2 x float>} @"\01-[A z]"({}* %self, i8* nocapture %_cmd) n
invoke.cont:
%0 = bitcast {}* %self to i8*
%1 = tail call i8* @objc_retain(i8* %0) nounwind
tail call void @llvm.dbg.value(metadata {}* %self, i64 0, metadata !0, metadata !{})
tail call void @llvm.dbg.value(metadata {}* %self, i64 0, metadata !0, metadata !{})
tail call void @llvm.dbg.value(metadata {}* %self, i64 0, metadata !MDLocalVariable(tag: DW_TAG_auto_variable), metadata !MDExpression())
tail call void @llvm.dbg.value(metadata {}* %self, i64 0, metadata !MDLocalVariable(tag: DW_TAG_auto_variable), metadata !MDExpression())
%ivar = load i64, i64* @"OBJC_IVAR_$_A.myZ", align 8
%add.ptr = getelementptr i8, i8* %0, i64 %ivar
%tmp1 = bitcast i8* %add.ptr to float*

View File

@ -41,10 +41,10 @@ entry:
%tmp2 = bitcast %struct._class_t* %tmp to i8*, !dbg !37
; CHECK: call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* %tmp2, i8* %tmp1)
%call = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* %tmp2, i8* %tmp1), !dbg !37, !clang.arc.no_objc_arc_exceptions !38
call void @llvm.dbg.value(metadata i8* %call, i64 0, metadata i32 02, metadata !{}), !dbg !37
call void @llvm.dbg.value(metadata i8* %call, i64 0, metadata !25, metadata !MDExpression()), !dbg !37
; CHECK: call i8* @objc_retain(i8* %call) [[NUW:#[0-9]+]]
%tmp3 = call i8* @objc_retain(i8* %call) nounwind, !dbg !39
call void @llvm.dbg.value(metadata i8* %call, i64 0, metadata !25, metadata !{}), !dbg !39
call void @llvm.dbg.value(metadata i8* %call, i64 0, metadata !25, metadata !MDExpression()), !dbg !39
invoke fastcc void @ThrowFunc(i8* %call)
to label %eh.cont unwind label %lpad, !dbg !40, !clang.arc.no_objc_arc_exceptions !38
@ -58,7 +58,7 @@ lpad: ; preds = %entry
catch i8* null, !dbg !40
%tmp5 = extractvalue { i8*, i32 } %tmp4, 0, !dbg !40
%exn.adjusted = call i8* @objc_begin_catch(i8* %tmp5) nounwind, !dbg !44
call void @llvm.dbg.value(metadata i8 0, i64 0, metadata !21, metadata !{}), !dbg !46
call void @llvm.dbg.value(metadata i8 0, i64 0, metadata !21, metadata !MDExpression()), !dbg !46
call void @objc_end_catch(), !dbg !49, !clang.arc.no_objc_arc_exceptions !38
; CHECK: call void @objc_release(i8* %call)
call void @objc_release(i8* %call) nounwind, !dbg !42, !clang.imprecise_release !38
@ -87,7 +87,7 @@ declare void @objc_exception_rethrow()
define internal fastcc void @ThrowFunc(i8* %obj) uwtable noinline ssp {
entry:
%tmp = call i8* @objc_retain(i8* %obj) nounwind
call void @llvm.dbg.value(metadata i8* %obj, i64 0, metadata !32, metadata !{}), !dbg !55
call void @llvm.dbg.value(metadata i8* %obj, i64 0, metadata !32, metadata !MDExpression()), !dbg !55
%tmp1 = load %struct._class_t*, %struct._class_t** @"\01L_OBJC_CLASSLIST_REFERENCES_$_1", align 8, !dbg !56
%tmp2 = load i8*, i8** @"\01L_OBJC_SELECTOR_REFERENCES_5", align 8, !dbg !56, !invariant.load !38
%tmp3 = bitcast %struct._class_t* %tmp1 to i8*, !dbg !56

View File

@ -23,11 +23,11 @@ target triple = "x86_64-apple-macosx10.7.0"
define i32 @depth(double* nocapture %A, i32 %m) #0 {
entry:
tail call void @llvm.dbg.value(metadata double* %A, i64 0, metadata !12, metadata !{}), !dbg !19
tail call void @llvm.dbg.value(metadata i32 %m, i64 0, metadata !13, metadata !{}), !dbg !19
tail call void @llvm.dbg.value(metadata i32 00, i64 0, metadata !14, metadata !{}), !dbg !21
tail call void @llvm.dbg.value(metadata i32 02, i64 0, metadata !15, metadata !{}), !dbg !21
tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !16, metadata !{}), !dbg !23
tail call void @llvm.dbg.value(metadata double* %A, i64 0, metadata !12, metadata !MDExpression()), !dbg !19
tail call void @llvm.dbg.value(metadata i32 %m, i64 0, metadata !13, metadata !MDExpression()), !dbg !19
tail call void @llvm.dbg.value(metadata i32 00, i64 0, metadata !14, metadata !MDExpression()), !dbg !21
tail call void @llvm.dbg.value(metadata i32 02, i64 0, metadata !15, metadata !MDExpression()), !dbg !21
tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !16, metadata !MDExpression()), !dbg !23
%cmp8 = icmp sgt i32 %m, 0, !dbg !23
br i1 %cmp8, label %for.body.lr.ph, label %for.end, !dbg !23

View File

@ -32,8 +32,8 @@ define i32 @main(i32 %argc, i8** nocapture readonly %argv) #0 {
; CHECK: Printing analysis 'Branch Probability Analysis' for function 'main':
entry:
tail call void @llvm.dbg.value(metadata i32 %argc, i64 0, metadata !13, metadata !{}), !dbg !27
tail call void @llvm.dbg.value(metadata i8** %argv, i64 0, metadata !14, metadata !{}), !dbg !27
tail call void @llvm.dbg.value(metadata i32 %argc, i64 0, metadata !13, metadata !MDExpression()), !dbg !27
tail call void @llvm.dbg.value(metadata i8** %argv, i64 0, metadata !14, metadata !MDExpression()), !dbg !27
%cmp = icmp slt i32 %argc, 2, !dbg !28
br i1 %cmp, label %return, label %if.end, !dbg !28
; CHECK: edge entry -> return probability is 1 / 2 = 50%
@ -43,7 +43,7 @@ if.end: ; preds = %entry
%arrayidx = getelementptr inbounds i8*, i8** %argv, i64 1, !dbg !30
%0 = load i8*, i8** %arrayidx, align 8, !dbg !30, !tbaa !31
%call = tail call i32 @atoi(i8* %0) #4, !dbg !30
tail call void @llvm.dbg.value(metadata i32 %call, i64 0, metadata !17, metadata !{}), !dbg !30
tail call void @llvm.dbg.value(metadata i32 %call, i64 0, metadata !17, metadata !MDExpression()), !dbg !30
%cmp1 = icmp sgt i32 %call, 100, !dbg !35
br i1 %cmp1, label %for.body, label %if.end6, !dbg !35
; CHECK: edge if.end -> for.body probability is 1 / 2 = 50%
@ -55,14 +55,14 @@ for.body: ; preds = %if.end, %for.body
%add = fadd double %s.015, 3.049000e+00, !dbg !36
%conv = sitofp i32 %u.016 to double, !dbg !36
%add4 = fadd double %add, %conv, !dbg !36
tail call void @llvm.dbg.value(metadata double %add4, i64 0, metadata !18, metadata !{}), !dbg !36
tail call void @llvm.dbg.value(metadata double %add4, i64 0, metadata !18, metadata !MDExpression()), !dbg !36
%div = fdiv double 3.940000e+00, %s.015, !dbg !37
%mul = fmul double %div, 3.200000e-01, !dbg !37
%add5 = fadd double %add4, %mul, !dbg !37
%sub = fsub double %add4, %add5, !dbg !37
tail call void @llvm.dbg.value(metadata double %sub, i64 0, metadata !18, metadata !{}), !dbg !37
tail call void @llvm.dbg.value(metadata double %sub, i64 0, metadata !18, metadata !MDExpression()), !dbg !37
%inc = add nsw i32 %u.016, 1, !dbg !38
tail call void @llvm.dbg.value(metadata i32 %inc, i64 0, metadata !21, metadata !{}), !dbg !38
tail call void @llvm.dbg.value(metadata i32 %inc, i64 0, metadata !21, metadata !MDExpression()), !dbg !38
%exitcond = icmp eq i32 %inc, %call, !dbg !38
br i1 %exitcond, label %if.end6, label %for.body, !dbg !38
; CHECK: edge for.body -> if.end6 probability is 1 / 10227 = 0.00977804

View File

@ -17,10 +17,10 @@ entry:
%b.addr = alloca i32, align 4
%c = alloca i32, align 4
store i32 %a, i32* %a.addr, align 4
call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !6, metadata !{}), !dbg !7
call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !6, metadata !MDExpression()), !dbg !7
store i32 %b, i32* %b.addr, align 4
call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !8, metadata !{}), !dbg !9
call void @llvm.dbg.declare(metadata i32* %c, metadata !10, metadata !{}), !dbg !12
call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !8, metadata !MDExpression()), !dbg !9
call void @llvm.dbg.declare(metadata i32* %c, metadata !10, metadata !MDExpression()), !dbg !12
%tmp = load i32, i32* %a.addr, align 4, !dbg !13
store i32 %tmp, i32* %c, align 4, !dbg !13
%tmp1 = load i32, i32* %a.addr, align 4, !dbg !14

View File

@ -37,9 +37,9 @@ define void @f1(<4 x i32>* nocapture %a, <4 x i32>* nocapture readonly %b, <4 x
; CHECK: store i32 %add.i3, i32* %a.i3, align 4, !dbg ![[TAG1]], !tbaa ![[TAG2]]
; CHECK: ret void
entry:
tail call void @llvm.dbg.value(metadata <4 x i32>* %a, i64 0, metadata !15, metadata !{}), !dbg !20
tail call void @llvm.dbg.value(metadata <4 x i32>* %b, i64 0, metadata !16, metadata !{}), !dbg !20
tail call void @llvm.dbg.value(metadata <4 x i32>* %c, i64 0, metadata !17, metadata !{}), !dbg !20
tail call void @llvm.dbg.value(metadata <4 x i32>* %a, i64 0, metadata !15, metadata !MDExpression()), !dbg !20
tail call void @llvm.dbg.value(metadata <4 x i32>* %b, i64 0, metadata !16, metadata !MDExpression()), !dbg !20
tail call void @llvm.dbg.value(metadata <4 x i32>* %c, i64 0, metadata !17, metadata !MDExpression()), !dbg !20
%bval = load <4 x i32>, <4 x i32>* %b, align 16, !dbg !21, !tbaa !22
%cval = load <4 x i32>, <4 x i32>* %c, align 16, !dbg !21, !tbaa !22
%add = add <4 x i32> %bval, %cval, !dbg !21

View File

@ -1,8 +1,8 @@
; RUN: opt -simplifycfg -S < %s | FileCheck %s
define i32 @foo(i32 %i) nounwind ssp {
call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !6, metadata !{}), !dbg !7
call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !9, metadata !{}), !dbg !11
call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !6, metadata !MDExpression()), !dbg !7
call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !9, metadata !MDExpression()), !dbg !11
%1 = icmp ne i32 %i, 0, !dbg !12
;CHECK: call i32 (...)* @bar()
;CHECK-NEXT: llvm.dbg.value
@ -10,12 +10,12 @@ define i32 @foo(i32 %i) nounwind ssp {
; <label>:2 ; preds = %0
%3 = call i32 (...)* @bar(), !dbg !13
call void @llvm.dbg.value(metadata i32 %3, i64 0, metadata !9, metadata !{}), !dbg !13
call void @llvm.dbg.value(metadata i32 %3, i64 0, metadata !9, metadata !MDExpression()), !dbg !13
br label %6, !dbg !15
; <label>:4 ; preds = %0
%5 = call i32 (...)* @bar(), !dbg !16
call void @llvm.dbg.value(metadata i32 %5, i64 0, metadata !9, metadata !{}), !dbg !16
call void @llvm.dbg.value(metadata i32 %5, i64 0, metadata !9, metadata !MDExpression()), !dbg !16
br label %6, !dbg !18
; <label>:6 ; preds = %4, %2

View File

@ -18,7 +18,7 @@ entry:
; Function Attrs: nounwind readonly ssp
define i32 @foo(i32 %i) #2 {
entry:
tail call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !15, metadata !{}), !dbg !20
tail call void @llvm.dbg.value(metadata i32 %i, i64 0, metadata !15, metadata !MDExpression()), !dbg !20
%.0 = load i32, i32* @xyz, align 4
ret i32 %.0, !dbg !21
}

View File

@ -0,0 +1,16 @@
; RUN: not llvm-as -disable-output <%s 2>&1 | FileCheck %s
; CHECK: invalid llvm.dbg.declare intrinsic address/value
; CHECK-NEXT: call void @llvm.dbg.declare({{.*}})
; CHECK-NEXT: !""
define void @foo(i32 %a) {
entry:
%s = alloca i32
call void @llvm.dbg.declare(metadata !"", metadata !MDLocalVariable(tag: DW_TAG_arg_variable), metadata !MDExpression())
ret void
}
declare void @llvm.dbg.declare(metadata, metadata, metadata)
!llvm.module.flags = !{!0}
!0 = !{i32 2, !"Debug Info Version", i32 3}

View File

@ -0,0 +1,16 @@
; RUN: not llvm-as -disable-output <%s 2>&1 | FileCheck %s
; CHECK: invalid llvm.dbg.declare intrinsic expression
; CHECK-NEXT: call void @llvm.dbg.declare({{.*}})
; CHECK-NEXT: !""
define void @foo(i32 %a) {
entry:
%s = alloca i32
call void @llvm.dbg.declare(metadata i32* %s, metadata !MDLocalVariable(tag: DW_TAG_arg_variable), metadata !"")
ret void
}
declare void @llvm.dbg.declare(metadata, metadata, metadata)
!llvm.module.flags = !{!0}
!0 = !{i32 2, !"Debug Info Version", i32 3}

View File

@ -0,0 +1,16 @@
; RUN: not llvm-as -disable-output <%s 2>&1 | FileCheck %s
; CHECK: invalid llvm.dbg.declare intrinsic variable
; CHECK-NEXT: call void @llvm.dbg.declare({{.*}})
; CHECK-NEXT: !""
define void @foo(i32 %a) {
entry:
%s = alloca i32
call void @llvm.dbg.declare(metadata i32* %s, metadata !"", metadata !MDExpression())
ret void
}
declare void @llvm.dbg.declare(metadata, metadata, metadata)
!llvm.module.flags = !{!0}
!0 = !{i32 2, !"Debug Info Version", i32 3}

View File

@ -0,0 +1,16 @@
; RUN: not llvm-as -disable-output <%s 2>&1 | FileCheck %s
; CHECK: invalid llvm.dbg.value intrinsic expression
; CHECK-NEXT: call void @llvm.dbg.value({{.*}})
; CHECK-NEXT: !""
define void @foo(i32 %a) {
entry:
%s = alloca i32
call void @llvm.dbg.value(metadata i32* %s, i64 0, metadata !MDLocalVariable(tag: DW_TAG_arg_variable), metadata !"")
ret void
}
declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
!llvm.module.flags = !{!0}
!0 = !{i32 2, !"Debug Info Version", i32 3}

View File

@ -0,0 +1,16 @@
; RUN: not llvm-as -disable-output <%s 2>&1 | FileCheck %s
; CHECK: invalid llvm.dbg.value intrinsic address/value
; CHECK-NEXT: call void @llvm.dbg.value({{.*}})
; CHECK-NEXT: !""
define void @foo(i32 %a) {
entry:
%s = alloca i32
call void @llvm.dbg.value(metadata !"", i64 0, metadata !MDLocalVariable(tag: DW_TAG_arg_variable), metadata !MDExpression())
ret void
}
declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
!llvm.module.flags = !{!0}
!0 = !{i32 2, !"Debug Info Version", i32 3}

View File

@ -0,0 +1,16 @@
; RUN: not llvm-as -disable-output <%s 2>&1 | FileCheck %s
; CHECK: invalid llvm.dbg.value intrinsic variable
; CHECK-NEXT: call void @llvm.dbg.value({{.*}})
; CHECK-NEXT: !""
define void @foo(i32 %a) {
entry:
%s = alloca i32
call void @llvm.dbg.value(metadata i32* %s, i64 0, metadata !"", metadata !MDExpression())
ret void
}
declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
!llvm.module.flags = !{!0}
!0 = !{i32 2, !"Debug Info Version", i32 3}