-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[CodeGen] Allow negative frame indicies in Register class. #164459
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
Changes from 7 commits
dc95302
7b2fcda
478c945
695baef
29bf5cd
a871d1f
e6a016a
b30b8ea
00fa7fb
0d3cc18
98162f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,35 @@ | ||||||||||||||||||||||||||||||||||||
| //===- RegisterTest.cpp -----------------------------------------------===// | ||||||||||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||||||||||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||||||||||||||||||||||||||||||||||
| // See https://llvm.org/LICENSE.txt for license information. | ||||||||||||||||||||||||||||||||||||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||||||||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||||||||||
| //===----------------------------------------------------------------------===// | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| #include "llvm/CodeGen/Register.h" | ||||||||||||||||||||||||||||||||||||
| #include "gtest/gtest.h" | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| using namespace llvm; | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| namespace { | ||||||||||||||||||||||||||||||||||||
| TEST(RegisterTest, Idx2StackSlot) { | ||||||||||||||||||||||||||||||||||||
| EXPECT_EQ(Register::index2StackSlot(0), Register::StackSlotZero); | ||||||||||||||||||||||||||||||||||||
| EXPECT_EQ(Register::index2StackSlot(1), Register::StackSlotZero | 1); | ||||||||||||||||||||||||||||||||||||
| EXPECT_EQ(Register::index2StackSlot(-1), | ||||||||||||||||||||||||||||||||||||
| Register::StackSlotZero | Register::StackSlotMask); | ||||||||||||||||||||||||||||||||||||
| // check that we do not crash on the highest possible value of frame index. | ||||||||||||||||||||||||||||||||||||
| EXPECT_NO_FATAL_FAILURE(Register::index2StackSlot((1 << 29) - 1)); | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| // check that we do not crash on the lowest possible value of frame index. | ||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||
| // check that we do not crash on the lowest possible value of frame index. | |
| // Check that we do not crash on the lowest possible value of frame index. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| EXPECT_EQ(Register::index2StackSlot(0), Register::StackSlotZero); | |
| EXPECT_EQ(Register::index2StackSlot(1), Register::StackSlotZero | 1); | |
| EXPECT_EQ(Register::index2StackSlot(-1), | |
| Register::StackSlotZero | Register::StackSlotMask); | |
| // check that we do not crash on the highest possible value of frame index. | |
| EXPECT_NO_FATAL_FAILURE(Register::index2StackSlot((1 << 29) - 1)); | |
| // check that we do not crash on the lowest possible value of frame index. | |
| EXPECT_NO_FATAL_FAILURE(Register::index2StackSlot(-(1 << 29))); | |
| int MaxPowOf2 = 1 << 29; | |
| EXPECT_EQ(Register::index2StackSlot(0), Register::StackSlotZero); | |
| EXPECT_EQ(Register::index2StackSlot(1), Register::StackSlotZero | 1); | |
| EXPECT_EQ(Register::index2StackSlot(-1), | |
| Register::StackSlotZero | Register::StackSlotMask); | |
| // check that we do not crash on the highest possible value of frame index. | |
| EXPECT_NO_FATAL_FAILURE(Register::index2StackSlot(MaxPowOf2 - 1)); | |
| // check that we do not crash on the lowest possible value of frame index. | |
| EXPECT_NO_FATAL_FAILURE(Register::index2StackSlot(-MaxPowOf2)); |
Or just MaxBits = 29 or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should use Register::MaxFrameIndexBitwidth - 1 instead of putting 29 anywhere in the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed an edit to this and the other line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed