Index: clang/test/CodeGen/2010-08-10-DbgConstant.c =================================================================== --- clang/test/CodeGen/2010-08-10-DbgConstant.c +++ clang/test/CodeGen/2010-08-10-DbgConstant.c @@ -1,6 +1,5 @@ // RUN: %clang_cc1 -S -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s -// CHECK: !DIGlobalVariableExpression(var: [[VAR:.*]], expr: [[EXPR:![0-9]+]]) -// CHECK: [[EXPR]] = !DIExpression(DW_OP_constu, 201, DW_OP_stack_value) +// CHECK: !DIGlobalVariableExpression(var: [[VAR:.*]], expr: !DIExpression(DW_OP_constu, 201, DW_OP_stack_value)) static const unsigned int ro = 201; void bar(int); Index: clang/test/CodeGen/debug-info-global-constant.c =================================================================== --- clang/test/CodeGen/debug-info-global-constant.c +++ clang/test/CodeGen/debug-info-global-constant.c @@ -5,11 +5,10 @@ // exactly once. // CHECK: @i = internal constant i32 1, align 4, !dbg ![[I:[0-9]+]] -// CHECK: ![[I]] = !DIGlobalVariableExpression(var: ![[VAR:.*]], expr: ![[EXPR:[0-9]+]]) +// CHECK: ![[I]] = !DIGlobalVariableExpression(var: ![[VAR:.*]], expr: !DIExpression(DW_OP_constu, 1, DW_OP_stack_value)) // CHECK: ![[VAR]] = distinct !DIGlobalVariable(name: "i", // CHECK: !DICompileUnit({{.*}}globals: ![[GLOBALS:[0-9]+]]) // CHECK: ![[GLOBALS]] = !{![[I]]} -// CHECK: ![[EXPR]] = !DIExpression(DW_OP_constu, 1, DW_OP_stack_value) static const int i = 1; void g(const int *, int); 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 @@ -33,20 +33,17 @@ return hVal + fVal + dVal + ldVal; } -// CHECK: !DIGlobalVariableExpression(var: [[HVAL:.*]], expr: [[HEXPR:.*]]) +// CHECK: !DIGlobalVariableExpression(var: [[HVAL:.*]], expr: !DIExpression(DW_OP_constu, 16502, DW_OP_stack_value)) // CHECK: [[HVAL]] = distinct !DIGlobalVariable(name: "hVal", // CHECK-SAME: isLocal: true, isDefinition: true -// CHECK: [[HEXPR]] = !DIExpression(DW_OP_constu, 16502, DW_OP_stack_value) -// CHECK: !DIGlobalVariableExpression(var: [[FVAL:.*]], expr: [[FEXPR:.*]]) +// CHECK: !DIGlobalVariableExpression(var: [[FVAL:.*]], expr: !DIExpression(DW_OP_constu, 3238681178, DW_OP_stack_value)) // CHECK: [[FVAL]] = distinct !DIGlobalVariable(name: "fVal", // CHECK-SAME: isLocal: true, isDefinition: true -// CHECK: [[FEXPR]] = !DIExpression(DW_OP_constu, 3238681178, DW_OP_stack_value) -// CHECK: !DIGlobalVariableExpression(var: [[DVAL:.*]], expr: [[DEXPR:.*]]) +// CHECK: !DIGlobalVariableExpression(var: [[DVAL:.*]], expr: !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value)) // CHECK: [[DVAL]] = distinct !DIGlobalVariable(name: "dVal", // CHECK-SAME: isLocal: true, isDefinition: true -// CHECK: [[DEXPR]] = !DIExpression(DW_OP_constu, 4658387303597904457, DW_OP_stack_value) // CHECK-LDlg-DAG: [[LDVAL:.*]] = distinct !DIGlobalVariable(name: "ldVal", {{.*}}, isLocal: true, isDefinition: true) // CHECK-LDlg-DAG: !DIGlobalVariableExpression(var: [[LDVAL]]) Index: clang/test/CodeGen/debug-info-vla.c =================================================================== --- clang/test/CodeGen/debug-info-vla.c +++ clang/test/CodeGen/debug-info-vla.c @@ -3,8 +3,7 @@ void testVLAwithSize(int s) { // CHECK: dbg.declare -// CHECK: dbg.declare({{.*}}, metadata ![[VAR:.*]], metadata ![[EXPR:.*]]) -// CHECK: ![[EXPR]] = !DIExpression() +// CHECK: dbg.declare({{.*}}, metadata ![[VAR:.*]], metadata !DIExpression()) // CHECK: ![[VAR]] = !DILocalVariable(name: "vla",{{.*}} line: [[@LINE+1]] int vla[s]; int i; 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 !{{[0-9]+}}), !dbg ![[LOC:[0-9]+]] +// CHECK-SAME: metadata ![[THIS:[0-9]+]], metadata !DIExpression()), !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.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info.cpp +++ clang/test/CodeGenCXX/debug-info.cpp @@ -4,7 +4,7 @@ // 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 ![[EXPR:[0-9]+]]) +// CHECK: call void @llvm.dbg.declare({{.*}}, metadata ![[F:[0-9]+]], metadata !DIExpression()) // !llvm.dbg.cu pulls in globals and their types first. // CHECK-NOT: !DIGlobalVariable(name: "c" @@ -21,7 +21,6 @@ // CHECK: ![[INCTYPE]] = !DICompositeType(tag: DW_TAG_structure_type, name: "incomplete" // CHECK-SAME: DIFlagFwdDecl -// CHECK: ![[EXPR]] = !DIExpression() template struct Identity { typedef T Type; 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 @@ -1,9 +1,6 @@ // RUN: %clang -cl-std=CL2.0 -emit-llvm -g -O0 -S -target amdgcn-amd-amdhsa -mcpu=fiji -o - %s | FileCheck %s // RUN: %clang -cl-std=CL2.0 -emit-llvm -g -O0 -S -target amdgcn-amd-amdhsa-opencl -mcpu=fiji -o - %s | FileCheck %s -// CHECK-DAG: ![[LOCAL:[0-9]+]] = !DIExpression(DW_OP_constu, 2, DW_OP_swap, DW_OP_xderef) -// CHECK-DAG: ![[PRIVATE:[0-9]+]] = !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef) - // 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]]) global int *FileVar0; @@ -54,31 +51,31 @@ kernel void kernel1( // CHECK-DAG: ![[KERNELARG0:[0-9]+]] = !DILocalVariable(name: "KernelArg0", arg: {{[0-9]+}}, scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}) - // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(1)** {{.*}}, metadata ![[KERNELARG0]], metadata ![[PRIVATE]]), !dbg !{{[0-9]+}} + // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(1)** {{.*}}, metadata ![[KERNELARG0]], metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !{{[0-9]+}} global int *KernelArg0, // CHECK-DAG: ![[KERNELARG1:[0-9]+]] = !DILocalVariable(name: "KernelArg1", arg: {{[0-9]+}}, scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}) - // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(2)** {{.*}}, metadata ![[KERNELARG1]], metadata ![[PRIVATE]]), !dbg !{{[0-9]+}} + // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(2)** {{.*}}, metadata ![[KERNELARG1]], metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !{{[0-9]+}} constant int *KernelArg1, // CHECK-DAG: ![[KERNELARG2:[0-9]+]] = !DILocalVariable(name: "KernelArg2", arg: {{[0-9]+}}, scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}) - // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(3)** {{.*}}, metadata ![[KERNELARG2]], metadata ![[PRIVATE]]), !dbg !{{[0-9]+}} + // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(3)** {{.*}}, metadata ![[KERNELARG2]], metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !{{[0-9]+}} local int *KernelArg2) { private int *Tmp0; int *Tmp1; // CHECK-DAG: ![[FUNCVAR0:[0-9]+]] = !DILocalVariable(name: "FuncVar0", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}) - // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(1)** {{.*}}, metadata ![[FUNCVAR0]], metadata ![[PRIVATE]]), !dbg !{{[0-9]+}} + // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(1)** {{.*}}, metadata ![[FUNCVAR0]], metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !{{[0-9]+}} global int *FuncVar0 = KernelArg0; // 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 addrspace(2)** {{.*}}, metadata ![[FUNCVAR1]], metadata ![[PRIVATE]]), !dbg !{{[0-9]+}} + // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(2)** {{.*}}, metadata ![[FUNCVAR1]], metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !{{[0-9]+}} constant int *FuncVar1 = KernelArg1; // CHECK-DAG: ![[FUNCVAR2:[0-9]+]] = !DILocalVariable(name: "FuncVar2", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}) - // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(3)** {{.*}}, metadata ![[FUNCVAR2]], metadata ![[PRIVATE]]), !dbg !{{[0-9]+}} + // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(3)** {{.*}}, metadata ![[FUNCVAR2]], metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !{{[0-9]+}} local int *FuncVar2 = KernelArg2; // CHECK-DAG: ![[FUNCVAR3:[0-9]+]] = !DILocalVariable(name: "FuncVar3", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}) - // CHECK-DAG: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[FUNCVAR3]], metadata ![[PRIVATE]]), !dbg !{{[0-9]+}} + // CHECK-DAG: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[FUNCVAR3]], metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !{{[0-9]+}} private int *FuncVar3 = Tmp0; // CHECK-DAG: ![[FUNCVAR4:[0-9]+]] = !DILocalVariable(name: "FuncVar4", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}) - // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(4)** {{.*}}, metadata ![[FUNCVAR4]], metadata ![[PRIVATE]]), !dbg !{{[0-9]+}} + // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(4)** {{.*}}, metadata ![[FUNCVAR4]], metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !{{[0-9]+}} 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) @@ -98,34 +95,34 @@ 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) - // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR10]], expr: ![[LOCAL]]) + // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR10]], expr: !DIExpression(DW_OP_constu, 2, DW_OP_swap, DW_OP_xderef)) global int *local FuncVar10; FuncVar10 = KernelArg0; // CHECK-DAG: ![[FUNCVAR11:[0-9]+]] = distinct !DIGlobalVariable(name: "FuncVar11", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: true, isDefinition: true) - // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR11]], expr: ![[LOCAL]]) + // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR11]], expr: !DIExpression(DW_OP_constu, 2, DW_OP_swap, DW_OP_xderef)) constant int *local FuncVar11; FuncVar11 = KernelArg1; // CHECK-DAG: ![[FUNCVAR12:[0-9]+]] = distinct !DIGlobalVariable(name: "FuncVar12", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: true, isDefinition: true) - // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR12]], expr: ![[LOCAL]]) + // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR12]], expr: !DIExpression(DW_OP_constu, 2, DW_OP_swap, DW_OP_xderef)) local int *local FuncVar12; FuncVar12 = KernelArg2; // CHECK-DAG: ![[FUNCVAR13:[0-9]+]] = distinct !DIGlobalVariable(name: "FuncVar13", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: true, isDefinition: true) - // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR13]], expr: ![[LOCAL]]) + // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR13]], expr: !DIExpression(DW_OP_constu, 2, DW_OP_swap, DW_OP_xderef)) private int *local FuncVar13; FuncVar13 = Tmp0; // CHECK-DAG: ![[FUNCVAR14:[0-9]+]] = distinct !DIGlobalVariable(name: "FuncVar14", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}, isLocal: true, isDefinition: true) - // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR14]], expr: ![[LOCAL]]) + // CHECK-DAG: !DIGlobalVariableExpression(var: ![[FUNCVAR14]], expr: !DIExpression(DW_OP_constu, 2, DW_OP_swap, DW_OP_xderef)) int *local FuncVar14; FuncVar14 = Tmp1; // CHECK-DAG: ![[FUNCVAR15:[0-9]+]] = !DILocalVariable(name: "FuncVar15", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}) - // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(1)** {{.*}}, metadata ![[FUNCVAR15]], metadata ![[PRIVATE]]), !dbg !{{[0-9]+}} + // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(1)** {{.*}}, metadata ![[FUNCVAR15]], metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !{{[0-9]+}} global int *private FuncVar15 = KernelArg0; // CHECK-DAG: ![[FUNCVAR16:[0-9]+]] = !DILocalVariable(name: "FuncVar16", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}) - // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(2)** {{.*}}, metadata ![[FUNCVAR16]], metadata ![[PRIVATE]]), !dbg !{{[0-9]+}} + // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(2)** {{.*}}, metadata ![[FUNCVAR16]], metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !{{[0-9]+}} constant int *private FuncVar16 = KernelArg1; // CHECK-DAG: ![[FUNCVAR17:[0-9]+]] = !DILocalVariable(name: "FuncVar17", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}) - // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(3)** {{.*}}, metadata ![[FUNCVAR17]], metadata ![[PRIVATE]]), !dbg !{{[0-9]+}} + // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(3)** {{.*}}, metadata ![[FUNCVAR17]], metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !{{[0-9]+}} local int *private FuncVar17 = KernelArg2; // CHECK-DAG: ![[FUNCVAR18:[0-9]+]] = !DILocalVariable(name: "FuncVar18", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}) - // CHECK-DAG: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[FUNCVAR18]], metadata ![[PRIVATE]]), !dbg !{{[0-9]+}} + // CHECK-DAG: call void @llvm.dbg.declare(metadata i32** {{.*}}, metadata ![[FUNCVAR18]], metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !{{[0-9]+}} private int *private FuncVar18 = Tmp0; // CHECK-DAG: ![[FUNCVAR19:[0-9]+]] = !DILocalVariable(name: "FuncVar19", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}}) - // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(4)** {{.*}}, metadata ![[FUNCVAR19]], metadata ![[PRIVATE]]), !dbg !{{[0-9]+}} + // CHECK-DAG: call void @llvm.dbg.declare(metadata i32 addrspace(4)** {{.*}}, metadata ![[FUNCVAR19]], metadata !DIExpression(DW_OP_constu, 1, DW_OP_swap, DW_OP_xderef)), !dbg !{{[0-9]+}} int *private FuncVar19 = Tmp1; } 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 @@ -32,7 +32,7 @@ // TCHECK: define {{.*}}void @__omp_offloading_{{.+}}([10 x float] addrspace(1)* noalias [[B_IN:%.+]], i{{[0-9]+}} [[A_IN:%.+]]) // TCHECK: [[A_ADDR:%.+]] = alloca i{{[0-9]+}}, // TCHECK-NOT: alloca i{{[0-9]+}}, - // TCHECK-64: call void @llvm.dbg.declare(metadata [10 x float] addrspace(1)** %{{.+}}, metadata !{{[0-9]+}}, metadata ![[LOCAL:[0-9]+]]) + // TCHECK-64: call void @llvm.dbg.declare(metadata [10 x float] addrspace(1)** %{{.+}}, metadata !{{[0-9]+}}, metadata !DIExpression()) // TCHECK: store i{{[0-9]+}} [[A_IN]], i{{[0-9]+}}* [[A_ADDR]], // TCHECK: ret void Index: llvm/lib/AsmParser/LLParser.cpp =================================================================== --- llvm/lib/AsmParser/LLParser.cpp +++ llvm/lib/AsmParser/LLParser.cpp @@ -643,11 +643,18 @@ NamedMDNode *NMD = M->getOrInsertNamedMetadata(Name); if (Lex.getKind() != lltok::rbrace) do { - if (ParseToken(lltok::exclaim, "Expected '!' here")) - return true; - MDNode *N = nullptr; - if (ParseMDNodeID(N)) return true; + // Parse DIExpressions inline as a special case. They are still MDNodes, + // so they can still appear in named metadata. Remove this logic if they + // become plain Metadata. + if (Lex.getKind() == lltok::MetadataVar && + Lex.getStrVal() == "DIExpression") { + if (ParseDIExpression(N, /*IsDistinct=*/false)) + return true; + } else if (ParseToken(lltok::exclaim, "Expected '!' here") || + ParseMDNodeID(N)) { + return true; + } NMD->addOperand(N); } while (EatIfPresent(lltok::comma)); Index: llvm/lib/CodeGen/MIRParser/MILexer.h =================================================================== --- llvm/lib/CodeGen/MIRParser/MILexer.h +++ llvm/lib/CodeGen/MIRParser/MILexer.h @@ -100,6 +100,7 @@ md_alias_scope, md_noalias, md_range, + md_diexpr, // Identifier tokens Identifier, Index: llvm/lib/CodeGen/MIRParser/MILexer.cpp =================================================================== --- llvm/lib/CodeGen/MIRParser/MILexer.cpp +++ llvm/lib/CodeGen/MIRParser/MILexer.cpp @@ -490,6 +490,7 @@ .Case("!alias.scope", MIToken::md_alias_scope) .Case("!noalias", MIToken::md_noalias) .Case("!range", MIToken::md_range) + .Case("!DIExpression", MIToken::md_diexpr) .Default(MIToken::Error); } Index: llvm/lib/CodeGen/MIRParser/MIParser.cpp =================================================================== --- llvm/lib/CodeGen/MIRParser/MIParser.cpp +++ llvm/lib/CodeGen/MIRParser/MIParser.cpp @@ -39,6 +39,7 @@ #include "llvm/IR/BasicBlock.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" +#include "llvm/IR/DebugInfoMetadata.h" #include "llvm/IR/DebugLoc.h" #include "llvm/IR/Function.h" #include "llvm/IR/InstrTypes.h" @@ -209,6 +210,7 @@ bool parseJumpTableIndexOperand(MachineOperand &Dest); bool parseExternalSymbolOperand(MachineOperand &Dest); bool parseMDNode(MDNode *&Node); + bool parseDIExpression(MDNode *&Node); bool parseMetadataOperand(MachineOperand &Dest); bool parseCFIOffset(int &Offset); bool parseCFIRegister(unsigned &Reg); @@ -854,10 +856,14 @@ bool MIParser::parseStandaloneMDNode(MDNode *&Node) { lex(); - if (Token.isNot(MIToken::exclaim)) + if (Token.is(MIToken::exclaim)) { + if (parseMDNode(Node)) + return true; + } else if (Token.is(MIToken::md_diexpr)) { + if (parseDIExpression(Node)) + return true; + } else return error("expected a metadata node"); - if (parseMDNode(Node)) - return true; if (Token.isNot(MIToken::Eof)) return error("expected end of string after the metadata node"); return false; @@ -1492,6 +1498,7 @@ bool MIParser::parseMDNode(MDNode *&Node) { assert(Token.is(MIToken::exclaim)); + auto Loc = Token.location(); lex(); if (Token.isNot(MIToken::IntegerLiteral) || Token.integerValue().isSigned()) @@ -1507,10 +1514,56 @@ return false; } +bool MIParser::parseDIExpression(MDNode *&Expr) { + assert(Token.is(MIToken::md_diexpr)); + lex(); + + // FIXME: Share this parsing with the IL parser. + SmallVector Elements; + + if (expectAndConsume(MIToken::lparen)) + return true; + + if (Token.isNot(MIToken::rparen)) { + do { + if (Token.is(MIToken::Identifier)) { + if (unsigned Op = dwarf::getOperationEncoding(Token.stringValue())) { + lex(); + Elements.push_back(Op); + continue; + } + return error(Twine("invalid DWARF op '") + Token.stringValue() + "'"); + } + + if (Token.isNot(MIToken::IntegerLiteral) || + Token.integerValue().isSigned()) + return error("expected unsigned integer"); + + auto &U = Token.integerValue(); + if (U.ugt(UINT64_MAX)) + return error("element too large, limit is " + Twine(UINT64_MAX)); + Elements.push_back(U.getZExtValue()); + lex(); + + } while (consumeIfPresent(MIToken::comma)); + } + + if (expectAndConsume(MIToken::rparen)) + return true; + + Expr = DIExpression::get(MF.getFunction()->getContext(), Elements); + return false; +} + bool MIParser::parseMetadataOperand(MachineOperand &Dest) { MDNode *Node = nullptr; - if (parseMDNode(Node)) - return true; + if (Token.is(MIToken::exclaim)) { + if (parseMDNode(Node)) + return true; + } else if (Token.is(MIToken::md_diexpr)) { + if (parseDIExpression(Node)) + return true; + } Dest = MachineOperand::CreateMetadata(Node); return false; } @@ -1851,6 +1904,7 @@ return parseExternalSymbolOperand(Dest); case MIToken::SubRegisterIndex: return parseSubRegisterIndexOperand(Dest); + case MIToken::md_diexpr: case MIToken::exclaim: return parseMetadataOperand(Dest); case MIToken::kw_cfi_same_value: Index: llvm/lib/IR/AsmWriter.cpp =================================================================== --- llvm/lib/IR/AsmWriter.cpp +++ llvm/lib/IR/AsmWriter.cpp @@ -1046,6 +1046,10 @@ void SlotTracker::CreateMetadataSlot(const MDNode *N) { assert(N && "Can't insert a null Value into SlotTracker!"); + // Don't make slots for DIExpressions. We just print them inline everywhere. + if (isa(N)) + return; + unsigned DestSlot = mdnNext; if (!mdnMap.insert(std::make_pair(N, DestSlot)).second) return; @@ -2073,6 +2077,13 @@ TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context, bool FromValue) { + // Write DIExpressions inline when used as a value. Improves readability of + // debug info intrinsics. + if (const DIExpression *Expr = dyn_cast(MD)) { + writeDIExpression(Out, Expr, TypePrinter, Machine, Context); + return; + } + if (const MDNode *N = dyn_cast(MD)) { std::unique_ptr MachineStorage; if (!Machine) { @@ -2424,7 +2435,16 @@ for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) { if (i) Out << ", "; - int Slot = Machine.getMetadataSlot(NMD->getOperand(i)); + + // Write DIExpressions inline. + // FIXME: Ban DIExpressions in NamedMDNodes, they will serve no purpose. + MDNode *Op = NMD->getOperand(i); + if (auto *Expr = dyn_cast(Op)) { + writeDIExpression(Out, Expr, nullptr, nullptr, nullptr); + continue; + } + + int Slot = Machine.getMetadataSlot(Op); if (Slot == -1) Out << ""; else Index: llvm/test/Assembler/DIGlobalVariableExpression.ll =================================================================== --- llvm/test/Assembler/DIGlobalVariableExpression.ll +++ llvm/test/Assembler/DIGlobalVariableExpression.ll @@ -3,7 +3,7 @@ @foo = global i32 0 -; CHECK: !named = !{!0, !1, !2, !3, !4, !5, !6, !7} +; CHECK: !named = !{!0, !1, !2, !3, !4, !5, !6, !DIExpression(DW_OP_constu, 42, DW_OP_stack_value)} !named = !{!0, !1, !2, !3, !4, !5, !6, !7} !0 = !DIFile(filename: "scope.h", directory: "/path/to/dir") @@ -17,7 +17,6 @@ file: !2, line: 7, type: !3, isLocal: true, isDefinition: false, align: 32) -; CHECK: !6 = !DIGlobalVariableExpression(var: !5, expr: !7) +; CHECK: !6 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression(DW_OP_constu, 42, DW_OP_stack_value)) !6 = !DIGlobalVariableExpression(var: !5, expr: !7) -; CHECK: !7 = !DIExpression(DW_OP_constu, 42, DW_OP_stack_value) !7 = !DIExpression(DW_OP_constu, 42, DW_OP_stack_value) Index: llvm/test/Assembler/diexpression.ll =================================================================== --- llvm/test/Assembler/diexpression.ll +++ llvm/test/Assembler/diexpression.ll @@ -1,16 +1,17 @@ ; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis | FileCheck %s ; RUN: verify-uselistorder %s -; CHECK: !named = !{!0, !1, !2, !3, !4, !5, !6} +; CHECK: !named = !{ +; CHECK-SAME: !DIExpression(), +; CHECK-SAME: !DIExpression(DW_OP_deref), +; CHECK-SAME: !DIExpression(DW_OP_constu, 3, DW_OP_plus), +; CHECK-SAME: !DIExpression(DW_OP_LLVM_fragment, 3, 7), +; CHECK-SAME: !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 3, DW_OP_LLVM_fragment, 3, 7), +; CHECK-SAME: !DIExpression(DW_OP_constu, 2, DW_OP_swap, DW_OP_xderef), +; CHECK-SAME: !DIExpression(DW_OP_plus_uconst, 3)} + !named = !{!0, !1, !2, !3, !4, !5, !6} -; CHECK: !0 = !DIExpression() -; CHECK-NEXT: !1 = !DIExpression(DW_OP_deref) -; CHECK-NEXT: !2 = !DIExpression(DW_OP_constu, 3, DW_OP_plus) -; CHECK-NEXT: !3 = !DIExpression(DW_OP_LLVM_fragment, 3, 7) -; CHECK-NEXT: !4 = !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 3, DW_OP_LLVM_fragment, 3, 7) -; CHECK-NEXT: !5 = !DIExpression(DW_OP_constu, 2, DW_OP_swap, DW_OP_xderef) -; CHECK-NEXT: !6 = !DIExpression(DW_OP_plus_uconst, 3) !0 = !DIExpression() !1 = !DIExpression(DW_OP_deref) !2 = !DIExpression(DW_OP_constu, 3, DW_OP_plus) Index: llvm/test/Assembler/invalid-diexpression-verify.ll =================================================================== --- llvm/test/Assembler/invalid-diexpression-verify.ll +++ llvm/test/Assembler/invalid-diexpression-verify.ll @@ -1,9 +1,8 @@ ; RUN: not llvm-as -disable-output < %s 2>&1 | FileCheck -check-prefix VERIFY %s ; RUN: llvm-as -disable-verify < %s | llvm-dis | FileCheck -check-prefix NOVERIFY %s -; NOVERIFY: !named = !{!0} +; NOVERIFY: !named = !{!DIExpression(0, 1, 9, 7, 2)} !named = !{!0} -; NOVERIFY: !0 = !DIExpression(0, 1, 9, 7, 2) ; VERIFY: assembly parsed, but does not verify !0 = !DIExpression(0, 1, 9, 7, 2) Index: llvm/test/Bitcode/DIExpression-aggresult.ll =================================================================== --- llvm/test/Bitcode/DIExpression-aggresult.ll +++ llvm/test/Bitcode/DIExpression-aggresult.ll @@ -2,8 +2,7 @@ %class.A = type { i32, i32, i32, i32 } define void @_Z3fooi(%class.A* sret %agg.result) #0 !dbg !3 { - ; CHECK: call void @llvm.dbg.declare({{.*}}, metadata ![[EXPR:[0-9]+]]), !dbg - ; CHECK: ![[EXPR]] = !DIExpression() + ; CHECK: call void @llvm.dbg.declare({{.*}}, metadata !DIExpression()), !dbg call void @llvm.dbg.declare(metadata %class.A* %agg.result, metadata !13, metadata !16), !dbg !17 ret void, !dbg !17 } Index: llvm/test/Bitcode/DIGlobalVariableExpression.ll =================================================================== --- llvm/test/Bitcode/DIGlobalVariableExpression.ll +++ llvm/test/Bitcode/DIGlobalVariableExpression.ll @@ -5,16 +5,14 @@ ; BC: GLOBAL_DECL_ATTACHMENT ; CHECK: @g = common global i32 0, align 4, !dbg ![[G:[0-9]+]] ; CHECK: @h = common global i32 0, align 4, !dbg ![[H:[0-9]+]] -; CHECK: ![[G]] = {{.*}}!DIGlobalVariableExpression(var: ![[GVAR:[0-9]+]], expr: ![[GEXPR:[0-9]+]]) +; CHECK: ![[G]] = {{.*}}!DIGlobalVariableExpression(var: ![[GVAR:[0-9]+]], expr: !DIExpression(DW_OP_plus_uconst, 1)) ; CHECK: ![[GVAR]] = distinct !DIGlobalVariable(name: "g", ; CHECK: DICompileUnit({{.*}}, imports: ![[IMPORTS:[0-9]+]] -; CHECK: !DIGlobalVariableExpression(var: ![[CVAR:[0-9]+]], expr: ![[CEXPR:[0-9]+]]) +; CHECK: !DIGlobalVariableExpression(var: ![[CVAR:[0-9]+]], expr: !DIExpression(DW_OP_constu, 23, DW_OP_stack_value)) ; CHECK: ![[CVAR]] = distinct !DIGlobalVariable(name: "c", -; CHECK: ![[CEXPR]] = !DIExpression(DW_OP_constu, 23, DW_OP_stack_value) ; CHECK: ![[HVAR:[0-9]+]] = distinct !DIGlobalVariable(name: "h", ; CHECK: ![[IMPORTS]] = !{![[CIMPORT:[0-9]+]]} ; CHECK: ![[CIMPORT]] = !DIImportedEntity({{.*}}entity: ![[HVAR]] -; CHECK: ![[GEXPR]] = !DIExpression(DW_OP_plus_uconst, 1) ; CHECK: ![[H]] = {{.*}}!DIGlobalVariableExpression(var: ![[HVAR]]) @g = common global i32 0, align 4, !dbg !0 Index: llvm/test/Bitcode/diglobalvariable-3.8.ll =================================================================== --- llvm/test/Bitcode/diglobalvariable-3.8.ll +++ llvm/test/Bitcode/diglobalvariable-3.8.ll @@ -9,9 +9,8 @@ !2 = !{} ; CHECK: !3 = !{!4} !3 = !{!4} -; CHECK: !4 = {{.*}}!DIGlobalVariableExpression(var: !5, expr: !8) +; CHECK: !4 = {{.*}}!DIGlobalVariableExpression(var: !5, expr: !DIExpression(DW_OP_constu, 42, DW_OP_stack_value)) ; CHECK: !5 = !DIGlobalVariable(name: "c", scope: !0, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true) -; CHECK: !8 = !DIExpression(DW_OP_constu, 42, DW_OP_stack_value) !4 = !DIGlobalVariable(name: "c", scope: !0, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, variable: i32 42) !5 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !6) !6 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 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 !9), !dbg !10 + ; CHECK: call void @llvm.dbg.value(metadata i32 42, metadata !8, metadata !DIExpression()) 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/CodeGen/AArch64/GlobalISel/debug-insts.ll =================================================================== --- llvm/test/CodeGen/AArch64/GlobalISel/debug-insts.ll +++ llvm/test/CodeGen/AArch64/GlobalISel/debug-insts.ll @@ -4,41 +4,41 @@ ; CHECK-LABEL: name: debug_declare ; CHECK: stack: ; CHECK: - { id: {{.*}}, name: in.addr, type: default, offset: 0, size: {{.*}}, alignment: {{.*}}, -; CHECK-NEXT: callee-saved-register: '', di-variable: '!11', di-expression: '!12', -; CHECK: DBG_VALUE debug-use %0(s32), debug-use _, !11, !12, debug-location !13 +; CHECK-NEXT: callee-saved-register: '', di-variable: '!11', di-expression: '!DIExpression()', +; CHECK: DBG_VALUE debug-use %0(s32), debug-use _, !11, !DIExpression(), debug-location !12 define void @debug_declare(i32 %in) #0 !dbg !7 { entry: %in.addr = alloca i32, align 4 store i32 %in, i32* %in.addr, align 4 - call void @llvm.dbg.declare(metadata i32* %in.addr, metadata !11, metadata !12), !dbg !13 - call void @llvm.dbg.declare(metadata i32 %in, metadata !11, metadata !12), !dbg !13 - ret void, !dbg !13 + call void @llvm.dbg.declare(metadata i32* %in.addr, metadata !11, metadata !DIExpression()), !dbg !12 + call void @llvm.dbg.declare(metadata i32 %in, metadata !11, metadata !DIExpression()), !dbg !12 + ret void, !dbg !12 } ; CHECK-LABEL: name: debug_declare_vla -; CHECK: DBG_VALUE debug-use %{{[0-9]+}}(p0), debug-use _, !15, !12, debug-location !16 -define void @debug_declare_vla(i32 %in) #0 !dbg !14 { +; CHECK: DBG_VALUE debug-use %{{[0-9]+}}(p0), debug-use _, !14, !DIExpression(), debug-location !15 +define void @debug_declare_vla(i32 %in) #0 !dbg !13 { entry: %vla.addr = alloca i32, i32 %in - call void @llvm.dbg.declare(metadata i32* %vla.addr, metadata !15, metadata !12), !dbg !16 - ret void, !dbg !16 + call void @llvm.dbg.declare(metadata i32* %vla.addr, metadata !14, metadata !DIExpression()), !dbg !15 + ret void, !dbg !15 } ; CHECK-LABEL: name: debug_value ; CHECK: [[IN:%[0-9]+]](s32) = COPY %w0 -define void @debug_value(i32 %in) #0 !dbg !17 { +define void @debug_value(i32 %in) #0 !dbg !16 { %addr = alloca i32 -; CHECK: DBG_VALUE debug-use [[IN]](s32), debug-use _, !18, !12, debug-location !19 - call void @llvm.dbg.value(metadata i32 %in, i64 0, metadata !18, metadata !12), !dbg !19 +; CHECK: DBG_VALUE debug-use [[IN]](s32), debug-use _, !17, !DIExpression(), debug-location !18 + call void @llvm.dbg.value(metadata i32 %in, i64 0, metadata !17, metadata !DIExpression()), !dbg !18 store i32 %in, i32* %addr -; CHECK: DBG_VALUE debug-use %1(p0), debug-use _, !18, !20, debug-location !19 - call void @llvm.dbg.value(metadata i32* %addr, i64 0, metadata !18, metadata !20), !dbg !19 -; CHECK: DBG_VALUE 123, 0, !18, !12, debug-location !19 - call void @llvm.dbg.value(metadata i32 123, i64 0, metadata !18, metadata !12), !dbg !19 -; CHECK: DBG_VALUE float 1.000000e+00, 0, !18, !12, debug-location !19 - call void @llvm.dbg.value(metadata float 1.000000e+00, i64 0, metadata !18, metadata !12), !dbg !19 -; CHECK: DBG_VALUE _, 0, !18, !12, debug-location !19 - call void @llvm.dbg.value(metadata i32* null, i64 0, metadata !18, metadata !12), !dbg !19 +; CHECK: DBG_VALUE debug-use %1(p0), debug-use _, !17, !DIExpression(DW_OP_deref), debug-location !18 + call void @llvm.dbg.value(metadata i32* %addr, i64 0, metadata !17, metadata !DIExpression(DW_OP_deref)), !dbg !18 +; CHECK: DBG_VALUE 123, 0, !17, !DIExpression(), debug-location !18 + call void @llvm.dbg.value(metadata i32 123, i64 0, metadata !17, metadata !DIExpression()), !dbg !18 +; CHECK: DBG_VALUE float 1.000000e+00, 0, !17, !DIExpression(), debug-location !18 + call void @llvm.dbg.value(metadata float 1.000000e+00, i64 0, metadata !17, metadata !DIExpression()), !dbg !18 +; CHECK: DBG_VALUE _, 0, !17, !DIExpression(), debug-location !18 + call void @llvm.dbg.value(metadata i32* null, i64 0, metadata !17, metadata !DIExpression()), !dbg !18 ret void } @@ -62,12 +62,10 @@ !9 = !{null, !10} !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) !11 = !DILocalVariable(name: "in", arg: 1, scope: !7, file: !1, line: 1, type: !10) -!12 = !DIExpression() -!13 = !DILocation(line: 1, column: 14, scope: !7) -!14 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) -!15 = !DILocalVariable(name: "in", arg: 1, scope: !14, file: !1, line: 1, type: !10) -!16 = !DILocation(line: 1, column: 14, scope: !14) -!17 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) -!18 = !DILocalVariable(name: "in", arg: 1, scope: !17, file: !1, line: 1, type: !10) -!19 = !DILocation(line: 1, column: 14, scope: !17) -!20 = !DIExpression(DW_OP_deref) +!12 = !DILocation(line: 1, column: 14, scope: !7) +!13 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) +!14 = !DILocalVariable(name: "in", arg: 1, scope: !13, file: !1, line: 1, type: !10) +!15 = !DILocation(line: 1, column: 14, scope: !13) +!16 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) +!17 = !DILocalVariable(name: "in", arg: 1, scope: !16, file: !1, line: 1, type: !10) +!18 = !DILocation(line: 1, column: 14, scope: !16) Index: llvm/test/CodeGen/AArch64/GlobalISel/regbankselect-dbg-value.mir =================================================================== --- llvm/test/CodeGen/AArch64/GlobalISel/regbankselect-dbg-value.mir +++ llvm/test/CodeGen/AArch64/GlobalISel/regbankselect-dbg-value.mir @@ -5,7 +5,7 @@ define void @test_dbg_value() !dbg !5 { ; Keep the dbg metadata live by referencing it in the IR. - call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !7, metadata !9), !dbg !10 + call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !7, metadata !DIExpression()), !dbg !9 ret void } @@ -23,8 +23,7 @@ !6 = !DISubroutineType(types: !2) !7 = !DILocalVariable(name: "in", arg: 1, scope: !5, file: !1, line: 1, type: !8) !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) - !9 = !DIExpression() - !10 = !DILocation(line: 1, column: 1, scope: !5) + !9 = !DILocation(line: 1, column: 1, scope: !5) ... --- @@ -37,9 +36,9 @@ bb.0: liveins: %w0 %0:_(s32) = COPY %w0 - ; CHECK: DBG_VALUE debug-use %0(s32), debug-use _, !7, !9, debug-location !10 - DBG_VALUE debug-use %0(s32), debug-use _, !7, !9, debug-location !10 + ; CHECK: DBG_VALUE debug-use %0(s32), debug-use _, !7, !DIExpression(), debug-location !9 + DBG_VALUE debug-use %0(s32), debug-use _, !7, !DIExpression(), debug-location !9 - ; CHECK: DBG_VALUE _, 0, !7, !9, debug-location !10 - DBG_VALUE _, 0, !7, !9, debug-location !10 + ; CHECK: DBG_VALUE _, 0, !7, !DIExpression(), debug-location !9 + DBG_VALUE _, 0, !7, !DIExpression(), debug-location !9 ... Index: llvm/test/CodeGen/AArch64/GlobalISel/select-dbg-value.mir =================================================================== --- llvm/test/CodeGen/AArch64/GlobalISel/select-dbg-value.mir +++ llvm/test/CodeGen/AArch64/GlobalISel/select-dbg-value.mir @@ -5,12 +5,12 @@ define void @test_dbg_value(i32 %a) !dbg !5 { %tmp0 = add i32 %a, %a - call void @llvm.dbg.value(metadata i32 %tmp0, i64 0, metadata !7, metadata !9), !dbg !10 + call void @llvm.dbg.value(metadata i32 %tmp0, i64 0, metadata !7, metadata !DIExpression()), !dbg !9 ret void } - define void @test_dbg_value_dead(i32 %a) !dbg !11 { - call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !12, metadata !9), !dbg !13 + define void @test_dbg_value_dead(i32 %a) !dbg !10 { + call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !11, metadata !DIExpression()), !dbg !12 ret void } @@ -28,11 +28,10 @@ !6 = !DISubroutineType(types: !2) !7 = !DILocalVariable(name: "in", arg: 1, scope: !5, file: !1, line: 1, type: !8) !8 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) - !9 = !DIExpression() - !10 = !DILocation(line: 1, column: 1, scope: !5) - !11 = distinct !DISubprogram(name: "test_dbg_value", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) - !12 = !DILocalVariable(name: "in", arg: 1, scope: !11, file: !1, line: 1, type: !8) - !13 = !DILocation(line: 1, column: 1, scope: !11) + !9 = !DILocation(line: 1, column: 1, scope: !5) + !10 = distinct !DISubprogram(name: "test_dbg_value", scope: !1, file: !1, line: 1, type: !6, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2) + !11 = !DILocalVariable(name: "in", arg: 1, scope: !10, file: !1, line: 1, type: !8) + !12 = !DILocation(line: 1, column: 1, scope: !10) ... --- @@ -50,9 +49,9 @@ ; CHECK: %0 = COPY %w0 ; CHECK-NEXT: %1 = ADDWrr %0, %0 ; CHECK-NEXT: %w0 = COPY %1 - ; CHECK-NEXT: DBG_VALUE debug-use %1, debug-use _, !7, !9, debug-location !10 + ; CHECK-NEXT: DBG_VALUE debug-use %1, debug-use _, !7, !DIExpression(), debug-location !9 - DBG_VALUE debug-use %1(s32), debug-use _, !7, !9, debug-location !10 + DBG_VALUE debug-use %1(s32), debug-use _, !7, !DIExpression(), debug-location !9 ... --- @@ -66,7 +65,7 @@ %0:gpr(s32) = COPY %w0 ; CHECK-NOT: COPY - ; CHECK: DBG_VALUE debug-use _, debug-use _, !7, !9, debug-location !10 + ; CHECK: DBG_VALUE debug-use _, debug-use _, !7, !DIExpression(), debug-location !9 - DBG_VALUE debug-use %0(s32), debug-use _, !7, !9, debug-location !10 + DBG_VALUE debug-use %0(s32), debug-use _, !7, !DIExpression(), debug-location !9 ... Index: llvm/test/CodeGen/MIR/X86/instructions-debug-location.mir =================================================================== --- llvm/test/CodeGen/MIR/X86/instructions-debug-location.mir +++ llvm/test/CodeGen/MIR/X86/instructions-debug-location.mir @@ -8,18 +8,18 @@ entry: %x.addr = alloca i32, align 4 store i32 %x, i32* %x.addr, align 4 - call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !13), !dbg !14 - %0 = load i32, i32* %x.addr, align 4, !dbg !15 - ret i32 %0, !dbg !15 + call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !DIExpression()), !dbg !13 + %0 = load i32, i32* %x.addr, align 4, !dbg !14 + ret i32 %0, !dbg !14 } define i32 @test_typed_immediates(i32 %x) #0 { entry: %x.addr = alloca i32, align 4 store i32 %x, i32* %x.addr, align 4 - call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !13), !dbg !14 - %0 = load i32, i32* %x.addr, align 4, !dbg !15 - ret i32 %0, !dbg !15 + call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !DIExpression()), !dbg !13 + %0 = load i32, i32* %x.addr, align 4, !dbg !14 + ret i32 %0, !dbg !14 } declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 @@ -43,9 +43,8 @@ !10 = !{i32 2, !"Debug Info Version", i32 3} !11 = !{!"clang version 3.7.0"} !12 = !DILocalVariable(name: "x", arg: 1, scope: !4, file: !5, line: 4, type: !8) - !13 = !DIExpression() - !14 = !DILocation(line: 4, scope: !4) - !15 = !DILocation(line: 8, scope: !4) + !13 = !DILocation(line: 4, scope: !4) + !14 = !DILocation(line: 8, scope: !4) ... --- @@ -60,14 +59,14 @@ body: | bb.0.entry: liveins: %edi - ; CHECK: DBG_VALUE debug-use _, 0, !11, !12, debug-location !13 - ; CHECK: %eax = COPY %0, debug-location !14 - ; CHECK: RETQ %eax, debug-location !14 + ; CHECK: DBG_VALUE debug-use _, 0, !11, !DIExpression(), debug-location !12 + ; CHECK: %eax = COPY %0, debug-location !13 + ; CHECK: RETQ %eax, debug-location !13 %0 = COPY %edi - DBG_VALUE debug-use _, 0, !12, !13, debug-location !14 + DBG_VALUE debug-use _, 0, !12, !DIExpression(), debug-location !13 MOV32mr %stack.0.x.addr, 1, _, 0, _, %0 - %eax = COPY %0, debug-location !15 - RETQ %eax, debug-location !15 + %eax = COPY %0, debug-location !14 + RETQ %eax, debug-location !14 ... --- name: test_typed_immediates @@ -83,12 +82,12 @@ liveins: %edi %0 = COPY %edi - ; CHECK: DBG_VALUE _, i32 0, !11, !12 - ; CHECK-NEXT: DBG_VALUE _, i64 -22, !11, !12 - ; CHECK-NEXT: DBG_VALUE _, i128 123492148938512984928424384934328985928, !11, !12 - DBG_VALUE _, i32 0, !12, !13 - DBG_VALUE _, i64 -22, !12, !13 - DBG_VALUE _, i128 123492148938512984928424384934328985928, !12, !13 + ; CHECK: DBG_VALUE _, i32 0, !DIExpression(), !12 + ; CHECK-NEXT: DBG_VALUE _, i64 -22, !DIExpression(), !12 + ; CHECK-NEXT: DBG_VALUE _, i128 123492148938512984928424384934328985928, !DIExpression(), !12 + DBG_VALUE _, i32 0, !DIExpression(), !13 + DBG_VALUE _, i64 -22, !DIExpression(), !13 + DBG_VALUE _, i128 123492148938512984928424384934328985928, !DIExpression(), !13 MOV32mr %stack.0.x.addr, 1, _, 0, _, %0 %eax = COPY %0 RETQ %eax Index: llvm/test/CodeGen/MIR/X86/metadata-operands.mir =================================================================== --- llvm/test/CodeGen/MIR/X86/metadata-operands.mir +++ llvm/test/CodeGen/MIR/X86/metadata-operands.mir @@ -8,9 +8,9 @@ entry: %x.addr = alloca i32, align 4 store i32 %x, i32* %x.addr, align 4 - call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !13), !dbg !14 - %0 = load i32, i32* %x.addr, align 4, !dbg !15 - ret i32 %0, !dbg !15 + call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !DIExpression()), !dbg !13 + %0 = load i32, i32* %x.addr, align 4, !dbg !14 + ret i32 %0, !dbg !14 } declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 @@ -34,9 +34,8 @@ !10 = !{i32 2, !"Debug Info Version", i32 3} !11 = !{!"clang version 3.7.0"} !12 = !DILocalVariable(name: "x", arg: 1, scope: !4, file: !5, line: 4, type: !8) - !13 = !DIExpression() - !14 = !DILocation(line: 4, scope: !4) - !15 = !DILocation(line: 8, scope: !4) + !13 = !DILocation(line: 4, scope: !4) + !14 = !DILocation(line: 8, scope: !4) ... --- @@ -52,9 +51,9 @@ bb.0.entry: liveins: %edi ; CHECK: %0 = COPY %edi - ; CHECK-NEXT: DBG_VALUE _, 0, !11, !12 + ; CHECK-NEXT: DBG_VALUE _, 0, !11, !DIExpression() %0 = COPY %edi - DBG_VALUE _, 0, !12, ! 13 + DBG_VALUE _, 0, !12, !DIExpression() MOV32mr %stack.0.x.addr, 1, _, 0, _, %0 %eax = COPY %0 RETQ %eax Index: llvm/test/CodeGen/MIR/X86/stack-object-debug-info.mir =================================================================== --- llvm/test/CodeGen/MIR/X86/stack-object-debug-info.mir +++ llvm/test/CodeGen/MIR/X86/stack-object-debug-info.mir @@ -15,7 +15,7 @@ %1 = bitcast [256 x i8]* %y.i to i8* call void @llvm.lifetime.end(i64 -1, i8* %1) #3 call void @llvm.lifetime.start(i64 -1, i8* %0) #3 - call void @llvm.dbg.declare(metadata i8* %0, metadata !4, metadata !7) #3, !dbg !8 + call void @llvm.dbg.declare(metadata i8* %0, metadata !4, metadata !DIExpression()) #3, !dbg !7 br label %for.body } @@ -35,14 +35,13 @@ !1 = !DIFile(filename: "t.c", directory: "") !2 = !{} !3 = !{i32 1, !"Debug Info Version", i32 3} - !4 = !DILocalVariable(name: "x", scope: !5, file: !1, line: 16, type: !9) + !4 = !DILocalVariable(name: "x", scope: !5, file: !1, line: 16, type: !8) !5 = distinct !DISubprogram(scope: null, isLocal: false, isDefinition: true, isOptimized: false, unit: !0) !6 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) - !7 = !DIExpression() - !8 = !DILocation(line: 0, scope: !5) - !9 = !DICompositeType(tag: DW_TAG_array_type, baseType: !6, size: 2048, align: 8, elements: !10) - !10 = !{!11} - !11 = !DISubrange(count: 256) + !7 = !DILocation(line: 0, scope: !5) + !8 = !DICompositeType(tag: DW_TAG_array_type, baseType: !6, size: 2048, align: 8, elements: !9) + !9 = !{!10} + !10 = !DISubrange(count: 256) ... --- name: foo @@ -52,17 +51,17 @@ # CHECK-LABEL: foo # CHECK: stack: # CHECK: - { id: 0, name: y.i, type: default, offset: 0, size: 256, alignment: 16, -# CHECK-NEXT: callee-saved-register: '', di-variable: '!4', di-expression: '!10', -# CHECK-NEXT: di-location: '!11' } +# CHECK-NEXT: callee-saved-register: '', di-variable: '!4', di-expression: '!DIExpression()', +# CHECK-NEXT: di-location: '!10' } stack: - { id: 0, name: y.i, offset: 0, size: 256, alignment: 16, di-variable: '!4', - di-expression: '!7', di-location: '!8' } + di-expression: '!DIExpression()', di-location: '!7' } body: | bb.0.entry: successors: %bb.1.for.body bb.1.for.body: successors: %bb.1.for.body - DBG_VALUE %stack.0.y.i, 0, !4, !7, debug-location !8 + DBG_VALUE %stack.0.y.i, 0, !4, !DIExpression(), debug-location !7 JMP_1 %bb.1.for.body ... Index: llvm/test/CodeGen/X86/lea-opt-with-debug.mir =================================================================== --- llvm/test/CodeGen/X86/lea-opt-with-debug.mir +++ llvm/test/CodeGen/X86/lea-opt-with-debug.mir @@ -14,22 +14,22 @@ @d = common local_unnamed_addr global i32 0, align 4 @b = common local_unnamed_addr global i32 0, align 4 - define i32 @fn1() local_unnamed_addr !dbg !9 { - %1 = load %struct.A*, %struct.A** @c, align 8, !dbg !14 - %2 = load i32, i32* @a, align 4, !dbg !14 - %3 = sext i32 %2 to i64, !dbg !14 - %4 = getelementptr inbounds %struct.A, %struct.A* %1, i64 %3, !dbg !14 - %5 = ptrtoint %struct.A* %4 to i64, !dbg !14 - %6 = trunc i64 %5 to i32, !dbg !14 - store i32 %6, i32* @d, align 4, !dbg !14 - %7 = getelementptr inbounds %struct.A, %struct.A* %1, i64 %3, i32 2, !dbg !15 - tail call void @llvm.dbg.value(metadata i32* %7, i64 0, metadata !12, metadata !16), !dbg !17 - br label %8, !dbg !18 + define i32 @fn1() local_unnamed_addr !dbg !8 { + %1 = load %struct.A*, %struct.A** @c, align 8, !dbg !13 + %2 = load i32, i32* @a, align 4, !dbg !13 + %3 = sext i32 %2 to i64, !dbg !13 + %4 = getelementptr inbounds %struct.A, %struct.A* %1, i64 %3, !dbg !13 + %5 = ptrtoint %struct.A* %4 to i64, !dbg !13 + %6 = trunc i64 %5 to i32, !dbg !13 + store i32 %6, i32* @d, align 4, !dbg !13 + %7 = getelementptr inbounds %struct.A, %struct.A* %1, i64 %3, i32 2, !dbg !14 + tail call void @llvm.dbg.value(metadata i32* %7, i64 0, metadata !11, metadata !DIExpression()), !dbg !15 + br label %8, !dbg !16 ;