[PATCH] D147740: [llvm-profdata] Refactoring Sample Profile Reader to increase FDO build speed using MD5 as key to Sample Profile map

William Junda Huang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 6 17:09:42 PDT 2023


huangjd added a comment.

In D147740#4452405 <https://reviews.llvm.org/D147740#4452405>, @ro wrote:

> This patch causes regressions on Solaris/sparcv9:
>
>   +  LLVM :: Transforms/SampleProfile/ctxsplit.ll
>   +  LLVM :: Transforms/SampleProfile/indirect-call.ll
>   +  LLVM :: Transforms/SampleProfile/profile-format.ll
>   +  LLVM :: tools/llvm-profdata/sample-nametable.test
>   +  LLVM-Unit :: ProfileData/./ProfileDataTests/26/194
>
> All of the fail in the same way (using `indirect-call.ll` as an example):
>
>   Stack dump:
>   0.      Program arguments: /var/llvm/dist-sparcv9-release-stage2-A-flang/tools/clang/stage2-bins/bin/opt -S /vol/llvm/src/llvm-project/dist/llvm/test/Transforms/SampleProfile/indirect-call.ll -passes=sample-profile -sample-profile-file=/vol/llvm/src/llvm-project/dist/llvm/test/Transforms/SampleProfile/Inputs/indirect-call.extbinary.afdo
>   Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
>   0  opt       0x00000001063410ec llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 36
>   1  opt       0x00000001063419d8 SignalHandler(int) + 896
>   2  libc.so.1 0xffffffff7eec4f00 __sighndlr + 12
>   3  libc.so.1 0xffffffff7eeb77a8 call_user_handler + 1024
>   4  libc.so.1 0xffffffff7eeb7b68 sigacthandler + 160
>   5  opt       0x000000010726a738 llvm::sampleprof::SampleProfileReaderBinary::readSampleContextFromTable() + 556
>   6  opt       0x000000010726e370 llvm::sampleprof::SampleProfileReaderExtBinaryBase::readFuncOffsetTable() + 680
>   7  opt       0x000000010726bb88 llvm::sampleprof::SampleProfileReaderExtBinaryBase::readOneSection(unsigned char const*, unsigned long, llvm::sampleprof::SecHdrTableEntry const&) + 484
>   8  opt       0x000000010726f1bc llvm::sampleprof::SampleProfileReaderExtBinaryBase::readImpl() + 212
>   9  opt       0x0000000106d31128 llvm::SampleProfileLoaderPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 2172
>   10 opt       0x0000000105c94770 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 480
>   11 opt       0x000000010373b650 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool) + 11052
>   12 opt       0x0000000103749cf0 main + 8592
>   13 opt       0x0000000103738544 _start + 100
>   FileCheck error: '<stdin>' is empty.
>
> `truss` (the Solaris syscall tracer) shows
>
>   22092:	    Incurred fault #5, FLTACCESS  %pc = 0x10726A738
>   22092:	      siginfo: SIGBUS BUS_ADRALN addr=0x1082ED3D3
>   22092:	    Received signal #10, SIGBUS [caught]
>   22092:	      siginfo: SIGBUS BUS_ADRALN addr=0x1082ED3D3
>
> i.e. the code tries an unaligned access, which is a no-no on strict-alignment targets like SPARC.

It looks like the error happens at line 577 of SampleProfReader.cpp. I changed ```hash_code Hash = MD5SampleContextStart[Idx]``` 
into

  hash_code Hash =
        support::endian::read<hash_code, support::little, support::unaligned>(
            MD5SampleContextStart + Idx);

Since MD5SampleContextStart can point to an unaligned position in the actual profile, if I understand it correctly.
I don't have a sparc machine, so I would like to find someone to test it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147740



More information about the llvm-commits mailing list