Skip to content

[LivePhysReg] Fix off by 1 error in an assert. NFC #128379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2025

Conversation

topperc
Copy link
Collaborator

@topperc topperc commented Feb 22, 2025

Pretty sure Reg should not be equal to the number of registers.

Pretty sure Reg should not be equal to the number of registers.
@llvmbot
Copy link
Member

llvmbot commented Feb 23, 2025

@llvm/pr-subscribers-llvm-regalloc

Author: Craig Topper (topperc)

Changes

Pretty sure Reg should not be equal to the number of registers.


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

1 Files Affected:

  • (modified) llvm/include/llvm/CodeGen/LivePhysRegs.h (+2-2)
diff --git a/llvm/include/llvm/CodeGen/LivePhysRegs.h b/llvm/include/llvm/CodeGen/LivePhysRegs.h
index 037905119eb22..696e8a0c5dd59 100644
--- a/llvm/include/llvm/CodeGen/LivePhysRegs.h
+++ b/llvm/include/llvm/CodeGen/LivePhysRegs.h
@@ -82,7 +82,7 @@ class LivePhysRegs {
   /// Adds a physical register and all its sub-registers to the set.
   void addReg(MCPhysReg Reg) {
     assert(TRI && "LivePhysRegs is not initialized.");
-    assert(Reg <= TRI->getNumRegs() && "Expected a physical register.");
+    assert(Reg < TRI->getNumRegs() && "Expected a physical register.");
     for (MCPhysReg SubReg : TRI->subregs_inclusive(Reg))
       LiveRegs.insert(SubReg);
   }
@@ -91,7 +91,7 @@ class LivePhysRegs {
   /// super-registers from the set.
   void removeReg(MCPhysReg Reg) {
     assert(TRI && "LivePhysRegs is not initialized.");
-    assert(Reg <= TRI->getNumRegs() && "Expected a physical register.");
+    assert(Reg < TRI->getNumRegs() && "Expected a physical register.");
     for (MCRegAliasIterator R(Reg, TRI, true); R.isValid(); ++R)
       LiveRegs.erase((*R).id());
   }

@topperc topperc merged commit a26fd0b into llvm:main Feb 23, 2025
13 checks passed
@topperc topperc deleted the pr/offbyone branch February 23, 2025 05:13
@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 23, 2025

LLVM Buildbot has detected a new failure on builder openmp-clang-x86_64-linux-debian running on gribozavr4 while building llvm at step 6 "test-openmp".

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

Here is the relevant piece of the build log for the reference
Step 6 (test-openmp) failure: test (failure)
******************** TEST 'libomp :: ompt/tasks/taskloop_dispatch.c' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/b/1/openmp-clang-x86_64-linux-debian/llvm.build/./bin/clang -fopenmp   -I /b/1/openmp-clang-x86_64-linux-debian/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -I /b/1/openmp-clang-x86_64-linux-debian/llvm.src/openmp/runtime/test -L /b/1/openmp-clang-x86_64-linux-debian/llvm.build/runtimes/runtimes-bins/openmp/runtime/src  -fno-omit-frame-pointer -I /b/1/openmp-clang-x86_64-linux-debian/llvm.src/openmp/runtime/test/ompt /b/1/openmp-clang-x86_64-linux-debian/llvm.src/openmp/runtime/test/ompt/tasks/taskloop_dispatch.c -o /b/1/openmp-clang-x86_64-linux-debian/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/ompt/tasks/Output/taskloop_dispatch.c.tmp -lm -latomic && /b/1/openmp-clang-x86_64-linux-debian/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/ompt/tasks/Output/taskloop_dispatch.c.tmp | sort -n -s | tee /b/1/openmp-clang-x86_64-linux-debian/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/ompt/tasks/Output/taskloop_dispatch.c.tmp.out | /b/1/openmp-clang-x86_64-linux-debian/llvm.build/./bin/FileCheck /b/1/openmp-clang-x86_64-linux-debian/llvm.src/openmp/runtime/test/ompt/tasks/taskloop_dispatch.c
# executed command: /b/1/openmp-clang-x86_64-linux-debian/llvm.build/./bin/clang -fopenmp -I /b/1/openmp-clang-x86_64-linux-debian/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -I /b/1/openmp-clang-x86_64-linux-debian/llvm.src/openmp/runtime/test -L /b/1/openmp-clang-x86_64-linux-debian/llvm.build/runtimes/runtimes-bins/openmp/runtime/src -fno-omit-frame-pointer -I /b/1/openmp-clang-x86_64-linux-debian/llvm.src/openmp/runtime/test/ompt /b/1/openmp-clang-x86_64-linux-debian/llvm.src/openmp/runtime/test/ompt/tasks/taskloop_dispatch.c -o /b/1/openmp-clang-x86_64-linux-debian/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/ompt/tasks/Output/taskloop_dispatch.c.tmp -lm -latomic
# executed command: /b/1/openmp-clang-x86_64-linux-debian/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/ompt/tasks/Output/taskloop_dispatch.c.tmp
# executed command: sort -n -s
# executed command: tee /b/1/openmp-clang-x86_64-linux-debian/llvm.build/runtimes/runtimes-bins/openmp/runtime/test/ompt/tasks/Output/taskloop_dispatch.c.tmp.out
# executed command: /b/1/openmp-clang-x86_64-linux-debian/llvm.build/./bin/FileCheck /b/1/openmp-clang-x86_64-linux-debian/llvm.src/openmp/runtime/test/ompt/tasks/taskloop_dispatch.c
# .---command stderr------------
# | /b/1/openmp-clang-x86_64-linux-debian/llvm.src/openmp/runtime/test/ompt/tasks/taskloop_dispatch.c:47:16: error: CHECK-DAG: expected string not found in input
# |  // CHECK-DAG: {{.*}}: ompt_event_taskloop_chunk_begin:{{.*}}task_id=[[TASK_ID0]]{{.*}}chunk_iterations=4
# |                ^
# | <stdin>:18:182: note: scanning from here
# | 281474976710658: ompt_event_task_create: parent_task_id=281474976710662, parent_task_frame.exit=0x7ffccda992d0, parent_task_frame.reenter=0x7ffccda990d0, new_task_id=281474976710666, codeptr_ra=0x7f72d0e95777, task_type=ompt_task_explicit=4, has_dependences=no
# |                                                                                                                                                                                      ^
# | <stdin>:18:182: note: with "TASK_ID0" equal to "281474976710663"
# | 281474976710658: ompt_event_task_create: parent_task_id=281474976710662, parent_task_frame.exit=0x7ffccda992d0, parent_task_frame.reenter=0x7ffccda990d0, new_task_id=281474976710666, codeptr_ra=0x7f72d0e95777, task_type=ompt_task_explicit=4, has_dependences=no
# |                                                                                                                                                                                      ^
# | <stdin>:22:14: note: possible intended match here
# | 281474976710658: ompt_event_taskloop_chunk_begin: parallel_id=281474976710661, task_id=281474976710666, codeptr_ra=(nil), chunk_start=12, chunk_iterations=4
# |              ^
# | 
# | Input file: <stdin>
# | Check file: /b/1/openmp-clang-x86_64-linux-debian/llvm.src/openmp/runtime/test/ompt/tasks/taskloop_dispatch.c
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |           .
# |           .
# |           .
# |          13: 281474976710658: ompt_event_taskgroup_begin: parallel_id=281474976710661, task_id=281474976710662, codeptr_ra=0x55a8864d543c 
# |          14: 281474976710658: ompt_event_taskloop_begin: parallel_id=281474976710661, task_id=281474976710662, codeptr_ra=0x7f72d0e95777, count=16 
# |          15: 281474976710658: ompt_event_task_create: parent_task_id=281474976710662, parent_task_frame.exit=0x7ffccda992d0, parent_task_frame.reenter=0x7ffccda990d0, new_task_id=281474976710663, codeptr_ra=0x7f72d0e95777, task_type=ompt_task_explicit=4, has_dependences=no 
# |          16: 281474976710658: ompt_event_task_create: parent_task_id=281474976710662, parent_task_frame.exit=0x7ffccda992d0, parent_task_frame.reenter=0x7ffccda990d0, new_task_id=281474976710664, codeptr_ra=0x7f72d0e95777, task_type=ompt_task_explicit=4, has_dependences=no 
# |          17: 281474976710658: ompt_event_task_create: parent_task_id=281474976710662, parent_task_frame.exit=0x7ffccda992d0, parent_task_frame.reenter=0x7ffccda990d0, new_task_id=281474976710665, codeptr_ra=0x7f72d0e95777, task_type=ompt_task_explicit=4, has_dependences=no 
# |          18: 281474976710658: ompt_event_task_create: parent_task_id=281474976710662, parent_task_frame.exit=0x7ffccda992d0, parent_task_frame.reenter=0x7ffccda990d0, new_task_id=281474976710666, codeptr_ra=0x7f72d0e95777, task_type=ompt_task_explicit=4, has_dependences=no 
# | dag:47'0                                                                                                                                                                                          X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
# | dag:47'1                                                                                                                                                                                                                                                                           with "TASK_ID0" equal to "281474976710663"
# |          19: 281474976710658: ompt_event_taskloop_end: parallel_id=281474976710661, task_id=281474976710662, codeptr_ra=0x7f72d0e95777, count=16 
# | dag:47'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |          20: 281474976710658: ompt_event_wait_taskgroup_begin: parallel_id=281474976710661, task_id=281474976710662, codeptr_ra=0x55a8864d5502 
# | dag:47'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |          21: 281474976710658: ompt_event_task_schedule: first_task_id=281474976710662, second_task_id=281474976710666, prior_task_status=ompt_task_switch=7 
# | dag:47'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...

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