[llvm] [llvm][CodeGen] Add a new software pipeliner 'Window Scheduler' (PR #84443)
Hua Tian via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 14 17:56:44 PDT 2024
huaatian wrote:
> I am seeing a crash when building the Linux kernel for Hexagon after this change. A C and LLVM IR reproducer from `cvise` and `llvm-reduce` respectively:
>
> ```c
> struct khazad_ctx {
> long long E[1];
> long D[];
> };
> long T7[] = {};
> void *khazad_setkey_in_key___trans_tmp_1;
> int khazad_setkey_in_key_r;
> void khazad_setkey_in_key() {
> struct khazad_ctx *ctx = khazad_setkey_in_key___trans_tmp_1;
> unsigned *key = (unsigned *)khazad_setkey_in_key;
> long long K1 = key[3];
> for (; khazad_setkey_in_key_r; khazad_setkey_in_key_r++) {
> K1 = ctx->E[khazad_setkey_in_key_r];
> ctx->D[khazad_setkey_in_key_r] = T7[K1 >> 32] ^ T7[K1 >> 4 & 5];
> }
> }
> ```
>
> ```llvm
> target datalayout = "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048"
> target triple = "hexagon-unknown-linux"
>
> define void @khazad_setkey_in_key(ptr %0, ptr %1) {
> br label %3
>
> 3: ; preds = %3, %2
> %4 = phi i32 [ %16, %3 ], [ 0, %2 ]
> %5 = load i64, ptr %0, align 8
> %6 = trunc i64 %5 to i32
> store i32 %6, ptr %1, align 4
> %7 = lshr i64 %5, 32
> %8 = trunc i64 %7 to i32
> %9 = getelementptr [0 x i32], ptr null, i32 0, i32 %8
> %10 = load i32, ptr %9, align 4
> %11 = lshr i32 %6, 1
> %12 = and i32 %11, 1
> %13 = getelementptr [0 x i32], ptr null, i32 0, i32 %12
> %14 = load i32, ptr %13, align 4
> %15 = xor i32 %14, %10
> store i32 %15, ptr %0, align 4
> %16 = add i32 %4, 1
> %17 = icmp eq i32 %4, 0
> br i1 %17, label %18, label %3
>
> 18: ; preds = %3
> ret void
> }
> ```
>
> @ [a144bf2](https://github.com/llvm/llvm-project/commit/a144bf2b2511b47fc165755817eda17f79ef5476)
>
> ```
> $ clang --target=hexagon-linux -O2 -c -o /dev/null khazad.i
>
> $ llc -o /dev/null reduced.ll
> ```
>
> @ [b6bf402](https://github.com/llvm/llvm-project/commit/b6bf4024a031a5e7b58aff1425d94841a88002d6)
>
> ```
> $ clang --target=hexagon-linux -O2 -c -o /dev/null khazad.i
> clang: /home/nathan/tmp/cvise.XAc760fE9l/src/llvm/lib/CodeGen/WindowScheduler.cpp:650: int llvm::WindowScheduler::getOriCycle(MachineInstr *): Assertion `OriToCycle.count(OriMI) && "Cannot find schedule cycle!"' failed.
> PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
> Stack dump:
> 0. Program arguments: clang --target=hexagon-linux -O2 -c -o /dev/null khazad.i
> 1. <eof> parser at end of file
> 2. Code generation
> 3. Running pass 'Function Pass Manager' on module 'khazad.i'.
> 4. Running pass 'Modulo Software Pipelining' on function '@khazad_setkey_in_key'
> #0 0x00005615664e1c36 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x3957c36)
> #1 0x00005615664df6ae llvm::sys::RunSignalHandlers() (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x39556ae)
> #2 0x0000561566463c1d CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
> #3 0x00007f67001dbae0 (/usr/lib/libc.so.6+0x3cae0)
> #4 0x00007f6700233e44 (/usr/lib/libc.so.6+0x94e44)
> #5 0x00007f67001dba30 raise (/usr/lib/libc.so.6+0x3ca30)
> #6 0x00007f67001c34c3 abort (/usr/lib/libc.so.6+0x244c3)
> #7 0x00007f67001c33df (/usr/lib/libc.so.6+0x243df)
> #8 0x00007f67001d3c67 (/usr/lib/libc.so.6+0x34c67)
> #9 0x0000561565e1d3ce llvm::WindowScheduler::getOriCycle(llvm::MachineInstr*) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x32933ce)
> #10 0x0000561565e1cc5a llvm::WindowScheduler::calculateMaxCycle(llvm::ScheduleDAGInstrs&, unsigned int) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x3292c5a)
> #11 0x0000561565e1daeb llvm::WindowScheduler::analyseII(llvm::ScheduleDAGInstrs&, unsigned int) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x3293aeb)
> #12 0x0000561565e1a1ba llvm::WindowScheduler::run() (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x32901ba)
> #13 0x0000561565a688e3 llvm::MachinePipeliner::runWindowScheduler(llvm::MachineLoop&) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x2ede8e3)
> #14 0x0000561565a66afb llvm::MachinePipeliner::scheduleLoop(llvm::MachineLoop&) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x2edcafb)
> #15 0x0000561565a6695b llvm::MachinePipeliner::runOnMachineFunction(llvm::MachineFunction&) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x2edc95b)
> #16 0x0000561565a2464e llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x2e9a64e)
> #17 0x0000561565fe9217 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x345f217)
> #18 0x0000561565ff1c22 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x3467c22)
> #19 0x0000561565fe9d17 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x345fd17)
> #20 0x0000561566cfc4a0 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x41724a0)
> #21 0x0000561566d22598 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x4198598)
> #22 0x0000561568136819 clang::ParseAST(clang::Sema&, bool, bool) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x55ac819)
> #23 0x000056156719f2dd clang::FrontendAction::Execute() (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x46152dd)
> #24 0x000056156710590d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x457b90d)
> #25 0x0000561567279c14 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x46efc14)
> #26 0x00005615650a6dd0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x251cdd0)
> #27 0x00005615650a36ae ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
> #28 0x0000561566f320c9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_0>(long) Job.cpp:0:0
> #29 0x0000561566463956 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x38d9956)
> #30 0x0000561566f31753 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x43a7753)
> #31 0x0000561566eea07c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x436007c)
> #32 0x0000561566eea5d7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x43605d7)
> #33 0x0000561566f0c729 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x4382729)
> #34 0x00005615650a2b9d clang_main(int, char**, llvm::ToolContext const&) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x2518b9d)
> #35 0x00005615650b3d56 main (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x2529d56)
> #36 0x00007f67001c4c88 (/usr/lib/libc.so.6+0x25c88)
> #37 0x00007f67001c4d4c __libc_start_main (/usr/lib/libc.so.6+0x25d4c)
> #38 0x00005615650a0fa5 _start (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/clang-19+0x2516fa5)
> clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
> ClangBuiltLinux clang version 19.0.0git (https://github.com/llvm/llvm-project.git b6bf4024a031a5e7b58aff1425d94841a88002d6)
> Target: hexagon-unknown-linux
> Thread model: posix
> InstalledDir: /home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin
> Build config: +assertions
> clang: note: diagnostic msg: Error generating preprocessed source(s) - no preprocessable inputs.
>
> $ llc -o /dev/null reduced.ll
> llc: /home/nathan/tmp/cvise.XAc760fE9l/src/llvm/lib/CodeGen/WindowScheduler.cpp:650: int llvm::WindowScheduler::getOriCycle(MachineInstr *): Assertion `OriToCycle.count(OriMI) && "Cannot find schedule cycle!"' failed.
> PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
> Stack dump:
> 0. Program arguments: llc -o /dev/null reduced.ll
> 1. Running pass 'Function Pass Manager' on module 'reduced.ll'.
> 2. Running pass 'Modulo Software Pipelining' on function '@khazad_setkey_in_key'
> #0 0x00005651bf6712a6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/llc+0x353c2a6)
> #1 0x00005651bf66ecae llvm::sys::RunSignalHandlers() (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/llc+0x3539cae)
> #2 0x00005651bf6719b4 SignalHandler(int) Signals.cpp:0:0
> #3 0x00007fbbbccc0ae0 (/usr/lib/libc.so.6+0x3cae0)
> #4 0x00007fbbbcd18e44 (/usr/lib/libc.so.6+0x94e44)
> #5 0x00007fbbbccc0a30 raise (/usr/lib/libc.so.6+0x3ca30)
> #6 0x00007fbbbcca84c3 abort (/usr/lib/libc.so.6+0x244c3)
> #7 0x00007fbbbcca83df (/usr/lib/libc.so.6+0x243df)
> #8 0x00007fbbbccb8c67 (/usr/lib/libc.so.6+0x34c67)
> #9 0x00005651bea1e8be llvm::WindowScheduler::getOriCycle(llvm::MachineInstr*) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/llc+0x28e98be)
> #10 0x00005651bea1e14a llvm::WindowScheduler::calculateMaxCycle(llvm::ScheduleDAGInstrs&, unsigned int) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/llc+0x28e914a)
> #11 0x00005651bea1efdb llvm::WindowScheduler::analyseII(llvm::ScheduleDAGInstrs&, unsigned int) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/llc+0x28e9fdb)
> #12 0x00005651bea1b56a llvm::WindowScheduler::run() (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/llc+0x28e656a)
> #13 0x00005651be709b53 llvm::MachinePipeliner::runWindowScheduler(llvm::MachineLoop&) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/llc+0x25d4b53)
> #14 0x00005651be707d1b llvm::MachinePipeliner::scheduleLoop(llvm::MachineLoop&) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/llc+0x25d2d1b)
> #15 0x00005651be707b7b llvm::MachinePipeliner::runOnMachineFunction(llvm::MachineFunction&) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/llc+0x25d2b7b)
> #16 0x00005651be69875e llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/llc+0x256375e)
> #17 0x00005651bec14b97 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/llc+0x2adfb97)
> #18 0x00005651bec1d682 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/llc+0x2ae8682)
> #19 0x00005651bec15727 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/llc+0x2ae0727)
> #20 0x00005651bdb84a42 main (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/llc+0x1a4fa42)
> #21 0x00007fbbbcca9c88 (/usr/lib/libc.so.6+0x25c88)
> #22 0x00007fbbbcca9d4c __libc_start_main (/usr/lib/libc.so.6+0x25d4c)
> #23 0x00005651bdb7e8e5 _start (/home/nathan/tmp/cvise.XAc760fE9l/install/llvm-bad/bin/llc+0x1a498e5)
> ```
>
> ```
> # bad: [e84ecf26fa5d9a4be4da078a1f85e988731308af] [NFC][PowerPC] Add test to check lanemasks for subregisters. (#94363)
> # good: [a91c8398f22c28618d681497e9856c3a4b8753c3] [MC] Move -save-temp-labels from llvm-mc to MCTargetOptionsCommandFlags
> git bisect start 'e84ecf26fa5d9a4be4da078a1f85e988731308af' 'a91c8398f22c28618d681497e9856c3a4b8753c3'
> # bad: [ba7d5ebe4bb2dc9b6885adf8346529e763cd6fce] [libc] Fix build breaks caused by f16sqrtf changes (#95459)
> git bisect bad ba7d5ebe4bb2dc9b6885adf8346529e763cd6fce
> # bad: [71e4d70f0bb04bae6c8521c711c770293fd228a5] [clang][NFC] Update CWG issues list git bisect bad 71e4d70f0bb04bae6c8521c711c770293fd228a5
> # good: [65f746e76c97b6f8aece139199aed44ce632255c] [flang] Update UBOUND runtime API and lowering (#95085)
> git bisect good 65f746e76c97b6f8aece139199aed44ce632255c
> # bad: [846e47e7b880bcf6b8f5773fe0fe236d486f3239] [MC] Reduce size of MCDataFragment by 8 bytes (#95293)
> git bisect bad 846e47e7b880bcf6b8f5773fe0fe236d486f3239
> # good: [445973caceea9154b7f05a0b574ced346955be87] [LegalizeTypes] Handle non byte-sized elt types when splitting INSERT/EXTRACT_VECTOR_ELT (#93357)
> git bisect good 445973caceea9154b7f05a0b574ced346955be87
> # good: [3475116e2c37a2c8a69658b36c02871c322da008] [clang][NFC] Add a test for CWG2685 (#95206)
> git bisect good 3475116e2c37a2c8a69658b36c02871c322da008
> # bad: [b6bf4024a031a5e7b58aff1425d94841a88002d6] [llvm][CodeGen] Add a new software pipeliner 'Window Scheduler' (#84443)
> git bisect bad b6bf4024a031a5e7b58aff1425d94841a88002d6
> # good: [a144bf2b2511b47fc165755817eda17f79ef5476] [Clang] Fix handling of brace ellison when building deduction guides (#94889)
> git bisect good a144bf2b2511b47fc165755817eda17f79ef5476
> # first bad commit: [b6bf4024a031a5e7b58aff1425d94841a88002d6] [llvm][CodeGen] Add a new software pipeliner 'Window Scheduler' (#84443)
> ```
Okay, we will handle it right away.
https://github.com/llvm/llvm-project/pull/84443
More information about the llvm-commits
mailing list