-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[GlobalISel] Add unit tests for call lowering on byref support #96805
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
darkbuck
merged 1 commit into
main
from
users/darkbuck/spr/globalisel-add-unit-tests-for-call-lowering-on-byref-support
Jun 27, 2024
Merged
[GlobalISel] Add unit tests for call lowering on byref support #96805
darkbuck
merged 1 commit into
main
from
users/darkbuck/spr/globalisel-add-unit-tests-for-call-lowering-on-byref-support
Jun 27, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created using spr 1.3.4
@llvm/pr-subscribers-llvm-globalisel Author: None (darkbuck) ChangesFull diff: https://github.com/llvm/llvm-project/pull/96805.diff 2 Files Affected:
diff --git a/llvm/unittests/CodeGen/GlobalISel/CMakeLists.txt b/llvm/unittests/CodeGen/GlobalISel/CMakeLists.txt
index 111d7f4d2f620..253b90d5dc1f8 100644
--- a/llvm/unittests/CodeGen/GlobalISel/CMakeLists.txt
+++ b/llvm/unittests/CodeGen/GlobalISel/CMakeLists.txt
@@ -1,5 +1,6 @@
set(LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
+ AsmParser
CodeGen
CodeGenTypes
Core
@@ -26,4 +27,5 @@ add_llvm_unittest(GlobalISelTests
KnownBitsVectorTest.cpp
GISelUtilsTest.cpp
GISelAliasTest.cpp
+ CallLowering.cpp
)
diff --git a/llvm/unittests/CodeGen/GlobalISel/CallLowering.cpp b/llvm/unittests/CodeGen/GlobalISel/CallLowering.cpp
new file mode 100644
index 0000000000000..1d36e5e9ca946
--- /dev/null
+++ b/llvm/unittests/CodeGen/GlobalISel/CallLowering.cpp
@@ -0,0 +1,57 @@
+//===- CallLowering.cpp - CallLowering unit tests -------------------------===//
+//
+// 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/GlobalISel/CallLowering.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/AsmParser/Parser.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Support/SourceMgr.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+
+namespace {
+struct TargetCallLoweringTest : public CallLowering, testing::Test {
+ LLVMContext C;
+
+public:
+ TargetCallLoweringTest() : CallLowering(nullptr) {}
+
+ std::unique_ptr<Module> parseIR(const char *IR) {
+ SMDiagnostic Err;
+ std::unique_ptr<Module> Mod = parseAssemblyString(IR, Err, C);
+ if (!Mod)
+ Err.print("TestTargetCallLoweringTest", errs());
+ return Mod;
+ }
+};
+} // namespace
+
+TEST_F(TargetCallLoweringTest, ArgByRef) {
+ std::unique_ptr<Module> M = parseIR(R"(
+define void @foo(ptr %p0, ptr byref(i32) align(4) %p1) {
+ ret void
+}
+)");
+ const DataLayout &DL = M->getDataLayout();
+ Function *F = M->getFunction("foo");
+ // Dummy vregs.
+ SmallVector<Register, 4> VRegs(1, 1);
+
+ CallLowering::ArgInfo Arg0(VRegs, F->getArg(0)->getType(), 0);
+ setArgFlags(Arg0, AttributeList::FirstArgIndex + 0, DL, *F);
+ EXPECT_TRUE(Arg0.Flags[0].isPointer());
+ EXPECT_FALSE(Arg0.Flags[0].isByRef());
+
+ CallLowering::ArgInfo Arg1(VRegs, F->getArg(1)->getType(), 1);
+ setArgFlags(Arg1, AttributeList::FirstArgIndex + 1, DL, *F);
+ EXPECT_TRUE(Arg1.Flags[0].isPointer());
+ EXPECT_TRUE(Arg1.Flags[0].isByRef());
+ EXPECT_EQ(Arg1.Flags[0].getByRefSize(), 4U);
+}
|
spaits
approved these changes
Jun 26, 2024
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.
Looks good to me. Thank you for creating these tests.
Thanks! |
arsenm
approved these changes
Jun 27, 2024
keith
added a commit
that referenced
this pull request
Jun 28, 2024
lravenclaw
pushed a commit
to lravenclaw/llvm-project
that referenced
this pull request
Jul 3, 2024
Reviewers: tschuett, spaits, aemerson, arsenm Reviewed By: spaits, arsenm Pull Request: llvm#96805
lravenclaw
pushed a commit
to lravenclaw/llvm-project
that referenced
this pull request
Jul 3, 2024
AlexisPerry
pushed a commit
to llvm-project-tlp/llvm-project
that referenced
this pull request
Jul 9, 2024
Reviewers: tschuett, spaits, aemerson, arsenm Reviewed By: spaits, arsenm Pull Request: llvm#96805
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.