-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[NVTPX] Copy kernel arguments as byte array #110356
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
Conversation
|
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
|
@llvm/pr-subscribers-backend-nvptx Author: Michael Kuron (mkuron) ChangesEnsures that struct padding is not skipped, as it may contain actual data if the struct is really a union. The patch originated from a discussion on #53710, and @Artem-B suggested I post it as a pull request. This is my first LLVM code contribution, so I may need a bit of help creating a suitable test case. Fixes #53710 Full diff: https://github.com/llvm/llvm-project/pull/110356.diff 1 Files Affected:
diff --git a/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp b/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp
index 082546c4dd72f8..bfeac304af61b9 100644
--- a/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXLowerArgs.cpp
@@ -626,8 +626,11 @@ void NVPTXLowerArgs::handleByValParam(const NVPTXTargetMachine &TM,
// Be sure to propagate alignment to this load; LLVM doesn't know that NVPTX
// addrspacecast preserves alignment. Since params are constant, this load
// is definitely not volatile.
+ const auto StructBytes = *AllocA->getAllocationSize(DL);
+ Type *ByteType = Type::getIntNTy(Func->getContext(), 8);
+ Type *OpaqueType = ArrayType::get(ByteType, StructBytes);
LoadInst *LI =
- new LoadInst(StructType, ArgInParam, Arg->getName(),
+ new LoadInst(OpaqueType, ArgInParam, Arg->getName(),
/*isVolatile=*/false, AllocA->getAlign(), FirstInst);
new StoreInst(LI, AllocA, FirstInst);
}
|
Ensures that struct padding is not skipped, as it may contain actual data if the struct is really a union. Fixes #53710
Artem-B
left a comment
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'm apparently bad at clicking on "Submit review" button. This comment's been sitting there unsubmitted for a while. Sorry about that.
Artem-B
left a comment
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.
LGTM, with a test nit.
llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/nvptx-basic.ll.expected
Outdated
Show resolved
Hide resolved
|
@Artem-B, do we need another approval? Who can merge? |
|
You are good to go. If you do not have commit access I can merge the patch on your behalf. |
|
@Artem-B, please do merge it. |
|
@mkuron Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
Ensures that struct padding is not skipped, as it may contain actual data if the struct is really a union. The patch originated from a discussion on llvm#53710 Fixes llvm#53710
Ensures that struct padding is not skipped, as it may contain actual data if the struct is really a union.
The patch originated from a discussion on #53710, and @Artem-B suggested I post it as a pull request. This is my first LLVM code contribution, so I may need a bit of help in getting this into a shape acceptable to merge.
I updated the existing test cases that were failing after my change, which lead to some changes from
align 4toalign 8on thestore. The result actually looks correct to me -- the corresponding argument and the correspondingallocaboth havealign 8, only thestorepreviously used a narrower alignment than it could have.Fixes #53710