[llvm] [NVPTX][NFC] Use same logic to get alignment in param declarations and function prototypes (PR #98220)
Kevin McAfee via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 9 13:47:20 PDT 2024
https://github.com/kalxr created https://github.com/llvm/llvm-project/pull/98220
Unifies the logic used to choose function prototype argument alignment and param alignment declared in the caller. The call in `getPrototype` to `getAlign`/`getFunctionParamOptimizedAlign` is replaced with `getArgumentAlignment`, which is what is currently used to select the alignment for the param declarations. This avoids code duplication of `getAlign().value_or(getFunctionParamOptimizedAlign())` and ensures that param alignments are the same in declarations and prototypes.
>From 38f5d9ccb8b70c8275960b1cbd9bd0b9214cb362 Mon Sep 17 00:00:00 2001
From: Kevin McAfee <kmcafee at nvidia.com>
Date: Mon, 8 Jul 2024 11:18:45 -0700
Subject: [PATCH] [NVPTX][NFC] Use same logic to get alignment in param
declarations and function prototypes
---
llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
index 26c16ee9fd18f..9fccfb26eb6fe 100644
--- a/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
@@ -1438,10 +1438,8 @@ std::string NVPTXTargetLowering::getPrototype(
if (!Outs[OIdx].Flags.isByVal()) {
if (IsTypePassedAsArray(Ty)) {
- const CallInst *CallI = cast<CallInst>(&CB);
Align ParamAlign =
- getAlign(*CallI, i + AttributeList::FirstArgIndex)
- .value_or(getFunctionParamOptimizedAlign(F, Ty, DL));
+ getArgumentAlignment(&CB, Ty, i + AttributeList::FirstArgIndex, DL);
O << ".param .align " << ParamAlign.value() << " .b8 ";
O << "_";
O << "[" << DL.getTypeAllocSize(Ty) << "]";
More information about the llvm-commits
mailing list