Skip to content

Conversation

@jayfoad
Copy link
Contributor

@jayfoad jayfoad commented Nov 13, 2024

Check that every path from the entry block to the use block passes
through at least one def block. Previously we only checked that at least
one path passed through a def block.

Check that every path from the entry block to the use block passes
through at least one def block. Previously we only checked that at least
one path passed through a def block.
@llvmbot
Copy link
Member

llvmbot commented Nov 13, 2024

@llvm/pr-subscribers-llvm-regalloc

Author: Jay Foad (jayfoad)

Changes

Check that every path from the entry block to the use block passes
through at least one def block. Previously we only checked that at least
one path passed through a def block.


Full diff: https://github.com/llvm/llvm-project/pull/116020.diff

1 Files Affected:

  • (modified) llvm/lib/CodeGen/LiveRangeCalc.cpp (+8-2)
diff --git a/llvm/lib/CodeGen/LiveRangeCalc.cpp b/llvm/lib/CodeGen/LiveRangeCalc.cpp
index dfd4d2910955af..1a9bc694ed0fdc 100644
--- a/llvm/lib/CodeGen/LiveRangeCalc.cpp
+++ b/llvm/lib/CodeGen/LiveRangeCalc.cpp
@@ -441,15 +441,21 @@ bool LiveRangeCalc::isJointlyDominated(const MachineBasicBlock *MBB,
   for (SlotIndex I : Defs)
     DefBlocks.set(Indexes.getMBBFromIndex(I)->getNumber());
 
+  unsigned EntryNum = MF.front().getNumber();
   SetVector<unsigned> PredQueue;
   PredQueue.insert(MBB->getNumber());
   for (unsigned i = 0; i != PredQueue.size(); ++i) {
     unsigned BN = PredQueue[i];
     if (DefBlocks[BN])
-      return true;
+      continue;
+    if (BN == EntryNum) {
+      // We found a path from MBB back to the entry block without hitting any of
+      // the def blocks.
+      return false;
+    }
     const MachineBasicBlock *B = MF.getBlockNumbered(BN);
     for (const MachineBasicBlock *P : B->predecessors())
       PredQueue.insert(P->getNumber());
   }
-  return false;
+  return true;
 }

@jayfoad
Copy link
Contributor Author

jayfoad commented Nov 13, 2024

I'll try to come up with a test case using MachineVerifier.

@jayfoad
Copy link
Contributor Author

jayfoad commented Nov 13, 2024

I'll try to come up with a test case using MachineVerifier.

Actually MachineVerifier only uses this function to verify LiveIntervals and I can't write a MIR test for malformed LiveIntervals, so I don't have any way to test this.

Copy link
Contributor

@kparzysz kparzysz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for catching this!

@jayfoad jayfoad merged commit a33ae1b into llvm:main Nov 13, 2024
10 checks passed
@jayfoad jayfoad deleted the fix-isjointlydominated branch November 13, 2024 13:36
@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 13, 2024

LLVM Buildbot has detected a new failure on builder openmp-offload-sles-build-only running on rocm-worker-hw-04-sles while building llvm at step 8 "Add check check-llvm".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/140/builds/10779

Here is the relevant piece of the build log for the reference
Step 8 (Add check check-llvm) failure: test (failure)
******************** TEST 'LLVM :: ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll' FAILED ********************
Exit Code: 2

Command Output (stderr):
--
RUN: at line 1: /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli -jit-kind=orc-lazy -compile-threads=2 -thread-entry hello /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll | /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
+ /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
+ /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli -jit-kind=orc-lazy -compile-threads=2 -thread-entry hello /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
lli: /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/include/llvm/ExecutionEngine/Orc/SymbolStringPool.h:282: llvm::orc::SymbolStringPool::~SymbolStringPool(): Assertion `Pool.empty() && "Dangling references at pool destruction time"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli -jit-kind=orc-lazy -compile-threads=2 -thread-entry hello /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll
 #0 0x0000000001745618 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli+0x1745618)
 #1 0x0000000001742b5c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007fb9500ae910 __restore_rt (/lib64/libpthread.so.0+0x16910)
 #3 0x00007fb94f9dcd2b raise (/lib64/libc.so.6+0x4ad2b)
 #4 0x00007fb94f9de3e5 abort (/lib64/libc.so.6+0x4c3e5)
 #5 0x00007fb94f9d4c6a __assert_fail_base (/lib64/libc.so.6+0x42c6a)
 #6 0x00007fb94f9d4cf2 (/lib64/libc.so.6+0x42cf2)
 #7 0x00000000007d373b (/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli+0x7d373b)
 #8 0x000000000128cdb1 llvm::orc::ExecutorProcessControl::~ExecutorProcessControl() (/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli+0x128cdb1)
 #9 0x000000000128d0d3 llvm::orc::SelfExecutorProcessControl::~SelfExecutorProcessControl() (/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli+0x128d0d3)
#10 0x00000000011e6649 llvm::orc::ExecutionSession::~ExecutionSession() (/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli+0x11e6649)
#11 0x0000000001226449 llvm::orc::LLJIT::~LLJIT() (/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli+0x1226449)
#12 0x0000000001226591 llvm::orc::LLLazyJIT::~LLLazyJIT() (/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli+0x1226591)
#13 0x00000000007dd263 runOrcJIT(char const*) (/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli+0x7dd263)
#14 0x0000000000765eac main (/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/lli+0x765eac)
#15 0x00007fb94f9c724d __libc_start_main (/lib64/libc.so.6+0x3524d)
#16 0x00000000007cab4a _start /home/abuild/rpmbuild/BUILD/glibc-2.31/csu/../sysdeps/x86_64/start.S:122:0
FileCheck error: '<stdin>' is empty.
FileCheck command line:  /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/llvm/test/ExecutionEngine/OrcLazy/multiple-compile-threads-basic.ll

--

********************


@jayfoad jayfoad restored the fix-isjointlydominated branch January 14, 2025 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants