[llvm] [NVPTX][NFC] Use same logic to get alignment in param declarations and function prototypes (PR #98220)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 9 14:07:13 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-nvptx

Author: Kevin McAfee (kalxr)

<details>
<summary>Changes</summary>

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.

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


1 Files Affected:

- (modified) llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp (+1-3) 


``````````diff
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) << "]";

``````````

</details>


https://github.com/llvm/llvm-project/pull/98220


More information about the llvm-commits mailing list