Reland "[Attr] support btf_type_tag attribute"
authorYonghong Song <yhs@fb.com>
Fri, 5 Nov 2021 18:01:31 +0000 (11:01 -0700)
committerYonghong Song <yhs@fb.com>
Fri, 5 Nov 2021 18:25:17 +0000 (11:25 -0700)
commit3466e00716e12e32fdb100e3fcfca5c2b3e8d784
treeb72f25b44ee1d31e246970c556931c1cd4ee0ef5
parentf64580f8d2ce5e1161857f9c89c2eee7a74c5ab8
Reland "[Attr] support btf_type_tag attribute"

This is to revert commit f95bd18b5faa (Revert "[Attr] support
btf_type_tag attribute") plus a bug fix.

Previous change failed to handle cases like below:
    $ cat reduced.c
    void a(*);
    void a() {}
    $ clang -c reduced.c -O2 -g

In such cases, during clang IR generation, for function a(),
CGCodeGen has numParams = 1 for FunctionType. But for
FunctionTypeLoc we have FuncTypeLoc.NumParams = 0. By using
FunctionType.numParams as the bound to access FuncTypeLoc
params, a random crash is triggered. The bug fix is to
check against FuncTypeLoc.NumParams before accessing
FuncTypeLoc.getParam(Idx).

Differential Revision: https://reviews.llvm.org/D111199
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/test/CodeGen/attr-btf_type_tag-func.c [new file with mode: 0644]
clang/test/CodeGen/attr-btf_type_tag-typedef-field.c [new file with mode: 0644]
clang/test/CodeGen/attr-btf_type_tag-var.c [new file with mode: 0644]
llvm/include/llvm/IR/DIBuilder.h
llvm/lib/IR/DIBuilder.cpp
llvm/test/Bitcode/attr-btf_type_tag.ll [new file with mode: 0644]
llvm/test/DebugInfo/attr-btf_type_tag.ll [new file with mode: 0644]