[PATCH] D144407: [NVPTX] Use proper parameter names in anonymous functions.
Pavel Kopyl via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 20 08:42:58 PST 2023
pavelkopyl created this revision.
Herald added subscribers: mattd, gchakrabarti, asavonic, hiraditya.
Herald added a project: All.
pavelkopyl requested review of this revision.
Herald added subscribers: llvm-commits, jholewinski.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D144407
Files:
llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
llvm/test/CodeGen/NVPTX/anonymous-fn-param.ll
Index: llvm/test/CodeGen/NVPTX/anonymous-fn-param.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/anonymous-fn-param.ll
@@ -0,0 +1,22 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 | FileCheck %s
+; RUN: %if ptxas %{ llc < %s -march=nvptx64 -mcpu=sm_20 | %ptxas-verify %}
+
+; CHECK: .func (.param .b32 func_retval0) __unnamed_1(
+; CHECK-NEXT: .param .b32 __unnamed_1_param_0
+; CHECK: ld.param.u32 {{%r[0-9]+}}, [__unnamed_1_param_0];
+
+; CHECK: .func (.param .b32 func_retval0) __unnamed_2(
+; CHECK-NEXT: .param .b32 __unnamed_2_param_0
+; CHECK: ld.param.u32 {{%r[0-9]+}}, [__unnamed_2_param_0];
+
+define internal i32 @0(i32 %a) {
+entry:
+ %r = add i32 %a, 1
+ ret i32 %r
+}
+
+define internal i32 @1(i32 %a) {
+entry:
+ %r = add i32 %a, 1
+ ret i32 %r
+}
Index: llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
===================================================================
--- llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
+++ llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
@@ -2617,7 +2617,14 @@
std::string ParamSym;
raw_string_ostream ParamStr(ParamSym);
- ParamStr << DAG.getMachineFunction().getName();
+ if (StringRef FnName = DAG.getMachineFunction().getName(); !FnName.empty()) {
+ ParamStr << FnName;
+ } else {
+ SmallString<128> NameBuf;
+ getTargetMachine().getObjFileLowering()->getNameWithPrefix(
+ NameBuf, &DAG.getMachineFunction().getFunction(), getTargetMachine());
+ ParamStr << NameBuf;
+ }
if (idx < 0)
ParamStr << "_vararg";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144407.498876.patch
Type: text/x-patch
Size: 1582 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230220/b794a871/attachment.bin>
More information about the llvm-commits
mailing list