[llvm-dev] Legal names for Functions and other Identifiers

SANJAY SRIVALLABH SINGAPURAM via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 22 13:03:30 PDT 2017


Hello Chen,

Here's some context. kernel-params-only-some-arrays.ll is a file used to
test Polly's GPU codegeneration feature. I had made changes to Polly to
rename the PTX functions it would produce, So these changes had to reflect
in this test case as well. Here's the entire diff,

--- a/test/GPGPU/kernel-params-only-some-arrays.ll
+++ b/test/GPGPU/kernel-params-only-some-arrays.ll
@@ -16,12 +16,12 @@
 ;        B[i] += 42;
 ;    }

-; KERNEL: ; ModuleID = 'kernel_0'
-; KERNEL-NEXT: source_filename = "kernel_0"
+; KERNEL: ; ModuleID =
'kernel_params_only_some_arrays_%or.cond---%or.end9_kernel_0'
+; KERNEL-NEXT: source_filename =
"kernel_params_only_some_arrays_%or.cond---%or.end9_kernel_0"
 ; KERNEL-NEXT: target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64"
 ; KERNEL-NEXT: target triple = "nvptx64-nvidia-cuda"

-; KERNEL: define ptx_kernel void @kernel_0(i8 addrspace(1)* %MemRef_A)
+; KERNEL: define ptx_kernel void
@kernel_params_only_some_arrays_%or.cond---%or.end9_kernel_0(i8
addrspace(1)* %MemRef_A)
 ; KERNEL-NEXT:   entry:
 ; KERNEL-NEXT:     %0 = call i32 @llvm.nvvm.read.ptx.sreg.ctaid.x()
 ; KERNEL-NEXT:     %b0 = zext i32 %0 to i64
@@ -31,12 +31,12 @@
 ; KERNEL:     ret void
 ; KERNEL-NEXT: }

-; KERNEL: ; ModuleID = 'kernel_1'
-; KERNEL-NEXT: source_filename = "kernel_1"
+; KERNEL: ; ModuleID =
'kernel_params_only_some_arrays_%or.cond---%or.end9_kernel_1'
+; KERNEL-NEXT: source_filename =
"kernel_params_only_some_arrays_%or.cond---%or.end9_kernel_1"
 ; KERNEL-NEXT: target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-n16:32:64"
 ; KERNEL-NEXT: target triple = "nvptx64-nvidia-cuda"

-; KERNEL: define ptx_kernel void @kernel_1(i8 addrspace(1)* %MemRef_B)
+; KERNEL: define ptx_kernel void
@kernel_params_only_some_arrays_%or.cond---%or.end9_kernel_1(i8
addrspace(1)* %MemRef_B)
 ; KERNEL-NEXT:   entry:
 ; KERNEL-NEXT:     %0 = call i32 @llvm.nvvm.read.ptx.sreg.ctaid.x()
 ; KERNEL-NEXT:     %b0 = zext i32 %0 to i64

I couldn't understand how "%" was actually a part of the name of a
function. The module was also passed to verifyModule here
<https://github.com/llvm-mirror/polly/blob/6b8cb877c2fa3ee0e626cac5811115a9c5c71b5b/lib/CodeGen/PPCGCodeGeneration.cpp#L1813>,
which puzzles me even more.

On Thu, Jun 22, 2017 at 8:07 PM 陳韋任 <chenwj.cs97g at g2.nctu.edu.tw> wrote:

> Produces the effect,
>> --- a/test/GPGPU/kernel-params-only-some-arrays.ll
>> <https://github.com/llvm-mirror/polly/blob/6b8cb877c2fa3ee0e626cac5811115a9c5c71b5b/test/GPGPU/kernel-params-only-some-arrays.ll#L19-L20>
>> +++ b/test/GPGPU/kernel-params-only-some-arrays.ll
>> @@ -16,12 +16,12 @@
>>  ;        B[i] += 42;
>>  ;    }
>>
>> -; KERNEL: ; ModuleID = 'kernel_0'
>> -; KERNEL-NEXT: source_filename = "kernel_0"
>> +; KERNEL: ; ModuleID =
>> 'kernel_params_only_some_arrays_%or.cond---%or.end9_kernel_0'
>> +; KERNEL-NEXT: source_filename =
>> "kernel_params_only_some_arrays_%or.cond---%or.end9_kernel_0"
>>
>> I don't understand how Module verification
>> <https://github.com/llvm-mirror/polly/blob/6b8cb877c2fa3ee0e626cac5811115a9c5c71b5b/lib/CodeGen/PPCGCodeGeneration.cpp#L1813>
>> was fine with this name. What are your thoughts ?
>>
>
> ​I think ModuleID and source_filename are just simple string, or they are
> not? I don't see any function name here.
>
> --
> Wei-Ren Chen (陳韋任)
> Homepage: https://people.cs.nctu.edu.tw/~chenwj
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170622/ef2660da/attachment.html>


More information about the llvm-dev mailing list