Artem-B wrote:

This is breaking CUDA/NVPTX. 
Enabling PGO results in compiler generating PGO-related data which references 
itself, and NVPTX can't compile those.

E.g. we see data like this which includes a reference to itself:
```
@__profd__ZN12cuda_helpers13memcmp_kernelEPjS0_mPb = protected global { i64, 
i64, i64, i64, ptr, ptr, i32, [3 x i16], i32 } { i64 322482019142718985, i64 
287486624882456055, i64 sub (i64 ptrtoint (ptr 
@__profc__ZN12cuda_helpers13memcmp_kernelEPjS0_mPb to i64), i64 ptr
toint (ptr @__profd__ZN12cuda_helpers13memcmp_kernelEPjS0_mPb to i64)), i64 0, 
ptr @_ZN12cuda_helpers13memcmp_kernelEPjS0_mPb, ptr null, i32 5, [3 x i16] 
zeroinitializer, i32 0 }, section "__llvm_prf_data", 
comdat($__profc__ZN12cuda_helpers13memcmp_kernelEPjS0_mPb), a
lign 8
```

When LLVM sees such self-reference, it crashes. https://godbolt.org/z/o6PTqr1ca

```
LLVM ERROR: Circular dependency found in global variable set
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-trunk/bin/llc -o 
/app/output.s -x86-asm-syntax=intel -march=nvptx64 -mcpu=sm_20 <source>
 #0 0x0000000003ab1a88 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/opt/compiler-explorer/clang-trunk/bin/llc+0x3ab1a88)
 #1 0x0000000003aaf644 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x00007a9fa6c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007a9fa6c969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007a9fa6c42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007a9fa6c287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x000000000077d6a2 llvm::UniqueStringSaver::save(llvm::Twine const&) 
(.cold) StringSaver.cpp:0:0
 #7 0x0000000003a079d8 (/opt/compiler-explorer/clang-trunk/bin/llc+0x3a079d8)
 #8 0x00000000017dc57e (/opt/compiler-explorer/clang-trunk/bin/llc+0x17dc57e)
 #9 0x00000000017dc3dd VisitGlobalVariableForEmission(llvm::GlobalVariable 
const*, llvm::SmallVectorImpl<llvm::GlobalVariable const*>&, 
llvm::DenseSet<llvm::GlobalVariable const*, 
llvm::DenseMapInfo<llvm::GlobalVariable const*, void>>&, 
llvm::DenseSet<llvm::GlobalVariable const*, 
llvm::DenseMapInfo<llvm::GlobalVariable const*, void>>&) NVPTXAsmPrinter.cpp:0:0
#10 0x00000000017dc6dc llvm::NVPTXAsmPrinter::emitGlobals(llvm::Module const&) 
(/opt/compiler-explorer/clang-trunk/bin/llc+0x17dc6dc)
#11 0x00000000017dcf7d llvm::NVPTXAsmPrinter::doFinalization(llvm::Module&) 
(/opt/compiler-explorer/clang-trunk/bin/llc+0x17dcf7d)
#12 0x00000000030a916d llvm::FPPassManager::doFinalization(llvm::Module&) 
(/opt/compiler-explorer/clang-trunk/bin/llc+0x30a916d)
#13 0x00000000030b48f0 llvm::legacy::PassManagerImpl::run(llvm::Module&) 
(/opt/compiler-explorer/clang-trunk/bin/llc+0x30b48f0)
#14 0x00000000008b4a08 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#15 0x000000000079237e main 
(/opt/compiler-explorer/clang-trunk/bin/llc+0x79237e)
#16 0x00007a9fa6c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#17 0x00007a9fa6c29e40 __libc_start_main 
(/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#18 0x00000000008ac9c5 _start 
(/opt/compiler-explorer/clang-trunk/bin/llc+0x8ac9c5)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```

https://github.com/llvm/llvm-project/pull/94268
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to