[llvm] [Exegesis][RISCV] Add RISCV support for llvm-exegesis (PR #89047)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 13 07:42:06 PST 2024
AnastasiyaChernikova wrote:
> > > I saw you removed the perf counters tuff, do you plan to send a separate PR for that? Without libpfm support for riscv, I can't test the PR.
> >
> >
> > The perf counter stuff has been taken out and will be added later (from what I understand).
> > libpfm as far as I'm aware does support the generic perf counters (I forget the names) that you should be able to wire up pretty easily.
> > @mshockwave was planning on upstreaming support for using the raw event encodings rather than using libpfm to get performance counters actually working on RISCV within `llvm-exegesis`. That shouldn't be too complicated to get working either. The code for that is available in #114149.
>
> Yeah, I'm using the code from that patch to test this one, and that's why I asked if they plan to send the rest of the code in a separate PR. I managed to generate the snippets but no measure can performed with the current PR.
>
> I'm also getting a crash when using `--opcode-index=-1`. Can you reproduce this crash @AnastasiyaChernikova?
>
> ```
> LLVM ERROR: Not supported instr: <MCInst 360 <MCOperand Reg:69> <MCOperand Reg:65> <MCOperand Reg:51> <MCOperand Imm:0> <MCOperand Reg:69> <MCOperand Reg:60> <MCOperand Reg:56>>
> PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
> Stack dump:
> 0. Program arguments: ./llvm-riscv/bin/llvm-exegesis --mode=latency --opcode-index=-1 --dump-object-to-disk=./test --benchmark-phase=assemble-measured-code
> 1. Running pass 'Function Pass Manager' on module 'ExegesisInfoTest'.
> 2. Running pass 'RISC-V Assembly Printer' on function '@foo'
> #0 0x0000002ab52a9e70 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/mgadelha/tools/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:13
> #1 0x0000002ab52a875c llvm::sys::RunSignalHandlers() /home/mgadelha/tools/llvm-project/llvm/lib/Support/Signals.cpp:106:18
> #2 0x0000002ab52aa58c SignalHandler(int) /home/mgadelha/tools/llvm-project/llvm/lib/Support/Unix/Signals.inc:0:3
> #3 0x0000003f88f59800 (linux-vdso.so.1+0x800)
> #4 0x0000003f88a4d2d4 (/usr/lib/libc.so.6+0x782d4)
> #5 0x0000003f88a0df6e raise (/usr/lib/libc.so.6+0x38f6e)
> #6 0x0000003f889fc448 abort (/usr/lib/libc.so.6+0x27448)
> #7 0x0000002ab528804c llvm::report_fatal_error(llvm::Twine const&, bool) /home/mgadelha/tools/llvm-project/llvm/lib/Support/ErrorHandling.cpp:126:5
> #8 0x0000002ab5287f20 llvm::report_fatal_error(llvm::Twine const&, bool) /home/mgadelha/tools/llvm-project/llvm/lib/Support/ErrorHandling.cpp:91:0
> #9 0x0000002ab53b03a8 void llvm::support::endian::write<unsigned short>(llvm::SmallVectorImpl<char>&, unsigned short, llvm::endianness) /home/mgadelha/tools/llvm-project/llvm/include/llvm/Support/EndianStream.h:61:0
> #10 0x0000002ab53ac3e8 (anonymous namespace)::RISCVMCCodeEmitter::encodeInstruction(llvm::MCInst const&, llvm::SmallVectorImpl<char>&, llvm::SmallVectorImpl<llvm::MCFixup>&, llvm::MCSubtargetInfo const&) const /home/mgadelha/tools/llvm-project/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp:0:0
> #11 0x0000002ab5244834 llvm::SmallVectorBase<unsigned int>::size() const /home/mgadelha/tools/llvm-project/llvm/include/llvm/ADT/SmallVector.h:78:32
> #12 0x0000002ab5244834 llvm::ArrayRef<llvm::MCFixup>::ArrayRef<void>(llvm::SmallVectorTemplateCommon<llvm::MCFixup, void> const&) /home/mgadelha/tools/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:92:38
> #13 0x0000002ab5244834 llvm::MutableArrayRef<llvm::MCFixup>::MutableArrayRef(llvm::SmallVectorImpl<llvm::MCFixup>&) /home/mgadelha/tools/llvm-project/llvm/include/llvm/ADT/ArrayRef.h:342:7
> #14 0x0000002ab5244834 llvm::MCELFStreamer::emitInstToData(llvm::MCInst const&, llvm::MCSubtargetInfo const&) /home/mgadelha/tools/llvm-project/llvm/lib/MC/MCELFStreamer.cpp:555:17
> #15 0x0000002ab52d07ce (anonymous namespace)::RISCVAsmPrinter::emitInstruction(llvm::MachineInstr const*) /home/mgadelha/tools/llvm-project/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp:0:0
> #16 0x0000002ab53e9574 llvm::MachineInstr::getOpcode() const /home/mgadelha/tools/llvm-project/llvm/include/llvm/CodeGen/MachineInstr.h:570:39
> #17 0x0000002ab53e9574 llvm::MachineInstr::isBundle() const /home/mgadelha/tools/llvm-project/llvm/include/llvm/CodeGen/MachineInstr.h:1429:12
> #18 0x0000002ab53e9574 llvm::AsmPrinter::emitFunctionBody() /home/mgadelha/tools/llvm-project/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1926:17
> #19 0x0000002ab52cea76 (anonymous namespace)::RISCVAsmPrinter::runOnMachineFunction(llvm::MachineFunction&) /home/mgadelha/tools/llvm-project/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp:0:3
> #20 0x0000002ab57abdfc llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /home/mgadelha/tools/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:94:13
> #21 0x0000002ab5cfa63a llvm::FPPassManager::runOnFunction(llvm::Function&) /home/mgadelha/tools/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1406:27
> #22 0x0000002ab5cfe658 llvm::FPPassManager::runOnModule(llvm::Module&) /home/mgadelha/tools/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1451:20
> #23 0x0000002ab5cfaa38 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /home/mgadelha/tools/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1521:27
> #24 0x0000002ab5cfaa38 llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/mgadelha/tools/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:539:44
> #25 0x0000002ab53dd976 llvm::exegesis::assembleToStream(llvm::exegesis::ExegesisTarget const&, std::unique_ptr<llvm::LLVMTargetMachine, std::default_delete<llvm::LLVMTargetMachine>>, llvm::ArrayRef<unsigned int>, std::function<void (llvm::exegesis::FunctionFiller&)> const&, llvm::raw_pwrite_stream&, llvm::exegesis::BenchmarkKey const&, bool) /home/mgadelha/tools/llvm-project/llvm/tools/llvm-exegesis/lib/Assembler.cpp:0:6
> #26 0x0000002ab53c64f4 std::_Function_base::~_Function_base() /opt/riscv64/lib/gcc/riscv64-unknown-linux-gnu/14.2.0/../../../../riscv64-unknown-linux-gnu/include/c++/14.2.0/bits/std_function.h:243:11
> #27 0x0000002ab53c64f4 llvm::exegesis::BenchmarkRunner::assembleSnippet(llvm::exegesis::BenchmarkCode const&, llvm::exegesis::SnippetRepetitor const&, unsigned int, unsigned int, bool) const /home/mgadelha/tools/llvm-project/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp:599:17
> #28 0x0000002ab53c6834 llvm::Expected<llvm::SmallString<0u>>::takeError() /home/mgadelha/tools/llvm-project/llvm/include/llvm/Support/Error.h:612:12
> #29 0x0000002ab53c6834 llvm::exegesis::BenchmarkRunner::getRunnableConfiguration(llvm::exegesis::BenchmarkCode const&, unsigned int, unsigned int, llvm::exegesis::SnippetRepetitor const&) const /home/mgadelha/tools/llvm-project/llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp:639:27
> #30 0x0000002ab520ba00 llvm::exegesis::runBenchmarkConfigurations(llvm::exegesis::LLVMState const&, llvm::ArrayRef<llvm::exegesis::BenchmarkCode>, llvm::ArrayRef<std::unique_ptr<llvm::exegesis::SnippetRepetitor const, std::default_delete<llvm::exegesis::SnippetRepetitor const>>>, llvm::exegesis::BenchmarkRunner const&) /home/mgadelha/tools/llvm-project/llvm/tools/llvm-exegesis/llvm-exegesis.cpp:487:19
> #31 0x0000002ab520ba00 llvm::exegesis::benchmarkMain() /home/mgadelha/tools/llvm-project/llvm/tools/llvm-exegesis/llvm-exegesis.cpp:645:5
> #32 0x0000002ab520c552 main /home/mgadelha/tools/llvm-project/llvm/tools/llvm-exegesis/llvm-exegesis.cpp:0:5
> #33 0x0000003f889fc98e (/usr/lib/libc.so.6+0x2798e)
> #34 0x0000003f889fca3a __libc_start_main (/usr/lib/libc.so.6+0x27a3a)
> #35 0x0000002ab5207158 _start (./llvm-riscv/bin/llvm-exegesis+0x136158)
> Aborted (core dumped)
> ```
Counter support is planned in the next pr.
This error really exists, it is because there was a request to separately take out support for loading instructions.This only happens on LB and LD instructions. Pr (https://github.com/llvm/llvm-project/pull/113458) fixes it. This pr will be uploaded on top of the current one with the necessary testing.
https://github.com/llvm/llvm-project/pull/89047
More information about the llvm-commits
mailing list