[PATCH] D111199: [Clang][LLVM][Attr] support btf_type_tag attribute

Yonghong Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 4 12:14:12 PDT 2021


yonghong-song added inline comments.


================
Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1426
+  TypeLoc RetTL;
+  if (!TL.isNull()) {
+    if (auto FTL = TL.getAs<FunctionTypeLoc>())
----------------
dblaikie wrote:
> I'm /guessing/ this can be rewritten as:
> ```
> if (TL)
> ```
> ? (similarly elsewhere in this patch)
Yes. Indeed. Thanks for the suggestion! Will make changes in the next revision.


================
Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1440-1441
+    bool DoneWithTL = false;
+    if (!TL.isNull()) {
+      if (auto FTL = TL.getAs<FunctionTypeLoc>()) {
+        DoneWithTL = true;
----------------
dblaikie wrote:
> Is this null check necessary, or does "getAs" return null if the underlying value is null already anyway? (oh, and this would apply above as well)
Yes. null check is necessary. Otherwise, we will get an assertion error like
```
clang: /home/yhs/work/llvm-project/clang/include/clang/AST/Type.h:689: const clang::ExtQualsTypeCommonBase* clang::QualType::getCommonPtr() const: Assertion `!isNull() && "Cannot retrieve 
a NULL type pointer"' failed.                                                                                                                                                               
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.                                                       
Stack dump:                                                                                                                                                                                 
0.      Program arguments: clang -g -D__TARGET_ARCH_x86 -mlittle-endian -I/home/yhs/work/bpf-next/tools/testing/selftests/bpf/tools/include -I/home/yhs/work/bpf-next/tools/testing/selftest
s/bpf -I/home/yhs/work/bpf-next/tools/include/uapi -I/home/yhs/work/bpf-next/tools/testing/selftests/usr/include -idirafter /home/yhs/work/llvm-project/llvm/build.cur/install/lib/clang/14.
0.0/include -idirafter /usr/local/include -idirafter /usr/include -Wno-compare-distinct-pointer-types -DENABLE_ATOMICS_TESTS -O2 -target bpf -c progs/btf_dump_test_case_multidim.c -o /home
/yhs/work/bpf-next/tools/testing/selftests/bpf/btf_dump_test_case_multidim.o -mcpu=v3                                                                                                       
1.      <eof> parser at end of file                                                                                                                                                         
2.      progs/btf_dump_test_case_multidim.c:32:5: LLVM IR generation of declaration 'f'                                                                                                     
3.      progs/btf_dump_test_case_multidim.c:32:5: Generating code for declaration 'f'                                                                                                       
 #0 0x0000000001e9e03f PrintStackTraceSignalHandler(void*) Signals.cpp:0:0                                                                                                                  
 #1 0x0000000001e9be7c llvm::sys::CleanupOnSignal(unsigned long) (/home/yhs/work/llvm-project/llvm/build.cur/install/bin/clang-14+0x1e9be7c)                                                
 #2 0x0000000001dea448 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0                                                                                                         
 #3 0x00007f7b08be4c20 __restore_rt sigaction.c:0:0                                                                                                                                         
 #4 0x00007f7b078dc37f raise (/lib64/libc.so.6+0x3737f)                                                                                                                                     
 #5 0x00007f7b078c6db5 abort (/lib64/libc.so.6+0x21db5)                                                                                                                                     
 #6 0x00007f7b078c6c89 _nl_load_domain.cold.0 loadmsgcat.c:0:0                                                                                                                              
 #7 0x00007f7b078d4a76 .annobin___GI___assert_fail.end assert.c:0:0                                                                                                                         
 #8 0x0000000002193ba3 (/home/yhs/work/llvm-project/llvm/build.cur/install/bin/clang-14+0x2193ba3)                                                                                          
 #9 0x00000000021b4981 clang::CodeGen::CGDebugInfo::CreateType(clang::FunctionType const*, llvm::DIFile*, clang::TypeLoc) (/home/yhs/work/llvm-project/llvm/build.cur/install/bin/clang-14+0
x21b4981)                                                                                                                                                                                   
#10 0x00000000021b11d8 clang::CodeGen::CGDebugInfo::CreateTypeNode(clang::QualType, llvm::DIFile*, clang::TypeLoc) (/home/yhs/work/llvm-project/llvm/build.cur/install/bin/clang-14+0x21b11d
8)                                                                                                                                                                                          
#11 0x00000000021b1416 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*, clang::TypeLoc) (/home/yhs/work/llvm-project/llvm/build.cur/install/bin/clang-14+0x21b14
16)                                                                                                                                                                                         
#12 0x00000000021b340d clang::CodeGen::CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag, clang::Type const*, clang::QualType, llvm::DIFile*, clang::TypeLoc) (/home/yhs/work/llvm-project
/llvm/build.cur/install/bin/clang-14+0x21b340d)                                                                                                                                             
#13 0x00000000021b3b01 clang::CodeGen::CGDebugInfo::CreateType(clang::PointerType const*, llvm::DIFile*, clang::TypeLoc) (/home/yhs/work/llvm-project/llvm/build.cur/install/bin/clang-14+0x
21b3b01)
...```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111199/new/

https://reviews.llvm.org/D111199



More information about the llvm-commits mailing list