diff --git a/llvm/include/llvm/Transforms/Utils/Local.h b/llvm/include/llvm/Transforms/Utils/Local.h --- a/llvm/include/llvm/Transforms/Utils/Local.h +++ b/llvm/include/llvm/Transforms/Utils/Local.h @@ -240,17 +240,17 @@ /// /// Inserts a llvm.dbg.value intrinsic before a store to an alloca'd value -/// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic. +/// that has an associated llvm.dbg.declare intrinsic. void ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, StoreInst *SI, DIBuilder &Builder); /// Inserts a llvm.dbg.value intrinsic before a load of an alloca'd value -/// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic. +/// that has an associated llvm.dbg.declare intrinsic. void ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, LoadInst *LI, DIBuilder &Builder); /// Inserts a llvm.dbg.value intrinsic after a phi that has an associated -/// llvm.dbg.declare or llvm.dbg.addr intrinsic. +/// llvm.dbg.declare intrinsic. void ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, PHINode *LI, DIBuilder &Builder); diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -730,7 +730,7 @@ } namespace { -// Returns true if \p I is an intrisnic that does not read or write memory. +// Returns true if \p I is an intrinsic that does not read or write memory. bool isNoopIntrinsic(Instruction *I) { if (const IntrinsicInst *II = dyn_cast(I)) { switch (II->getIntrinsicID()) { @@ -740,7 +740,6 @@ case Intrinsic::launder_invariant_group: case Intrinsic::assume: return true; - case Intrinsic::dbg_addr: case Intrinsic::dbg_declare: case Intrinsic::dbg_label: case Intrinsic::dbg_value: diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp --- a/llvm/lib/Transforms/Scalar/SROA.cpp +++ b/llvm/lib/Transforms/Scalar/SROA.cpp @@ -4739,11 +4739,13 @@ // Migrate debug information from the old alloca to the new alloca(s) // and the individual partitions. - TinyPtrVector DbgDeclares = FindDbgAddrUses(&AI); + TinyPtrVector DbgVariables; + for (auto *DbgDeclare : FindDbgDeclareUses(&AI)) + DbgVariables.push_back(DbgDeclare); for (auto *DbgAssign : at::getAssignmentMarkers(&AI)) - DbgDeclares.push_back(DbgAssign); - for (DbgVariableIntrinsic *DbgDeclare : DbgDeclares) { - auto *Expr = DbgDeclare->getExpression(); + DbgVariables.push_back(DbgAssign); + for (DbgVariableIntrinsic *DbgVariable : DbgVariables) { + auto *Expr = DbgVariable->getExpression(); DIBuilder DIB(*AI.getModule(), /*AllowUnresolved*/ false); uint64_t AllocaSize = DL.getTypeSizeInBits(AI.getAllocatedType()).getFixedValue(); @@ -4775,7 +4777,7 @@ } // The alloca may be larger than the variable. - auto VarSize = DbgDeclare->getVariable()->getSizeInBits(); + auto VarSize = DbgVariable->getVariable()->getSizeInBits(); if (VarSize) { if (Size > *VarSize) Size = *VarSize; @@ -4795,18 +4797,18 @@ // Remove any existing intrinsics on the new alloca describing // the variable fragment. - for (DbgVariableIntrinsic *OldDII : FindDbgAddrUses(Fragment.Alloca)) { + for (DbgDeclareInst *OldDII : FindDbgDeclareUses(Fragment.Alloca)) { auto SameVariableFragment = [](const DbgVariableIntrinsic *LHS, const DbgVariableIntrinsic *RHS) { return LHS->getVariable() == RHS->getVariable() && LHS->getDebugLoc()->getInlinedAt() == RHS->getDebugLoc()->getInlinedAt(); }; - if (SameVariableFragment(OldDII, DbgDeclare)) + if (SameVariableFragment(OldDII, DbgVariable)) OldDII->eraseFromParent(); } - if (auto *DbgAssign = dyn_cast(DbgDeclare)) { + if (auto *DbgAssign = dyn_cast(DbgVariable)) { if (!Fragment.Alloca->hasMetadata(LLVMContext::MD_DIAssignID)) { Fragment.Alloca->setMetadata( LLVMContext::MD_DIAssignID, @@ -4820,8 +4822,8 @@ LLVM_DEBUG(dbgs() << "Created new assign intrinsic: " << *NewAssign << "\n"); } else { - DIB.insertDeclare(Fragment.Alloca, DbgDeclare->getVariable(), - FragmentExpr, DbgDeclare->getDebugLoc(), &AI); + DIB.insertDeclare(Fragment.Alloca, DbgVariable->getVariable(), + FragmentExpr, DbgVariable->getDebugLoc(), &AI); } } } @@ -4945,7 +4947,7 @@ // not be able to find it. if (AllocaInst *AI = dyn_cast(I)) { DeletedAllocas.insert(AI); - for (DbgVariableIntrinsic *OldDII : FindDbgAddrUses(AI)) + for (DbgDeclareInst *OldDII : FindDbgDeclareUses(AI)) OldDII->eraseFromParent(); } diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp --- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -379,8 +379,8 @@ /// /// Possible improvements: /// - Check fully overlapping fragments and not only identical fragments. -/// - Support dbg.addr, dbg.declare. dbg.label, and possibly other meta -/// instructions being part of the sequence of consecutive instructions. +/// - Support dbg.declare. dbg.label, and possibly other meta instructions being +/// part of the sequence of consecutive instructions. static bool removeRedundantDbgInstrsUsingBackwardScan(BasicBlock *BB) { SmallVector ToBeRemoved; SmallDenseSet VariableSet; diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1486,11 +1486,10 @@ /// (or fragment of the variable) described by \p DII. /// /// This is primarily intended as a helper for the different -/// ConvertDebugDeclareToDebugValue functions. The dbg.declare/dbg.addr that is -/// converted describes an alloca'd variable, so we need to use the -/// alloc size of the value when doing the comparison. E.g. an i1 value will be -/// identified as covering an n-bit fragment, if the store size of i1 is at -/// least n bits. +/// ConvertDebugDeclareToDebugValue functions. The dbg.declare that is converted +/// describes an alloca'd variable, so we need to use the alloc size of the +/// value when doing the comparison. E.g. an i1 value will be identified as +/// covering an n-bit fragment, if the store size of i1 is at least n bits. static bool valueCoversEntireFragment(Type *ValTy, DbgVariableIntrinsic *DII) { const DataLayout &DL = DII->getModule()->getDataLayout(); TypeSize ValueSize = DL.getTypeAllocSizeInBits(ValTy); @@ -1519,7 +1518,7 @@ } /// Inserts a llvm.dbg.value intrinsic before a store to an alloca'd value -/// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic. +/// that has an associated llvm.dbg.declare intrinsic. void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, StoreInst *SI, DIBuilder &Builder) { assert(DII->isAddressOfVariable() || isa(DII)); @@ -1562,7 +1561,7 @@ } /// Inserts a llvm.dbg.value intrinsic before a load of an alloca'd value -/// that has an associated llvm.dbg.declare or llvm.dbg.addr intrinsic. +/// that has an associated llvm.dbg.declare intrinsic. void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, LoadInst *LI, DIBuilder &Builder) { auto *DIVar = DII->getVariable(); @@ -1590,7 +1589,7 @@ } /// Inserts a llvm.dbg.value intrinsic after a phi that has an associated -/// llvm.dbg.declare or llvm.dbg.addr intrinsic. +/// llvm.dbg.declare intrinsic. void llvm::ConvertDebugDeclareToDebugValue(DbgVariableIntrinsic *DII, PHINode *APN, DIBuilder &Builder) { auto *DIVar = DII->getVariable(); @@ -1773,8 +1772,8 @@ bool llvm::replaceDbgDeclare(Value *Address, Value *NewAddress, DIBuilder &Builder, uint8_t DIExprFlags, int Offset) { - auto DbgAddrs = FindDbgAddrUses(Address); - for (DbgVariableIntrinsic *DII : DbgAddrs) { + auto DbgDeclares = FindDbgDeclareUses(Address); + for (DbgVariableIntrinsic *DII : DbgDeclares) { const DebugLoc &Loc = DII->getDebugLoc(); auto *DIVar = DII->getVariable(); auto *DIExpr = DII->getExpression(); @@ -1785,7 +1784,7 @@ Builder.insertDeclare(NewAddress, DIVar, DIExpr, Loc, DII); DII->eraseFromParent(); } - return !DbgAddrs.empty(); + return !DbgDeclares.empty(); } static void replaceOneDbgValueForAlloca(DbgValueInst *DVI, Value *NewAddress, @@ -1881,9 +1880,8 @@ continue; } - // Do not add DW_OP_stack_value for DbgDeclare and DbgAddr, because they - // are implicitly pointing out the value as a DWARF memory location - // description. + // Do not add DW_OP_stack_value for DbgDeclare, because they are implicitly + // pointing out the value as a DWARF memory location description. bool StackValue = isa(DII); auto DIILocation = DII->location_ops(); assert( @@ -1923,9 +1921,9 @@ MaxDebugArgs) { DII->addVariableLocationOps(AdditionalValues, SalvagedExpr); } else { - // Do not salvage using DIArgList for dbg.addr/dbg.declare, as it is - // not currently supported in those instructions. Do not salvage using - // DIArgList for dbg.assign yet. FIXME: support this. + // Do not salvage using DIArgList for dbg.declare, as it is not currently + // supported in those instructions. Do not salvage using DIArgList for + // dbg.assign yet. FIXME: support this. // Also do not salvage if the resulting DIArgList would contain an // unreasonably large number of values. DII->setKillLocation(); diff --git a/llvm/lib/Transforms/Utils/MemoryOpRemark.cpp b/llvm/lib/Transforms/Utils/MemoryOpRemark.cpp --- a/llvm/lib/Transforms/Utils/MemoryOpRemark.cpp +++ b/llvm/lib/Transforms/Utils/MemoryOpRemark.cpp @@ -321,7 +321,7 @@ // Try to get an llvm.dbg.declare, which has a DILocalVariable giving us the // real debug info name and size of the variable. for (const DbgVariableIntrinsic *DVI : - FindDbgAddrUses(const_cast(V))) { + FindDbgDeclareUses(const_cast(V))) { if (DILocalVariable *DILV = DVI->getVariable()) { std::optional DISize = getSizeInBytes(DILV->getSizeInBits()); VariableInfo Var{DILV->getName(), DISize}; diff --git a/llvm/test/Transforms/Mem2Reg/dbg-addr-inline-dse.ll b/llvm/test/Transforms/Mem2Reg/dbg-addr-inline-dse.ll deleted file mode 100644 --- a/llvm/test/Transforms/Mem2Reg/dbg-addr-inline-dse.ll +++ /dev/null @@ -1,94 +0,0 @@ -; RUN: opt -passes=mem2reg -S < %s | FileCheck %s -implicit-check-not="call void @llvm.dbg.addr" - -; This example is intended to simulate this pass pipeline, which may not exist -; in practice: -; 1. DSE f from the original C source -; 2. Inline escape -; 3. mem2reg -; This exercises the corner case of multiple llvm.dbg.addr intrinsics. - -; C source: -; -; void escape(int *px) { ++*px; } -; extern int global; -; void f(int x) { -; escape(&x); -; x = 1; // DSE should delete and insert dbg.value(i32 1) -; global = x; -; x = 2; // DSE should insert dbg.addr -; escape(&x); -; } - -; ModuleID = 'dse.c' -source_filename = "dse.c" -target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-pc-windows-msvc19.0.24215" - -declare void @llvm.dbg.addr(metadata, metadata, metadata) #2 -declare void @llvm.dbg.value(metadata, metadata, metadata) #2 - -@global = external global i32, align 4 - -; Function Attrs: nounwind uwtable -define void @f(i32 %x) #0 !dbg !8 { -entry: - %x.addr = alloca i32, align 4 - store i32 %x, ptr %x.addr, align 4 - call void @llvm.dbg.addr(metadata ptr %x.addr, metadata !13, metadata !DIExpression()), !dbg !18 - %ld.1 = load i32, ptr %x.addr, align 4, !dbg !19 - %inc.1 = add nsw i32 %ld.1, 1, !dbg !19 - store i32 %inc.1, ptr %x.addr, align 4, !dbg !19 - call void @llvm.dbg.value(metadata i32 1, metadata !13, metadata !DIExpression()), !dbg !20 - store i32 1, ptr @global, align 4, !dbg !22 - call void @llvm.dbg.addr(metadata ptr %x.addr, metadata !13, metadata !DIExpression()), !dbg !23 - store i32 2, ptr %x.addr, align 4, !dbg !23 - %ld.2 = load i32, ptr %x.addr, align 4, !dbg !19 - %inc.2 = add nsw i32 %ld.2, 1, !dbg !19 - store i32 %inc.2, ptr %x.addr, align 4, !dbg !19 - ret void, !dbg !25 -} - -; CHECK-LABEL: define void @f(i32 %x) -; CHECK: call void @llvm.dbg.value(metadata i32 %x, metadata !13, metadata !DIExpression()) -; CHECK: %inc.1 = add nsw i32 %x, 1 -; CHECK: call void @llvm.dbg.value(metadata i32 %inc.1, metadata !13, metadata !DIExpression()) -; CHECK: call void @llvm.dbg.value(metadata i32 1, metadata !13, metadata !DIExpression()) -; CHECK: store i32 1, ptr @global, align 4 -; CHECK: call void @llvm.dbg.value(metadata i32 2, metadata !13, metadata !DIExpression()) -; CHECK: %inc.2 = add nsw i32 2, 1 -; CHECK: call void @llvm.dbg.value(metadata i32 %inc.2, metadata !13, metadata !DIExpression()) -; CHECK: ret void - -attributes #0 = { nounwind uwtable } -attributes #2 = { nounwind readnone speculatable } - -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!3, !4, !5, !6} -!llvm.ident = !{!7} - -!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) -!1 = !DIFile(filename: "dse.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild") -!2 = !{} -!3 = !{i32 2, !"Dwarf Version", i32 4} -!4 = !{i32 2, !"Debug Info Version", i32 3} -!5 = !{i32 1, !"wchar_size", i32 2} -!6 = !{i32 7, !"PIC Level", i32 2} -!7 = !{!"clang version 6.0.0 "} -!8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 3, type: !9, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12) -!9 = !DISubroutineType(types: !10) -!10 = !{null, !11} -!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!12 = !{!13} -!13 = !DILocalVariable(name: "x", arg: 1, scope: !8, file: !1, line: 3, type: !11) -!14 = !{!15, !15, i64 0} -!15 = !{!"int", !16, i64 0} -!16 = !{!"omnipotent char", !17, i64 0} -!17 = !{!"Simple C/C++ TBAA"} -!18 = !DILocation(line: 3, column: 12, scope: !8) -!19 = !DILocation(line: 4, column: 3, scope: !8) -!20 = !DILocation(line: 5, column: 5, scope: !8) -!21 = !DILocation(line: 6, column: 12, scope: !8) -!22 = !DILocation(line: 6, column: 10, scope: !8) -!23 = !DILocation(line: 7, column: 5, scope: !8) -!24 = !DILocation(line: 8, column: 3, scope: !8) -!25 = !DILocation(line: 9, column: 1, scope: !8) diff --git a/llvm/test/Transforms/Mem2Reg/dbg-addr.ll b/llvm/test/Transforms/Mem2Reg/dbg-addr.ll deleted file mode 100644 --- a/llvm/test/Transforms/Mem2Reg/dbg-addr.ll +++ /dev/null @@ -1,91 +0,0 @@ -; RUN: opt -passes=mem2reg -S < %s | FileCheck %s - -; ModuleID = 'newvars.c' -source_filename = "newvars.c" -target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-pc-windows-msvc19.0.24215" - -; Function Attrs: nounwind uwtable -define i32 @if_else(i32 %cond, i32 %a, i32 %b) !dbg !8 { -entry: - %x = alloca i32, align 4 - call void @llvm.dbg.addr(metadata ptr %x, metadata !16, metadata !DIExpression()), !dbg !26 - store i32 %a, ptr %x, align 4, !dbg !26, !tbaa !17 - %tobool = icmp ne i32 %cond, 0, !dbg !28 - br i1 %tobool, label %if.then, label %if.else, !dbg !30 - -if.then: ; preds = %entry - store i32 0, ptr %x, align 4, !dbg !31, !tbaa !17 - br label %if.end, !dbg !33 - -if.else: ; preds = %entry - store i32 %b, ptr %x, align 4, !dbg !36, !tbaa !17 - br label %if.end - -if.end: ; preds = %if.else, %if.then - %rv = load i32, ptr %x, align 4, !dbg !37, !tbaa !17 - ret i32 %rv, !dbg !39 -} - -; CHECK-LABEL: define i32 @if_else({{.*}}) -; CHECK: entry: -; CHECK-NOT: alloca i32 -; CHECK: call void @llvm.dbg.value(metadata i32 %a, metadata ![[X_LOCAL:[0-9]+]], metadata !DIExpression()) -; CHECK: if.then: ; preds = %entry -; CHECK: call void @llvm.dbg.value(metadata i32 0, metadata ![[X_LOCAL]], metadata !DIExpression()) -; CHECK: if.else: ; preds = %entry -; CHECK: call void @llvm.dbg.value(metadata i32 %b, metadata ![[X_LOCAL]], metadata !DIExpression()) -; CHECK: if.end: ; preds = %if.else, %if.then -; CHECK: %[[PHI:[^ ]*]] = phi i32 [ 0, %if.then ], [ %b, %if.else ] -; CHECK: call void @llvm.dbg.value(metadata i32 %[[PHI]], metadata ![[X_LOCAL]], metadata !DIExpression()) -; CHECK: ret i32 - -; CHECK: ![[X_LOCAL]] = !DILocalVariable(name: "x", {{.*}}) - -; Function Attrs: nounwind readnone speculatable -declare void @llvm.dbg.declare(metadata, metadata, metadata) -declare void @llvm.dbg.addr(metadata, metadata, metadata) - -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!3, !4, !5, !6} -!llvm.ident = !{!7} - -!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) -!1 = !DIFile(filename: "newvars.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild") -!2 = !{} -!3 = !{i32 2, !"Dwarf Version", i32 4} -!4 = !{i32 2, !"Debug Info Version", i32 3} -!5 = !{i32 1, !"wchar_size", i32 2} -!6 = !{i32 7, !"PIC Level", i32 2} -!7 = !{!"clang version 6.0.0 "} -!8 = distinct !DISubprogram(name: "if_else", scope: !1, file: !1, line: 1, type: !9, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12) -!9 = !DISubroutineType(types: !10) -!10 = !{!11, !11, !11, !11} -!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!12 = !{!13, !14, !15, !16} -!13 = !DILocalVariable(name: "b", arg: 3, scope: !8, file: !1, line: 1, type: !11) -!14 = !DILocalVariable(name: "a", arg: 2, scope: !8, file: !1, line: 1, type: !11) -!15 = !DILocalVariable(name: "cond", arg: 1, scope: !8, file: !1, line: 1, type: !11) -!16 = !DILocalVariable(name: "x", scope: !8, file: !1, line: 2, type: !11) -!17 = !{!18, !18, i64 0} -!18 = !{!"int", !19, i64 0} -!19 = !{!"omnipotent char", !20, i64 0} -!20 = !{!"Simple C/C++ TBAA"} -!22 = !DILocation(line: 1, column: 34, scope: !8) -!23 = !DILocation(line: 1, column: 27, scope: !8) -!24 = !DILocation(line: 1, column: 17, scope: !8) -!25 = !DILocation(line: 2, column: 3, scope: !8) -!26 = !DILocation(line: 2, column: 7, scope: !8) -!27 = !DILocation(line: 2, column: 11, scope: !8) -!28 = !DILocation(line: 3, column: 7, scope: !29) -!29 = distinct !DILexicalBlock(scope: !8, file: !1, line: 3, column: 7) -!30 = !DILocation(line: 3, column: 7, scope: !8) -!31 = !DILocation(line: 4, column: 7, scope: !32) -!32 = distinct !DILexicalBlock(scope: !29, file: !1, line: 3, column: 13) -!33 = !DILocation(line: 5, column: 3, scope: !32) -!34 = !DILocation(line: 6, column: 9, scope: !35) -!35 = distinct !DILexicalBlock(scope: !29, file: !1, line: 5, column: 10) -!36 = !DILocation(line: 6, column: 7, scope: !35) -!37 = !DILocation(line: 8, column: 10, scope: !8) -!38 = !DILocation(line: 9, column: 1, scope: !8) -!39 = !DILocation(line: 8, column: 3, scope: !8) diff --git a/llvm/test/Transforms/SROA/dbg-addr-diamond.ll b/llvm/test/Transforms/SROA/dbg-addr-diamond.ll deleted file mode 100644 --- a/llvm/test/Transforms/SROA/dbg-addr-diamond.ll +++ /dev/null @@ -1,133 +0,0 @@ -; NOTE: Assertions have been autogenerated by utils/update_test_checks.py -; RUN: opt -use-dbg-addr -passes='sroa' -S < %s | FileCheck %s --check-prefixes=CHECK,CHECK-PRESERVE-CFG -; RUN: opt -use-dbg-addr -passes='sroa' -S < %s | FileCheck %s --check-prefixes=CHECK,CHECK-MODIFY-CFG - -; ModuleID = '' -source_filename = "newvars.c" -target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-pc-windows-msvc19.0.24215" - -%struct.Pair = type { i32, i32 } - -@pair = internal global %struct.Pair zeroinitializer - -; Function Attrs: nounwind uwtable -define void @if_else(i32 %cond, i32 %a, i32 %b) !dbg !8 { -; CHECK-LABEL: @if_else( -; CHECK-NEXT: entry: -; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[A:%.*]], metadata [[META20:![0-9]+]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg [[DBG21:![0-9]+]] -; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[B:%.*]], metadata [[META20]], metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32)), !dbg [[DBG21]] -; CHECK-NEXT: [[TOBOOL:%.*]] = icmp ne i32 [[COND:%.*]], 0, !dbg [[DBG22:![0-9]+]] -; CHECK-NEXT: br i1 [[TOBOOL]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]], !dbg [[DBG24:![0-9]+]] -; CHECK: if.then: -; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 0, metadata [[META20]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg [[DBG21]] -; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[A]], metadata [[META20]], metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32)), !dbg [[DBG21]] -; CHECK-NEXT: br label [[IF_END:%.*]], !dbg [[DBG25:![0-9]+]] -; CHECK: if.else: -; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[B]], metadata [[META20]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg [[DBG21]] -; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 0, metadata [[META20]], metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32)), !dbg [[DBG21]] -; CHECK-NEXT: br label [[IF_END]] -; CHECK: if.end: -; CHECK-NEXT: [[P_SROA_4_0:%.*]] = phi i32 [ [[A]], [[IF_THEN]] ], [ 0, [[IF_ELSE]] ], !dbg [[DBG27:![0-9]+]] -; CHECK-NEXT: [[P_SROA_0_0:%.*]] = phi i32 [ 0, [[IF_THEN]] ], [ [[B]], [[IF_ELSE]] ], !dbg [[DBG27]] -; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[P_SROA_0_0]], metadata [[META20]], metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg [[DBG21]] -; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[P_SROA_4_0]], metadata [[META20]], metadata !DIExpression(DW_OP_LLVM_fragment, 32, 32)), !dbg [[DBG21]] -; CHECK-NEXT: store i32 [[P_SROA_0_0]], ptr @pair, align 4, !dbg [[DBG28:![0-9]+]] -; CHECK-NEXT: store i32 [[P_SROA_4_0]], ptr getelementptr inbounds (i8, ptr @pair, i64 4), align 4, !dbg [[DBG28]] -; CHECK-NEXT: ret void -; -entry: - %p = alloca %struct.Pair, align 4 - call void @llvm.dbg.addr(metadata ptr %p, metadata !20, metadata !DIExpression()), !dbg !26 - store i32 %a, ptr %p, align 4, !dbg !28 - %y = getelementptr inbounds %struct.Pair, ptr %p, i32 0, i32 1, !dbg !34 - store i32 %b, ptr %y, align 4, !dbg !35 - %tobool = icmp ne i32 %cond, 0, !dbg !37 - br i1 %tobool, label %if.then, label %if.else, !dbg !39 - -if.then: ; preds = %entry - store i32 0, ptr %p, align 4, !dbg !42 - %y2 = getelementptr inbounds %struct.Pair, ptr %p, i32 0, i32 1, !dbg !43 - store i32 %a, ptr %y2, align 4, !dbg !44 - br label %if.end, !dbg !45 - -if.else: ; preds = %entry - store i32 %b, ptr %p, align 4, !dbg !48 - %y4 = getelementptr inbounds %struct.Pair, ptr %p, i32 0, i32 1, !dbg !49 - store i32 0, ptr %y4, align 4, !dbg !50 - br label %if.end - -if.end: ; preds = %if.else, %if.then - call void @llvm.memcpy.p0.p0.i64(ptr align 4 @pair, ptr align 4 %p, i64 8, i1 false), !dbg !51 - ret void -} - - - -; Function Attrs: argmemonly nounwind -declare void @llvm.memcpy.p0.p0.i64(ptr nocapture writeonly, ptr nocapture readonly, i64, i1) #2 - -; Function Attrs: nounwind readnone speculatable -declare void @llvm.dbg.addr(metadata, metadata, metadata) - -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!3, !4, !5, !6} -!llvm.ident = !{!7} - -!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) -!1 = !DIFile(filename: "newvars.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild") -!2 = !{} -!3 = !{i32 2, !"Dwarf Version", i32 4} -!4 = !{i32 2, !"Debug Info Version", i32 3} -!5 = !{i32 1, !"wchar_size", i32 2} -!6 = !{i32 7, !"PIC Level", i32 2} -!7 = !{!"clang version 6.0.0 "} -!8 = distinct !DISubprogram(name: "if_else", scope: !1, file: !1, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !16) -!9 = !DISubroutineType(types: !10) -!10 = !{!11, !14, !14, !14} -!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Pair", file: !1, line: 1, size: 64, elements: !12) -!12 = !{!13, !15} -!13 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !11, file: !1, line: 1, baseType: !14, size: 32) -!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!15 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !11, file: !1, line: 1, baseType: !14, size: 32, offset: 32) -!16 = !{!17, !18, !19, !20} -!17 = !DILocalVariable(name: "b", arg: 3, scope: !8, file: !1, line: 2, type: !14) -!18 = !DILocalVariable(name: "a", arg: 2, scope: !8, file: !1, line: 2, type: !14) -!19 = !DILocalVariable(name: "cond", arg: 1, scope: !8, file: !1, line: 2, type: !14) -!20 = !DILocalVariable(name: "p", scope: !8, file: !1, line: 3, type: !11) -!22 = !DILocation(line: 2, column: 42, scope: !8) -!23 = !DILocation(line: 2, column: 35, scope: !8) -!24 = !DILocation(line: 2, column: 25, scope: !8) -!25 = !DILocation(line: 3, column: 3, scope: !8) -!26 = !DILocation(line: 3, column: 15, scope: !8) -!27 = !DILocation(line: 4, column: 5, scope: !8) -!28 = !DILocation(line: 4, column: 7, scope: !8) -!29 = !{!30, !31, i64 0} -!30 = !{!"Pair", !31, i64 0, !31, i64 4} -!31 = !{!"int", !32, i64 0} -!32 = !{!"omnipotent char", !33, i64 0} -!33 = !{!"Simple C/C++ TBAA"} -!34 = !DILocation(line: 5, column: 5, scope: !8) -!35 = !DILocation(line: 5, column: 7, scope: !8) -!36 = !{!30, !31, i64 4} -!37 = !DILocation(line: 6, column: 7, scope: !38) -!38 = distinct !DILexicalBlock(scope: !8, file: !1, line: 6, column: 7) -!39 = !DILocation(line: 6, column: 7, scope: !8) -!40 = !DILocation(line: 7, column: 7, scope: !41) -!41 = distinct !DILexicalBlock(scope: !38, file: !1, line: 6, column: 13) -!42 = !DILocation(line: 7, column: 9, scope: !41) -!43 = !DILocation(line: 8, column: 7, scope: !41) -!44 = !DILocation(line: 8, column: 9, scope: !41) -!45 = !DILocation(line: 9, column: 3, scope: !41) -!46 = !DILocation(line: 10, column: 7, scope: !47) -!47 = distinct !DILexicalBlock(scope: !38, file: !1, line: 9, column: 10) -!48 = !DILocation(line: 10, column: 9, scope: !47) -!49 = !DILocation(line: 11, column: 7, scope: !47) -!50 = !DILocation(line: 11, column: 9, scope: !47) -!51 = !DILocation(line: 13, column: 10, scope: !8) -!52 = !{i64 0, i64 4, !53, i64 4, i64 4, !53} -!53 = !{!31, !31, i64 0} -!54 = !DILocation(line: 14, column: 1, scope: !8) -;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line: -; CHECK-MODIFY-CFG: {{.*}} -; CHECK-PRESERVE-CFG: {{.*}} diff --git a/llvm/test/Transforms/SpeculativeExecution/PR46267.ll b/llvm/test/Transforms/SpeculativeExecution/PR46267.ll --- a/llvm/test/Transforms/SpeculativeExecution/PR46267.ll +++ b/llvm/test/Transforms/SpeculativeExecution/PR46267.ll @@ -36,15 +36,11 @@ land.rhs: ; preds = %entry ; CHECK: land.rhs: ; CHECK-NEXT: call void @llvm.dbg.label -; CHECK-NEXT: %x = alloca i32, align 4 -; CHECK-NEXT: call void @llvm.dbg.addr(metadata ptr %x ; CHECK-NEXT: %y = alloca i32, align 4 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %y ; CHECK-NEXT: %a0 = load i32, ptr undef, align 1 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 %a0 call void @llvm.dbg.label(metadata !11), !dbg !10 - %x = alloca i32, align 4 - call void @llvm.dbg.addr(metadata ptr %x, metadata !12, metadata !DIExpression()), !dbg !10 %y = alloca i32, align 4 call void @llvm.dbg.declare(metadata ptr %y, metadata !14, metadata !DIExpression()), !dbg !10 @@ -64,7 +60,6 @@ declare void @llvm.dbg.value(metadata, metadata, metadata) #1 declare void @llvm.dbg.label(metadata) declare void @llvm.dbg.declare(metadata, metadata, metadata) -declare void @llvm.dbg.addr(metadata, metadata, metadata) attributes #1 = { nounwind readnone speculatable willreturn } diff --git a/llvm/test/Transforms/Util/strip-nonlinetable-debuginfo-localvars.ll b/llvm/test/Transforms/Util/strip-nonlinetable-debuginfo-localvars.ll --- a/llvm/test/Transforms/Util/strip-nonlinetable-debuginfo-localvars.ll +++ b/llvm/test/Transforms/Util/strip-nonlinetable-debuginfo-localvars.ll @@ -3,16 +3,14 @@ define void @f() !dbg !4 { entry: %i = alloca i32, align 4 - ; CHECK-NOT: llvm.dbg.{{addr|declare|value}} + ; CHECK-NOT: llvm.dbg.{{declare|value}} call void @llvm.dbg.declare(metadata ptr %i, metadata !11, metadata !13), !dbg !14 - call void @llvm.dbg.addr(metadata ptr %i, metadata !16, metadata !13), !dbg !14 store i32 42, ptr %i, align 4, !dbg !14 call void @llvm.dbg.value(metadata i32 0, metadata !16, metadata !13), !dbg !15 ret void, !dbg !15 } ; Function Attrs: nounwind readnone -declare void @llvm.dbg.addr(metadata, metadata, metadata) declare void @llvm.dbg.declare(metadata, metadata, metadata) declare void @llvm.dbg.value(metadata, metadata, metadata) diff --git a/llvm/unittests/Transforms/Utils/LocalTest.cpp b/llvm/unittests/Transforms/Utils/LocalTest.cpp --- a/llvm/unittests/Transforms/Utils/LocalTest.cpp +++ b/llvm/unittests/Transforms/Utils/LocalTest.cpp @@ -679,7 +679,7 @@ call void @llvm.dbg.declare(metadata i64* %c, metadata !13, metadata !DIExpression()), !dbg !17 %d = inttoptr i64 0 to i32*, !dbg !18 - call void @llvm.dbg.addr(metadata i32* %d, metadata !20, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.declare(metadata i32* %d, metadata !20, metadata !DIExpression()), !dbg !18 %e = add <2 x i16> zeroinitializer, zeroinitializer call void @llvm.dbg.value(metadata <2 x i16> %e, metadata !14, metadata !DIExpression()), !dbg !18 @@ -695,7 +695,6 @@ ret void, !dbg !19 } - declare void @llvm.dbg.addr(metadata, metadata, metadata) declare void @llvm.dbg.declare(metadata, metadata, metadata) declare void @llvm.dbg.value(metadata, metadata, metadata) @@ -755,10 +754,7 @@ SmallVector CDbgVals; findDbgUsers(CDbgVals, &C); EXPECT_EQ(2U, CDbgVals.size()); - EXPECT_TRUE(any_of(CDbgVals, [](DbgVariableIntrinsic *DII) { - return isa(DII); - })); - EXPECT_TRUE(any_of(CDbgVals, [](DbgVariableIntrinsic *DII) { + EXPECT_TRUE(all_of(CDbgVals, [](DbgVariableIntrinsic *DII) { return isa(DII); })); @@ -767,10 +763,7 @@ SmallVector DDbgVals; findDbgUsers(DDbgVals, &D); EXPECT_EQ(2U, DDbgVals.size()); - EXPECT_TRUE(any_of(DDbgVals, [](DbgVariableIntrinsic *DII) { - return isa(DII); - })); - EXPECT_TRUE(any_of(DDbgVals, [](DbgVariableIntrinsic *DII) { + EXPECT_TRUE(all_of(DDbgVals, [](DbgVariableIntrinsic *DII) { return isa(DII); }));