Author: Yonghong Song Date: 2021-08-26T14:27:58-07:00 New Revision: 82d9cb34a2782df04975abb5a86365546ffae867
URL: https://github.com/llvm/llvm-project/commit/82d9cb34a2782df04975abb5a86365546ffae867 DIFF: https://github.com/llvm/llvm-project/commit/82d9cb34a2782df04975abb5a86365546ffae867.diff LOG: [DebugInfo] convert btf_tag attrs to DI annotations for func parameters Generate btf_tag annotations for DILocalVariable. The annotations are represented as an DINodeArray in DebugInfo. Differential Revision: https://reviews.llvm.org/D106620 Added: clang/test/CodeGen/attr-btf_tag-parameter.c Modified: clang/lib/CodeGen/CGDebugInfo.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 2de933f658009..5993ce8531f8f 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -4367,8 +4367,10 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD, // Create the descriptor for the variable. llvm::DILocalVariable *D = nullptr; if (ArgNo) { + llvm::DINodeArray Annotations = CollectBTFTagAnnotations(VD); D = DBuilder.createParameterVariable(Scope, Name, *ArgNo, Unit, Line, Ty, - CGM.getLangOpts().Optimize, Flags); + CGM.getLangOpts().Optimize, Flags, + Annotations); } else { // For normal local variable, we will try to find out whether 'VD' is the // copy parameter of coroutine. diff --git a/clang/test/CodeGen/attr-btf_tag-parameter.c b/clang/test/CodeGen/attr-btf_tag-parameter.c new file mode 100644 index 0000000000000..77ca246f68270 --- /dev/null +++ b/clang/test/CodeGen/attr-btf_tag-parameter.c @@ -0,0 +1,18 @@ +// REQUIRES: x86-registered-target +// RUN: %clang -target x86_64 -g -S -emit-llvm -o - %s | FileCheck %s + +#define __tag1 __attribute__((btf_tag("tag1"))) +#define __tag2 __attribute__((btf_tag("tag2"))) + +struct t1 { + int a; +}; + +int foo(struct t1 __tag1 __tag2 *arg) { + return arg->a; +} + +// CHECK: !DILocalVariable(name: "arg", arg: 1, scope: ![[#]], file: ![[#]], line: [[#]], type: ![[#]], annotations: ![[ANNOT:[0-9]+]]) +// CHECK: ![[ANNOT]] = !{![[TAG1:[0-9]+]], ![[TAG2:[0-9]+]]} +// CHECK: ![[TAG1]] = !{!"btf_tag", !"tag1"} +// CHECK: ![[TAG2]] = !{!"btf_tag", !"tag2"} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits