Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -4068,9 +4068,14 @@ assert(std::find(Expr.begin(), Expr.end(), llvm::dwarf::DW_OP_deref) == Expr.end() && "Debug info already contains DW_OP_deref."); + if (Expr.size() == 0) + Expr.push_back(llvm::dwarf::DW_OP_LLVM_arg0); Expr.push_back(llvm::dwarf::DW_OP_deref); } + if (Expr.size() == 0) + Expr.push_back(llvm::dwarf::DW_OP_LLVM_arg0); + // Create the descriptor for the variable. auto *D = ArgNo ? DBuilder.createParameterVariable( Scope, Name, *ArgNo, Unit, Line, Ty, @@ -4167,6 +4172,7 @@ ->getElementOffset(blockInfo.getCapture(VD).getIndex())); SmallVector addr; + addr.push_back(llvm::dwarf::DW_OP_LLVM_arg0); addr.push_back(llvm::dwarf::DW_OP_deref); addr.push_back(llvm::dwarf::DW_OP_plus_uconst); addr.push_back(offset.getQuantity()); Index: clang/test/CodeGen/2009-10-20-GlobalDebug.c =================================================================== --- clang/test/CodeGen/2009-10-20-GlobalDebug.c +++ clang/test/CodeGen/2009-10-20-GlobalDebug.c @@ -10,11 +10,11 @@ return 0; } -// CHECK: [[L]] = !DIGlobalVariableExpression(var: [[LV:.*]], expr: !DIExpression()) +// CHECK: [[L]] = !DIGlobalVariableExpression(var: [[LV:.*]], expr: !DIExpression(DW_OP_LLVM_arg0)) // CHECK: [[LV]] = distinct !DIGlobalVariable(name: "localstatic" // CHECK-NOT: linkageName: // CHECK-SAME: line: 9, -// CHECK: [[G]] = !DIGlobalVariableExpression(var: [[GV:.*]], expr: !DIExpression()) +// CHECK: [[G]] = !DIGlobalVariableExpression(var: [[GV:.*]], expr: !DIExpression(DW_OP_LLVM_arg0)) // CHECK: [[GV]] = distinct !DIGlobalVariable(name: "global" // CHECK-NOT: linkageName: // CHECK-SAME: line: 7, Index: clang/test/CodeGen/debug-info-static-const-fp.c =================================================================== --- clang/test/CodeGen/debug-info-static-const-fp.c +++ clang/test/CodeGen/debug-info-static-const-fp.c @@ -46,6 +46,6 @@ // CHECK-SAME: isLocal: true, isDefinition: true // CHECK-LDlg-DAG: [[LDVAL:.*]] = distinct !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) -// CHECK-LDlg-DAG: !DIGlobalVariableExpression(var: [[LDVAL]], expr: !DIExpression()) +// CHECK-LDlg-DAG: !DIGlobalVariableExpression(var: [[LDVAL]], expr: !DIExpression(DW_OP_LLVM_arg0)) // CHECK-LDsm-DAG: [[LDVAL:.*]] = distinct !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) // CHECK-LDsm-DAG: !DIGlobalVariableExpression(var: [[LDVAL]], expr: Index: clang/test/CodeGen/debug-info-static.c =================================================================== --- clang/test/CodeGen/debug-info-static.c +++ clang/test/CodeGen/debug-info-static.c @@ -2,7 +2,7 @@ // CHECK: @f.xyzzy = internal global i32 0, align 4, !dbg [[XYZZY:![0-9]+]] -// CHECK: [[XYZZY]] = !DIGlobalVariableExpression(var: [[VAR:.*]], expr: !DIExpression()) +// CHECK: [[XYZZY]] = !DIGlobalVariableExpression(var: [[VAR:.*]], expr: !DIExpression(DW_OP_LLVM_arg0)) // CHECK: [[VAR]] = distinct !DIGlobalVariable void f(void) { Index: clang/test/CodeGenCUDA/debug-info-address-class.cu =================================================================== --- clang/test/CodeGenCUDA/debug-info-address-class.cu +++ clang/test/CodeGenCUDA/debug-info-address-class.cu @@ -3,7 +3,7 @@ #include "Inputs/cuda.h" // CHECK-DAG: ![[FILEVAR0:[0-9]+]] = distinct !DIGlobalVariable(name: "FileVar0", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: false, isDefinition: true) -// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR0]], expr: !DIExpression()) +// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR0]], expr: !DIExpression(DW_OP_LLVM_arg0)) __device__ int FileVar0; // CHECK-DAG: ![[FILEVAR1:[0-9]+]] = distinct !DIGlobalVariable(name: "FileVar1", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: false, isDefinition: true) // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR1]], expr: !DIExpression(DW_OP_constu, 8, DW_OP_swap, DW_OP_xderef)) @@ -14,12 +14,12 @@ __device__ void kernel1( // CHECK-DAG: ![[ARG:[0-9]+]] = !DILocalVariable(name: "Arg", arg: {{[0-9]+}}, scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}) - // CHECK-DAG: call void @llvm.dbg.declare(metadata i32* {{.*}}, metadata ![[ARG]], metadata !DIExpression()), !dbg !{{[0-9]+}} + // CHECK-DAG: call void @llvm.dbg.declare(metadata i32* {{.*}}, metadata ![[ARG]], metadata !DIExpression(DW_OP_LLVM_arg0)), !dbg !{{[0-9]+}} int Arg) { // CHECK-DAG: ![[FUNCVAR0:[0-9]+]] = distinct !DIGlobalVariable(name: "FuncVar0", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: true, isDefinition: true) // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR0]], expr: !DIExpression(DW_OP_constu, 8, DW_OP_swap, DW_OP_xderef)) __shared__ int FuncVar0; // CHECK-DAG: ![[FUNCVAR1:[0-9]+]] = !DILocalVariable(name: "FuncVar1", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}) - // CHECK-DAG: call void @llvm.dbg.declare(metadata i32* {{.*}}, metadata ![[FUNCVAR1]], metadata !DIExpression()), !dbg !{{[0-9]+}} + // CHECK-DAG: call void @llvm.dbg.declare(metadata i32* {{.*}}, metadata ![[FUNCVAR1]], metadata !DIExpression(DW_OP_LLVM_arg0)), !dbg !{{[0-9]+}} int FuncVar1; } Index: clang/test/CodeGenCXX/debug-info-inheriting-constructor.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-inheriting-constructor.cpp +++ clang/test/CodeGenCXX/debug-info-inheriting-constructor.cpp @@ -13,7 +13,7 @@ // CHECK: call void @llvm.dbg.declare // CHECK-NOT: ret void // CHECK: call void @llvm.dbg.declare(metadata %{{.*}}** %{{[^,]+}}, -// CHECK-SAME: metadata ![[THIS:[0-9]+]], metadata !DIExpression()), !dbg ![[LOC:[0-9]+]] +// CHECK-SAME: metadata ![[THIS:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_arg0)), !dbg ![[LOC:[0-9]+]] // CHECK: ret void, !dbg ![[NOINL:[0-9]+]] // CHECK: ![[FOO:.*]] = distinct !DISubprogram(name: "foo" // CHECK-DAG: ![[A:.*]] = distinct !DISubprogram(name: "A", linkageName: "_ZN1BCI11AEiz" Index: clang/test/CodeGenCXX/debug-info-nrvo.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-nrvo.cpp +++ clang/test/CodeGenCXX/debug-info-nrvo.cpp @@ -28,8 +28,8 @@ // CHECK: %[[RESULT:.*]] = alloca i8*, align 8 // CHECK: call void @llvm.dbg.declare(metadata i8** %[[RESULT]], -// CHECK-SAME: metadata !DIExpression(DW_OP_deref) +// CHECK-SAME: metadata !DIExpression(DW_OP_LLVM_arg0, DW_OP_deref) // NOELIDE: %[[FOO:.*]] = alloca %struct.Foo, align 4 // NOELIDE: call void @llvm.dbg.declare(metadata %struct.Foo* %[[FOO]], -// NOELIDE-SAME: metadata !DIExpression() +// NOELIDE-SAME: metadata !DIExpression(DW_OP_LLVM_arg0) Index: clang/test/CodeGenCXX/debug-info-static-member.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-static-member.cpp +++ clang/test/CodeGenCXX/debug-info-static-member.cpp @@ -33,7 +33,7 @@ // why the definition of "a" comes before the declarations while // "b" and "c" come after. -// CHECK: [[A]] = !DIGlobalVariableExpression(var: [[AV:.*]], expr: !DIExpression()) +// CHECK: [[A]] = !DIGlobalVariableExpression(var: [[AV:.*]], expr: !DIExpression(DW_OP_LLVM_arg0)) // CHECK: [[AV]] = distinct !DIGlobalVariable(name: "a", // CHECK-SAME: declaration: ![[DECL_A:[0-9]+]]) // MSVC: distinct !DIGlobalVariable(name: "a" @@ -47,7 +47,7 @@ // CHECK: !DIDerivedType(tag: DW_TAG_member, name: "static_decl_templ_var" int C::a = 4; -// CHECK: [[B]] = !DIGlobalVariableExpression(var: [[BV:.*]], expr: !DIExpression()) +// CHECK: [[B]] = !DIGlobalVariableExpression(var: [[BV:.*]], expr: !DIExpression(DW_OP_LLVM_arg0)) // CHECK: [[BV]] = distinct !DIGlobalVariable(name: "b", // CHECK-SAME: declaration: ![[DECL_B:[0-9]+]]) // MSVC: distinct !DIGlobalVariable(name: "b" @@ -96,7 +96,7 @@ // CHECK-SAME: flags: DIFlagPublic | DIFlagStaticMember) int C::b = 2; -// CHECK: [[C]] = !DIGlobalVariableExpression(var: [[CV:.*]], expr: !DIExpression()) +// CHECK: [[C]] = !DIGlobalVariableExpression(var: [[CV:.*]], expr: !DIExpression(DW_OP_LLVM_arg0)) // CHECK: [[CV]] = distinct !DIGlobalVariable(name: "c", {{.*}} declaration: ![[DECL_C]]) // MSVC: distinct !DIGlobalVariable(name: "c" int C::c = 1; Index: clang/test/CodeGenCXX/debug-info-template-member.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-template-member.cpp +++ clang/test/CodeGenCXX/debug-info-template-member.cpp @@ -19,7 +19,7 @@ } // The compile unit pulls in the global variables first. -// CHECK: [[X]] = !DIGlobalVariableExpression(var: [[XV:.*]], expr: !DIExpression()) +// CHECK: [[X]] = !DIGlobalVariableExpression(var: [[XV:.*]], expr: !DIExpression(DW_OP_LLVM_arg0)) // CHECK: [[XV]] = distinct !DIGlobalVariable(name: "x", // CHECK-SAME: type: ![[OUTER_FOO_INNER_ID:[0-9]+]] // Index: clang/test/CodeGenCXX/debug-info-template.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-template.cpp +++ clang/test/CodeGenCXX/debug-info-template.cpp @@ -25,7 +25,7 @@ int glb; void func(); -// CHECK: [[TCI]] = !DIGlobalVariableExpression(var: [[TCIV:.*]], expr: !DIExpression()) +// CHECK: [[TCI]] = !DIGlobalVariableExpression(var: [[TCIV:.*]], expr: !DIExpression(DW_OP_LLVM_arg0)) // CHECK: [[TCIV]] = distinct !DIGlobalVariable(name: "tci", // CHECK-SAME: type: ![[TCNESTED:[0-9]+]] // CHECK: ![[TCNESTED]] ={{.*}}!DICompositeType(tag: DW_TAG_structure_type, name: "nested", @@ -84,7 +84,7 @@ // CHECK: [[TCARG7_3]] = !DITemplateValueParameter(type: [[INT]], value: i32 3) 3>::nested tci; -// CHECK: [[TCN]] = !DIGlobalVariableExpression(var: [[TCNV:.*]], expr: !DIExpression()) +// CHECK: [[TCN]] = !DIGlobalVariableExpression(var: [[TCNV:.*]], expr: !DIExpression(DW_OP_LLVM_arg0)) // CHECK: [[TCNV]] = distinct !DIGlobalVariable(name: "tcn" // CHECK-SAME: type: ![[TCNT:[0-9]+]] TC @@ -125,7 +125,7 @@ struct NN { }; -// CHECK: [[NN]] = !DIGlobalVariableExpression(var: [[NNV:.*]], expr: !DIExpression()) +// CHECK: [[NN]] = !DIGlobalVariableExpression(var: [[NNV:.*]], expr: !DIExpression(DW_OP_LLVM_arg0)) // CHECK: [[NNV]] = distinct !DIGlobalVariable(name: "nn" // CHECK-SAME: type: ![[NNT:[0-9]+]] Index: clang/test/CodeGenCXX/debug-info.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info.cpp +++ clang/test/CodeGenCXX/debug-info.cpp @@ -4,11 +4,11 @@ // CHECK: @_ZN6pr96081xE = global [3 x i8]* null, align 8, !dbg [[X:![0-9]+]] // CHECK: define void @_ZN7pr147634funcENS_3fooE -// CHECK: call void @llvm.dbg.declare({{.*}}, metadata ![[F:[0-9]+]], metadata !DIExpression()) +// CHECK: call void @llvm.dbg.declare({{.*}}, metadata ![[F:[0-9]+]], metadata !DIExpression(DW_OP_LLVM_arg0)) // !llvm.dbg.cu pulls in globals and their types first. // CHECK-NOT: !DIGlobalVariable(name: "c" -// CHECK: [[X]] = !DIGlobalVariableExpression(var: [[XV:!.*]], expr: !DIExpression()) +// CHECK: [[X]] = !DIGlobalVariableExpression(var: [[XV:!.*]], expr: !DIExpression(DW_OP_LLVM_arg0)) // CHECK: [[XV]] = distinct !DIGlobalVariable(name: "x", linkageName: "_ZN6pr96081xE" // CHECK-SAME: type: [[INCARRAYPTR:![0-9]*]] // CHECK: [[INCARRAYPTR]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: [[INCARRAY:![0-9]+]] Index: clang/test/CodeGenCXX/inline-dllexport-member.cpp =================================================================== --- clang/test/CodeGenCXX/inline-dllexport-member.cpp +++ clang/test/CodeGenCXX/inline-dllexport-member.cpp @@ -7,7 +7,7 @@ static const unsigned int ui = 0; }; -// CHECK: [[UI]] = !DIGlobalVariableExpression(var: [[UIV:.*]], expr: !DIExpression()) +// CHECK: [[UI]] = !DIGlobalVariableExpression(var: [[UIV:.*]], expr: !DIExpression(DW_OP_LLVM_arg0)) // CHECK: [[UIV]] = distinct !DIGlobalVariable(name: "ui", linkageName: "?ui@s@@2IB", scope: ![[SCOPE:[0-9]+]], // CHECK: ![[SCOPE]] = distinct !DICompileUnit( Index: clang/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl =================================================================== --- clang/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl +++ clang/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl @@ -2,51 +2,51 @@ // RUN: %clang -cl-std=CL2.0 -emit-llvm -g -O0 -S -target amdgcn-amd-amdhsa-opencl -mcpu=fiji -o - %s | FileCheck %s // CHECK-DAG: ![[FILEVAR0:[0-9]+]] = distinct !DIGlobalVariable(name: "FileVar0", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: false, isDefinition: true) -// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR0]], expr: !DIExpression()) +// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR0]], expr: !DIExpression(DW_OP_LLVM_arg0)) global int *FileVar0; // CHECK-DAG: ![[FILEVAR1:[0-9]+]] = distinct !DIGlobalVariable(name: "FileVar1", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: false, isDefinition: true) -// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR1]], expr: !DIExpression()) +// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR1]], expr: !DIExpression(DW_OP_LLVM_arg0)) constant int *FileVar1; // CHECK-DAG: ![[FILEVAR2:[0-9]+]] = distinct !DIGlobalVariable(name: "FileVar2", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: false, isDefinition: true) -// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR2]], expr: !DIExpression()) +// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR2]], expr: !DIExpression(DW_OP_LLVM_arg0)) local int *FileVar2; // CHECK-DAG: ![[FILEVAR3:[0-9]+]] = distinct !DIGlobalVariable(name: "FileVar3", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: false, isDefinition: true) -// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR3]], expr: !DIExpression()) +// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR3]], expr: !DIExpression(DW_OP_LLVM_arg0)) private int *FileVar3; // CHECK-DAG: ![[FILEVAR4:[0-9]+]] = distinct !DIGlobalVariable(name: "FileVar4", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: false, isDefinition: true) -// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR4]], expr: !DIExpression()) +// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR4]], expr: !DIExpression(DW_OP_LLVM_arg0)) int *FileVar4; // CHECK-DAG: ![[FILEVAR5:[0-9]+]] = distinct !DIGlobalVariable(name: "FileVar5", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: false, isDefinition: true) -// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR5]], expr: !DIExpression()) +// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR5]], expr: !DIExpression(DW_OP_LLVM_arg0)) global int *global FileVar5; // CHECK-DAG: ![[FILEVAR6:[0-9]+]] = distinct !DIGlobalVariable(name: "FileVar6", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: false, isDefinition: true) -// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR6]], expr: !DIExpression()) +// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR6]], expr: !DIExpression(DW_OP_LLVM_arg0)) constant int *global FileVar6; // CHECK-DAG: ![[FILEVAR7:[0-9]+]] = distinct !DIGlobalVariable(name: "FileVar7", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: false, isDefinition: true) -// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR7]], expr: !DIExpression()) +// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR7]], expr: !DIExpression(DW_OP_LLVM_arg0)) local int *global FileVar7; // CHECK-DAG: ![[FILEVAR8:[0-9]+]] = distinct !DIGlobalVariable(name: "FileVar8", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: false, isDefinition: true) -// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR8]], expr: !DIExpression()) +// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR8]], expr: !DIExpression(DW_OP_LLVM_arg0)) private int *global FileVar8; // CHECK-DAG: ![[FILEVAR9:[0-9]+]] = distinct !DIGlobalVariable(name: "FileVar9", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: false, isDefinition: true) -// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR9]], expr: !DIExpression()) +// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR9]], expr: !DIExpression(DW_OP_LLVM_arg0)) int *global FileVar9; // CHECK-DAG: ![[FILEVAR10:[0-9]+]] = distinct !DIGlobalVariable(name: "FileVar10", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: false, isDefinition: true) -// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR10]], expr: !DIExpression()) +// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR10]], expr: !DIExpression(DW_OP_LLVM_arg0)) global int *constant FileVar10 = 0; // CHECK-DAG: ![[FILEVAR11:[0-9]+]] = distinct !DIGlobalVariable(name: "FileVar11", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: false, isDefinition: true) -// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR11]], expr: !DIExpression()) +// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR11]], expr: !DIExpression(DW_OP_LLVM_arg0)) constant int *constant FileVar11 = 0; // CHECK-DAG: ![[FILEVAR12:[0-9]+]] = distinct !DIGlobalVariable(name: "FileVar12", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: false, isDefinition: true) -// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR12]], expr: !DIExpression()) +// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR12]], expr: !DIExpression(DW_OP_LLVM_arg0)) local int *constant FileVar12 = 0; // CHECK-DAG: ![[FILEVAR13:[0-9]+]] = distinct !DIGlobalVariable(name: "FileVar13", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: false, isDefinition: true) -// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR13]], expr: !DIExpression()) +// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR13]], expr: !DIExpression(DW_OP_LLVM_arg0)) private int *constant FileVar13 = 0; // CHECK-DAG: ![[FILEVAR14:[0-9]+]] = distinct !DIGlobalVariable(name: "FileVar14", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: false, isDefinition: true) -// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR14]], expr: !DIExpression()) +// CHECK-DAG: !DIGlobalVariableExpression(var: ![[FILEVAR14]], expr: !DIExpression(DW_OP_LLVM_arg0)) int *constant FileVar14 = 0; kernel void kernel1( @@ -79,19 +79,19 @@ int *FuncVar4 = Tmp1; // CHECK-DAG: ![[FUNCVAR5:[0-9]+]] = distinct !DIGlobalVariable(name: "FuncVar5", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: true, isDefinition: true) - // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR5]], expr: !DIExpression()) + // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR5]], expr: !DIExpression(DW_OP_LLVM_arg0)) global int *constant FuncVar5 = 0; // CHECK-DAG: ![[FUNCVAR6:[0-9]+]] = distinct !DIGlobalVariable(name: "FuncVar6", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: true, isDefinition: true) - // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR6]], expr: !DIExpression()) + // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR6]], expr: !DIExpression(DW_OP_LLVM_arg0)) constant int *constant FuncVar6 = 0; // CHECK-DAG: ![[FUNCVAR7:[0-9]+]] = distinct !DIGlobalVariable(name: "FuncVar7", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: true, isDefinition: true) - // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR7]], expr: !DIExpression()) + // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR7]], expr: !DIExpression(DW_OP_LLVM_arg0)) local int *constant FuncVar7 = 0; // CHECK-DAG: ![[FUNCVAR8:[0-9]+]] = distinct !DIGlobalVariable(name: "FuncVar8", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: true, isDefinition: true) - // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR8]], expr: !DIExpression()) + // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR8]], expr: !DIExpression(DW_OP_LLVM_arg0)) private int *constant FuncVar8 = 0; // CHECK-DAG: ![[FUNCVAR9:[0-9]+]] = distinct !DIGlobalVariable(name: "FuncVar9", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: true, isDefinition: true) - // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR9]], expr: !DIExpression()) + // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR9]], expr: !DIExpression(DW_OP_LLVM_arg0)) int *constant FuncVar9 = 0; // CHECK-DAG: ![[FUNCVAR10:[0-9]+]] = distinct !DIGlobalVariable(name: "FuncVar10", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: true, isDefinition: true) Index: clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp =================================================================== --- clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp +++ clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp @@ -38,7 +38,7 @@ // TCHECK: [[A_ADDR:%.+]] = alloca i{{[0-9]+}}, // TCHECK-NOT: alloca [[TTII]], // TCHECK-NOT: alloca i{{[0-9]+}}, - // TCHECK-64: call void @llvm.dbg.declare(metadata [10 x float] addrspace(1)** %{{.+}}, metadata !{{[0-9]+}}, metadata !DIExpression()) + // TCHECK-64: call void @llvm.dbg.declare(metadata [10 x float] addrspace(1)** %{{.+}}, metadata !{{[0-9]+}}, metadata !DIExpression(DW_OP_LLVM_arg0)) // TCHECK: store i{{[0-9]+}} [[A_IN]], i{{[0-9]+}}* [[A_ADDR]], // TCHECK: ret void Index: llvm/docs/LangRef.rst =================================================================== --- llvm/docs/LangRef.rst +++ llvm/docs/LangRef.rst @@ -4825,6 +4825,12 @@ signed offset of the specified register. The opcode is only generated by the ``AsmPrinter`` pass to describe call site parameter value which requires an expression over two registers. +- ``DW_OP_LLVM_argN`` represents argument number N of the containing LLVM + intrinsic. Where N can be any value from 0 to 7. For example in intrinsic + ``call @llvm.dbg.someintrinsic(DILocalVariable("x"), DILocalVariable("y"), + metadata !DIExpression(DW_OP_LLVM_arg0, DW_OP_LLVM_arg1, DW_OP_plus))`` + ``DW_OP_LLVM_arg0`` represents ``DILocalVariable("x")`` and + ``DW_OP_LLVM_arg1`` represents ``DILocalVariable("y")``. DWARF specifies three kinds of simple location descriptions: Register, memory, and implicit location descriptions. Note that a location description is Index: llvm/include/llvm/BinaryFormat/Dwarf.h =================================================================== --- llvm/include/llvm/BinaryFormat/Dwarf.h +++ llvm/include/llvm/BinaryFormat/Dwarf.h @@ -122,6 +122,14 @@ DW_OP_LLVM_convert = 0x1001, ///< Only used in LLVM metadata. DW_OP_LLVM_tag_offset = 0x1002, ///< Only used in LLVM metadata. DW_OP_LLVM_entry_value = 0x1003, ///< Only used in LLVM metadata. + DW_OP_LLVM_arg0 = 0x1004, ///< Only used in LLVM metadata. + DW_OP_LLVM_arg1 = 0x1005, ///< Only used in LLVM metadata. + DW_OP_LLVM_arg2 = 0x1006, ///< Only used in LLVM metadata. + DW_OP_LLVM_arg3 = 0x1007, ///< Only used in LLVM metadata. + DW_OP_LLVM_arg4 = 0x1008, ///< Only used in LLVM metadata. + DW_OP_LLVM_arg5 = 0x1009, ///< Only used in LLVM metadata. + DW_OP_LLVM_arg6 = 0x100a, ///< Only used in LLVM metadata. + DW_OP_LLVM_arg7 = 0x100b, ///< Only used in LLVM metadata. }; enum TypeKind : uint8_t { Index: llvm/include/llvm/IR/DebugInfoMetadata.h =================================================================== --- llvm/include/llvm/IR/DebugInfoMetadata.h +++ llvm/include/llvm/IR/DebugInfoMetadata.h @@ -2447,7 +2447,9 @@ /// Return whether the first element a DW_OP_deref. bool startsWithDeref() const { - return getNumElements() > 0 && getElement(0) == dwarf::DW_OP_deref; + return (getNumElements() > 0 && getElement(0) == dwarf::DW_OP_deref) || + (getNumElements() > 1 && getElement(0) == dwarf::DW_OP_LLVM_arg0 && + getElement(1) == dwarf::DW_OP_deref); } /// Holds the characteristics of one fragment of a larger variable. Index: llvm/lib/BinaryFormat/Dwarf.cpp =================================================================== --- llvm/lib/BinaryFormat/Dwarf.cpp +++ llvm/lib/BinaryFormat/Dwarf.cpp @@ -151,6 +151,22 @@ return "DW_OP_LLVM_tag_offset"; case DW_OP_LLVM_entry_value: return "DW_OP_LLVM_entry_value"; + case DW_OP_LLVM_arg0: + return "DW_OP_LLVM_arg0"; + case DW_OP_LLVM_arg1: + return "DW_OP_LLVM_arg1"; + case DW_OP_LLVM_arg2: + return "DW_OP_LLVM_arg2"; + case DW_OP_LLVM_arg3: + return "DW_OP_LLVM_arg3"; + case DW_OP_LLVM_arg4: + return "DW_OP_LLVM_arg4"; + case DW_OP_LLVM_arg5: + return "DW_OP_LLVM_arg5"; + case DW_OP_LLVM_arg6: + return "DW_OP_LLVM_arg6"; + case DW_OP_LLVM_arg7: + return "DW_OP_LLVM_arg7"; } } @@ -163,6 +179,14 @@ .Case("DW_OP_LLVM_fragment", DW_OP_LLVM_fragment) .Case("DW_OP_LLVM_tag_offset", DW_OP_LLVM_tag_offset) .Case("DW_OP_LLVM_entry_value", DW_OP_LLVM_entry_value) + .Case("DW_OP_LLVM_arg0", DW_OP_LLVM_arg0) + .Case("DW_OP_LLVM_arg1", DW_OP_LLVM_arg1) + .Case("DW_OP_LLVM_arg2", DW_OP_LLVM_arg2) + .Case("DW_OP_LLVM_arg3", DW_OP_LLVM_arg3) + .Case("DW_OP_LLVM_arg4", DW_OP_LLVM_arg4) + .Case("DW_OP_LLVM_arg5", DW_OP_LLVM_arg5) + .Case("DW_OP_LLVM_arg6", DW_OP_LLVM_arg6) + .Case("DW_OP_LLVM_arg7", DW_OP_LLVM_arg7) .Default(0); } Index: llvm/lib/Bitcode/Reader/MetadataLoader.cpp =================================================================== --- llvm/lib/Bitcode/Reader/MetadataLoader.cpp +++ llvm/lib/Bitcode/Reader/MetadataLoader.cpp @@ -503,8 +503,10 @@ for (unsigned I = 0; I < GVs->getNumOperands(); I++) if (auto *GV = dyn_cast_or_null(GVs->getOperand(I))) { - auto *DGVE = DIGlobalVariableExpression::getDistinct( - Context, GV, DIExpression::get(Context, {})); + auto *Expr = + DIExpression::get(Context, {llvm::dwarf::DW_OP_LLVM_arg0}); + auto *DGVE = + DIGlobalVariableExpression::getDistinct(Context, GV, Expr); GVs->replaceOperandWith(I, DGVE); } } @@ -537,7 +539,7 @@ if (DIExpr->startsWithDeref() && dyn_cast_or_null(DDI->getAddress())) { SmallVector Ops; - Ops.append(std::next(DIExpr->elements_begin()), + Ops.append(std::next(DIExpr->elements_begin(), 2), DIExpr->elements_end()); auto *E = DIExpression::get(Context, Ops); DDI->setOperand(2, MetadataAsValue::get(Context, E)); @@ -618,7 +620,30 @@ Expr = MutableArrayRef(Buffer); LLVM_FALLTHROUGH; } - case 3: + case 3: { + if (Expr.size() == 0) { + Buffer.push_back(dwarf::DW_OP_LLVM_arg0); + } else if (Expr[0] == dwarf::DW_OP_deref) { + Buffer.insert(Buffer.begin(), dwarf::DW_OP_LLVM_arg0); + } else if (Expr.size() >= 3) { + switch (Expr[2]) { + case dwarf::DW_OP_mul: + case dwarf::DW_OP_div: + case dwarf::DW_OP_mod: + case dwarf::DW_OP_or: + case dwarf::DW_OP_and: + case dwarf::DW_OP_xor: + case dwarf::DW_OP_shl: + case dwarf::DW_OP_shr: + case dwarf::DW_OP_shra: + Buffer.insert(Buffer.begin(), dwarf::DW_OP_LLVM_arg0); + break; + } + } + Expr = MutableArrayRef(Buffer); + LLVM_FALLTHROUGH; + } + case 4: // Up-to-date! break; } @@ -1757,7 +1782,9 @@ DIGlobalVariableExpression *DGVE = nullptr; if (Attach || Expr) DGVE = DIGlobalVariableExpression::getDistinct( - Context, DGV, Expr ? Expr : DIExpression::get(Context, {})); + Context, DGV, + Expr ? Expr + : DIExpression::get(Context, {llvm::dwarf::DW_OP_LLVM_arg0})); if (Attach) Attach->addDebugInfo(DGVE); Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp =================================================================== --- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -1874,7 +1874,7 @@ SmallVectorImpl &Record, unsigned Abbrev) { Record.reserve(N->getElements().size() + 1); - const uint64_t Version = 3 << 1; + const uint64_t Version = 4 << 1; Record.push_back((uint64_t)N->isDistinct() | Version); Record.append(N->elements_begin(), N->elements_end()); Index: llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp =================================================================== --- llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp +++ llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp @@ -379,7 +379,9 @@ } else if (OpNum >= dwarf::DW_OP_breg0 && OpNum <= dwarf::DW_OP_breg31) { addBReg(OpNum - dwarf::DW_OP_breg0, Op->getArg(0)); continue; - } + } else if (OpNum >= dwarf::DW_OP_LLVM_arg0 && + OpNum <= dwarf::DW_OP_LLVM_arg7) + continue; switch (OpNum) { case dwarf::DW_OP_LLVM_fragment: { Index: llvm/lib/IR/DIBuilder.cpp =================================================================== --- llvm/lib/IR/DIBuilder.cpp +++ llvm/lib/IR/DIBuilder.cpp @@ -649,8 +649,10 @@ VMContext, cast_or_null(Context), Name, LinkageName, F, LineNumber, Ty, IsLocalToUnit, isDefined, cast_or_null(Decl), TemplateParams, AlignInBits); - if (!Expr) + if (!Expr) { Expr = createExpression(); + Expr = DIExpression::append(Expr, llvm::dwarf::DW_OP_LLVM_arg0); + } auto *N = DIGlobalVariableExpression::get(VMContext, GV, Expr); AllGVs.push_back(N); return N; Index: llvm/lib/IR/DebugInfoMetadata.cpp =================================================================== --- llvm/lib/IR/DebugInfoMetadata.cpp +++ llvm/lib/IR/DebugInfoMetadata.cpp @@ -862,7 +862,8 @@ uint64_t Op = I->getOp(); if ((Op >= dwarf::DW_OP_reg0 && Op <= dwarf::DW_OP_reg31) || - (Op >= dwarf::DW_OP_breg0 && Op <= dwarf::DW_OP_breg31)) + (Op >= dwarf::DW_OP_breg0 && Op <= dwarf::DW_OP_breg31) || + (Op >= dwarf::DW_OP_LLVM_arg0 && Op <= dwarf::DW_OP_LLVM_arg7)) return true; // Check that the operand is valid. @@ -995,23 +996,31 @@ } bool DIExpression::extractIfOffset(int64_t &Offset) const { - if (getNumElements() == 0) { + unsigned NumElements = getNumElements(); + unsigned Index = 0; + + if (NumElements > 0 && Elements[0] == dwarf::DW_OP_LLVM_arg0) { + Index = 1; + NumElements --; + } + + if (NumElements == 0) { Offset = 0; return true; } - if (getNumElements() == 2 && Elements[0] == dwarf::DW_OP_plus_uconst) { - Offset = Elements[1]; + if (NumElements == 2 && Elements[Index] == dwarf::DW_OP_plus_uconst) { + Offset = Elements[Index + 1]; return true; } - if (getNumElements() == 3 && Elements[0] == dwarf::DW_OP_constu) { - if (Elements[2] == dwarf::DW_OP_plus) { - Offset = Elements[1]; + if (NumElements == 3 && Elements[Index] == dwarf::DW_OP_constu) { + if (Elements[Index + 2] == dwarf::DW_OP_plus) { + Offset = Elements[Index + 1]; return true; } - if (Elements[2] == dwarf::DW_OP_minus) { - Offset = -Elements[1]; + if (Elements[Index + 2] == dwarf::DW_OP_minus) { + Offset = -Elements[Index + 1]; return true; } } @@ -1061,6 +1070,8 @@ bool EntryValue) { assert(Expr && "Can't prepend ops to this expression"); + expr_op_iterator Itr = Expr->expr_op_begin(); + expr_op_iterator EndItr = Expr->expr_op_end(); if (EntryValue) { Ops.push_back(dwarf::DW_OP_LLVM_entry_value); // Add size info needed for entry value expression. @@ -1071,17 +1082,20 @@ // If there are no ops to prepend, do not even add the DW_OP_stack_value. if (Ops.empty()) StackValue = false; - for (auto Op : Expr->expr_ops()) { + else if (Itr != EndItr && Itr->getOp() == dwarf::DW_OP_LLVM_arg0) + Itr++; + + for (; Itr != EndItr; Itr++) { // A DW_OP_stack_value comes at the end, but before a DW_OP_LLVM_fragment. if (StackValue) { - if (Op.getOp() == dwarf::DW_OP_stack_value) + if (Itr->getOp() == dwarf::DW_OP_stack_value) StackValue = false; - else if (Op.getOp() == dwarf::DW_OP_LLVM_fragment) { + else if (Itr->getOp() == dwarf::DW_OP_LLVM_fragment) { Ops.push_back(dwarf::DW_OP_stack_value); StackValue = false; } } - Op.appendToVector(Ops); + Itr->appendToVector(Ops); } if (StackValue) Ops.push_back(dwarf::DW_OP_stack_value); @@ -1147,7 +1161,9 @@ const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits) { SmallVector Ops; // Copy over the expression, but leave off any trailing DW_OP_LLVM_fragment. - if (Expr) { + if (Expr && !(Expr->getNumElements() == 1 && + Expr->getElement(0) == dwarf::DW_OP_LLVM_arg0)) { + for (auto Op : Expr->expr_ops()) { switch (Op.getOp()) { default: break; Index: llvm/lib/Transforms/Utils/Local.cpp =================================================================== --- llvm/lib/Transforms/Utils/Local.cpp +++ llvm/lib/Transforms/Utils/Local.cpp @@ -1438,8 +1438,13 @@ // the variable by dereferencing the alloca. if (!CI->isLifetimeStartOrEnd()) { DebugLoc NewLoc = getDebugValueLoc(DDI, nullptr); - auto *DerefExpr = - DIExpression::append(DDI->getExpression(), dwarf::DW_OP_deref); + DIExpression *DerefExpr = DDI->getExpression(); + + if (DDI->getExpression()->getNumElements() == 0) + DerefExpr = DIExpression::append(DerefExpr, + dwarf::DW_OP_LLVM_arg0); + + DerefExpr = DIExpression::append(DerefExpr, dwarf::DW_OP_deref); DIB.insertDbgValueIntrinsic(AI, DDI->getVariable(), DerefExpr, NewLoc, CI); } @@ -1583,14 +1588,25 @@ // This is an alloca-based llvm.dbg.value. The first thing it should do with // the alloca pointer is dereference it. Otherwise we don't know how to handle // it and give up. - if (!DIExpr || DIExpr->getNumElements() < 1 || - DIExpr->getElement(0) != dwarf::DW_OP_deref) + + if (!DIExpr || (DIExpr->getNumElements() == 0) || + !(DIExpr->getElement(0) == dwarf::DW_OP_deref || + (DIExpr->getNumElements() > 1 && + DIExpr->getElement(0) == dwarf::DW_OP_LLVM_arg0 && + DIExpr->getElement(1) == dwarf::DW_OP_deref))) return; // Insert the offset before the first deref. // We could just change the offset argument of dbg.value, but it's unsigned... - if (Offset) + if (Offset) { + if (DIExpr->getElement(0) == dwarf::DW_OP_LLVM_arg0) { + ArrayRef NewElem = DIExpr->getElements().drop_front(); + SmallVector Ops; + Ops.append(NewElem.begin(), NewElem.end()); + DIExpr = DIExpression::get(DIExpr->getContext(), Ops); + } DIExpr = DIExpression::prepend(DIExpr, 0, Offset); + } Builder.insertDbgValueIntrinsic(NewAddress, DIVar, DIExpr, Loc, DVI); DVI->eraseFromParent(); @@ -1722,23 +1738,32 @@ case Instruction::Sub: return applyOffset(-int64_t(Val)); case Instruction::Mul: - return applyOps({dwarf::DW_OP_constu, Val, dwarf::DW_OP_mul}); + return applyOps( + {dwarf::DW_OP_LLVM_arg0, dwarf::DW_OP_constu, Val, dwarf::DW_OP_mul}); case Instruction::SDiv: - return applyOps({dwarf::DW_OP_constu, Val, dwarf::DW_OP_div}); + return applyOps( + {dwarf::DW_OP_LLVM_arg0, dwarf::DW_OP_constu, Val, dwarf::DW_OP_div}); case Instruction::SRem: - return applyOps({dwarf::DW_OP_constu, Val, dwarf::DW_OP_mod}); + return applyOps( + {dwarf::DW_OP_LLVM_arg0, dwarf::DW_OP_constu, Val, dwarf::DW_OP_mod}); case Instruction::Or: - return applyOps({dwarf::DW_OP_constu, Val, dwarf::DW_OP_or}); + return applyOps( + {dwarf::DW_OP_LLVM_arg0, dwarf::DW_OP_constu, Val, dwarf::DW_OP_or}); case Instruction::And: - return applyOps({dwarf::DW_OP_constu, Val, dwarf::DW_OP_and}); + return applyOps( + {dwarf::DW_OP_LLVM_arg0, dwarf::DW_OP_constu, Val, dwarf::DW_OP_and}); case Instruction::Xor: - return applyOps({dwarf::DW_OP_constu, Val, dwarf::DW_OP_xor}); + return applyOps( + {dwarf::DW_OP_LLVM_arg0, dwarf::DW_OP_constu, Val, dwarf::DW_OP_xor}); case Instruction::Shl: - return applyOps({dwarf::DW_OP_constu, Val, dwarf::DW_OP_shl}); + return applyOps( + {dwarf::DW_OP_LLVM_arg0, dwarf::DW_OP_constu, Val, dwarf::DW_OP_shl}); case Instruction::LShr: - return applyOps({dwarf::DW_OP_constu, Val, dwarf::DW_OP_shr}); + return applyOps( + {dwarf::DW_OP_LLVM_arg0, dwarf::DW_OP_constu, Val, dwarf::DW_OP_shr}); case Instruction::AShr: - return applyOps({dwarf::DW_OP_constu, Val, dwarf::DW_OP_shra}); + return applyOps({dwarf::DW_OP_LLVM_arg0, dwarf::DW_OP_constu, Val, + dwarf::DW_OP_shra}); default: // TODO: Salvage constants from each kind of binop we know about. return nullptr; Index: llvm/test/Bitcode/DIExpression-deref.ll =================================================================== --- llvm/test/Bitcode/DIExpression-deref.ll +++ llvm/test/Bitcode/DIExpression-deref.ll @@ -17,7 +17,7 @@ !7 = !DIExpression(DW_OP_deref, DW_OP_plus, 0) ; CHECK: !DIExpression(DW_OP_plus_uconst, 1, DW_OP_deref) !8 = !DIExpression(DW_OP_plus, 1, DW_OP_deref) -; CHECK: !DIExpression(DW_OP_deref) +; CHECK: !DIExpression(DW_OP_LLVM_arg0, DW_OP_deref) !9 = !DIExpression(DW_OP_deref) !10 = !DIGlobalVariableExpression(var: !0, expr: !6) !11 = !DIGlobalVariableExpression(var: !0, expr: !7) Index: llvm/test/Bitcode/DIGlobalVariableExpression2.ll =================================================================== --- llvm/test/Bitcode/DIGlobalVariableExpression2.ll +++ llvm/test/Bitcode/DIGlobalVariableExpression2.ll @@ -1,10 +1,10 @@ ; RUN: llvm-dis -o - %s.bc | FileCheck %s ; CHECK: @g = common global i32 0, align 4, !dbg ![[G:[0-9]+]] -; CHECK-DAG: ![[G]] = distinct !DIGlobalVariableExpression(var: ![[GVAR:[0-9]+]], expr: !DIExpression()) +; CHECK-DAG: ![[G]] = distinct !DIGlobalVariableExpression(var: ![[GVAR:[0-9]+]], expr: !DIExpression(DW_OP_LLVM_arg0)) ; CHECK-DAG: distinct !DICompileUnit({{.*}}, globals: ![[GLOBS:[0-9]+]] ; CHECK-DAG: ![[GLOBS]] = !{![[GEXPR:[0-9]+]]} -; CHECK-DAG: ![[GEXPR]] = distinct !DIGlobalVariableExpression(var: ![[GVAR]], expr: !DIExpression()) +; CHECK-DAG: ![[GEXPR]] = distinct !DIGlobalVariableExpression(var: ![[GVAR]], expr: !DIExpression(DW_OP_LLVM_arg0)) ; CHECK-DAG: ![[GVAR]] = !DIGlobalVariable(name: "g", ; Test the bitcode upgrade for DIGlobalVariable -> DIGlobalVariableExpression. Index: llvm/test/Bitcode/upgrade-dbg-value.ll =================================================================== --- llvm/test/Bitcode/upgrade-dbg-value.ll +++ llvm/test/Bitcode/upgrade-dbg-value.ll @@ -6,7 +6,7 @@ define void @f() !dbg !3 { entry: ; CHECK-NOT: call void @llvm.dbg.value - ; CHECK: call void @llvm.dbg.value(metadata i32 42, metadata !8, metadata !DIExpression()) + ; CHECK: call void @llvm.dbg.value(metadata i32 42, metadata !8, metadata !DIExpression(DW_OP_LLVM_arg0)) call void @llvm.dbg.value(metadata i32 42, i64 0, metadata !8, metadata !9), !dbg !10 ; CHECK-NOT: call void @llvm.dbg.value call void @llvm.dbg.value(metadata i32 0, i64 1, metadata !8, metadata !9), !dbg !10 Index: llvm/test/DebugInfo/Generic/dbg-value-lower-linenos.ll =================================================================== --- llvm/test/DebugInfo/Generic/dbg-value-lower-linenos.ll +++ llvm/test/DebugInfo/Generic/dbg-value-lower-linenos.ll @@ -55,7 +55,7 @@ ; CHECK-SAME: !dbg ![[UNKNOWN2:[0-9]+]] ; CHECK-NEXT: store ; CHECK-NEXT: dbg.value(metadata i32* %map.addr, metadata ![[MAPVAR]], -; CHECK-SAME: metadata !DIExpression(DW_OP_deref)), +; CHECK-SAME: metadata !DIExpression(DW_OP_LLVM_arg0, DW_OP_deref)), ; CHECK-SAME: !dbg ![[UNKNOWN2]] ; CHECK-NEXT: call ; CHECK-NEXT: load Index: llvm/test/Transforms/BDCE/basic.ll =================================================================== --- llvm/test/Transforms/BDCE/basic.ll +++ llvm/test/Transforms/BDCE/basic.ll @@ -387,7 +387,7 @@ entry: %call = tail call signext i32 @foo(i32 signext 5) #0 %and = and i32 %call, 33554432 -; DEBUGIFY: call void @llvm.dbg.value(metadata i32 %call, metadata {{.*}}, metadata !DIExpression(DW_OP_constu, 33554432, DW_OP_and, DW_OP_stack_value)) +; DEBUGIFY: call void @llvm.dbg.value(metadata i32 %call, metadata {{.*}}, metadata !DIExpression(DW_OP_LLVM_arg0, DW_OP_constu, 33554432, DW_OP_and, DW_OP_stack_value)) %cast = trunc i32 %call to i16 ret i16 %cast } Index: llvm/test/Transforms/InstCombine/debuginfo-variables.ll =================================================================== --- llvm/test/Transforms/InstCombine/debuginfo-variables.ll +++ llvm/test/Transforms/InstCombine/debuginfo-variables.ll @@ -39,14 +39,14 @@ define void @test_or(i64 %A) { ; CHECK-LABEL: @test_or( -; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 256, DW_OP_or, DW_OP_stack_value)) +; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_LLVM_arg0, DW_OP_constu, 256, DW_OP_or, DW_OP_stack_value)) %1 = or i64 %A, 256 ret void } define void @test_xor(i32 %A) { ; CHECK-LABEL: @test_xor( -; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 1, DW_OP_xor, DW_OP_stack_value)) +; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 %A, {{.*}}, metadata !DIExpression(DW_OP_LLVM_arg0, DW_OP_constu, 1, DW_OP_xor, DW_OP_stack_value)) %1 = xor i32 %A, 1 ret void } @@ -67,42 +67,42 @@ define void @test_shl(i64 %A) { ; CHECK-LABEL: @test_shl( -; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 7, DW_OP_shl, DW_OP_stack_value)) +; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_LLVM_arg0, DW_OP_constu, 7, DW_OP_shl, DW_OP_stack_value)) %1 = shl i64 %A, 7 ret void } define void @test_lshr(i64 %A) { ; CHECK-LABEL: @test_lshr( -; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 7, DW_OP_shr, DW_OP_stack_value)) +; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_LLVM_arg0, DW_OP_constu, 7, DW_OP_shr, DW_OP_stack_value)) %1 = lshr i64 %A, 7 ret void } define void @test_ashr(i64 %A) { ; CHECK-LABEL: @test_ashr( -; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 7, DW_OP_shra, DW_OP_stack_value)) +; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_LLVM_arg0, DW_OP_constu, 7, DW_OP_shra, DW_OP_stack_value)) %1 = ashr i64 %A, 7 ret void } define void @test_mul(i64 %A) { ; CHECK-LABEL: @test_mul( -; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 7, DW_OP_mul, DW_OP_stack_value)) +; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_LLVM_arg0, DW_OP_constu, 7, DW_OP_mul, DW_OP_stack_value)) %1 = mul i64 %A, 7 ret void } define void @test_sdiv(i64 %A) { ; CHECK-LABEL: @test_sdiv( -; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 7, DW_OP_div, DW_OP_stack_value)) +; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_LLVM_arg0, DW_OP_constu, 7, DW_OP_div, DW_OP_stack_value)) %1 = sdiv i64 %A, 7 ret void } define void @test_srem(i64 %A) { ; CHECK-LABEL: @test_srem( -; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 7, DW_OP_mod, DW_OP_stack_value)) +; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_LLVM_arg0, DW_OP_constu, 7, DW_OP_mod, DW_OP_stack_value)) %1 = srem i64 %A, 7 ret void } @@ -116,7 +116,7 @@ define void @test_and(i64 %A) { ; CHECK-LABEL: @test_and( -; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_constu, 256, DW_OP_and, DW_OP_stack_value)) +; CHECK-NEXT: call void @llvm.dbg.value(metadata i64 %A, {{.*}}, metadata !DIExpression(DW_OP_LLVM_arg0, DW_OP_constu, 256, DW_OP_and, DW_OP_stack_value)) %1 = and i64 %A, 256 ret void } Index: llvm/test/Transforms/InstCombine/lower-dbg-declare.ll =================================================================== --- llvm/test/Transforms/InstCombine/lower-dbg-declare.ll +++ llvm/test/Transforms/InstCombine/lower-dbg-declare.ll @@ -43,7 +43,7 @@ br i1 %lnot, label %while.body, label %while.end, !dbg !22 while.body: ; preds = %while.cond -; CHECK: dbg.value(metadata i32* %d1, metadata [[METADATA_IDX1]], metadata !DIExpression(DW_OP_deref)) +; CHECK: dbg.value(metadata i32* %d1, metadata [[METADATA_IDX1]], metadata !DIExpression(DW_OP_LLVM_arg0, DW_OP_deref)) ; CHECK-NEXT: call void @_ZL6escapeRi call void @_ZL6escapeRi(i32* dereferenceable(4) %d1), !dbg !23 br label %while.cond, !dbg !22, !llvm.loop !24 Index: llvm/test/Transforms/Util/dbg-call-bitcast.ll =================================================================== --- llvm/test/Transforms/Util/dbg-call-bitcast.ll +++ llvm/test/Transforms/Util/dbg-call-bitcast.ll @@ -6,11 +6,11 @@ call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %2) call void @llvm.dbg.declare(metadata i32* %1, metadata !16, metadata !DIExpression()), !dbg !19 ; CHECK: %[[A:.*]] = alloca i32, align 4 -; CHECK: call void @llvm.dbg.value(metadata i32* %[[A]], {{.*}}, metadata !DIExpression(DW_OP_deref) +; CHECK: call void @llvm.dbg.value(metadata i32* %[[A]], {{.*}}, metadata !DIExpression(DW_OP_LLVM_arg0, DW_OP_deref) ; CHECK: call void @_Z1gPv call void @_Z1gPv(i8* nonnull %2) %3 = bitcast i32* %1 to i8* -; CHECK: call void @llvm.dbg.value(metadata i32* %[[A]], {{.*}}, metadata !DIExpression(DW_OP_deref) +; CHECK: call void @llvm.dbg.value(metadata i32* %[[A]], {{.*}}, metadata !DIExpression(DW_OP_LLVM_arg0, DW_OP_deref) ; CHECK: call void @_Z1gPv call void @_Z1gPv(i8* nonnull %3) call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %2)