[LLVMdev] Example for usage of LLVM/Clang/libclc

mats petersson mats at planetcatfish.com
Sat Feb 7 02:19:59 PST 2015


So the problem is really how the builtins.opt.bc is produced - it is
one large file with all the functions, and the compiler is really just
doing what you tell it to. It would work better if the process did
what the normal linking of normal libraries does, which is to resolve
only those symbols required from the library. But I don't believe that
is available here, because bitcode files don't contain the relevant
information to "split it apart" (or the "linker" part doesn't know how
to use such information).

--
Mats

On 7 February 2015 at 00:05, Ahmed ElTantawy <ahmede at ece.ubc.ca> wrote:
> Thanks a lot for both your answers:
>
> @mats:
>> Would it not just be a matter of removing
>> -Xclang -mlink-bitcode-file -Xclang nvptx--nvidiacl/lib/builtins.opt.bc
>> from your command? The seems to be the part that links in builtin
>> functions..
>
> I can not do this as in the code I am using some of these builtin functions
> but not "all" of them. Currently what happens is that all of them get
> translated to LLVM-IR, even those I don't use. I can manually include only
> those I am interested in for a specific kernel, but that will not be neat
> solution.
>
> @Dan:
>
>> Mark all functions apart from the kernel entry points with the internal
>> attribute and then run global dead code elimination (it should remove most
>> of the unused functions).
>> You can use the opt tool to do this.
>> e.g. if you had kernel entry points foo and bar you could run the
>> following
>> $ opt -internalize-public-api-list= foo,bar -globaldce your_program.bc
>> transformed_program.bc
>
> That would probably help, but I was aiming for a solution that doesn't
> involve knowing the name of kernel entry points, but I can definitely write
> a small script that would figure out the kernel entry points for me.
>
>
>
> On Thu, Feb 5, 2015 at 6:41 AM, mats petersson <mats at planetcatfish.com>
> wrote:
>>
>> So, another "department for ignorance and stupid comments" comment:
>>
>> Would it not just be a matter of removing
>> -Xclang -mlink-bitcode-file -Xclang nvptx--nvidiacl/lib/builtins.opt.bc
>> from your command? The seems to be the part that links in builtin
>> functions..
>>
>> On 5 February 2015 at 13:50, Dan Liew <dan at su-root.co.uk> wrote:
>> > Hi,
>> >
>> >> which works but it produces LLVM IR code for all OpenCL intrinsics
>> >> implemented by libclc along with the kernel I am interested in, is
>> >> their a
>> >> possibility to avoid this ? and only produce the llvm code for the
>> >> kernel
>> >> required ?
>> >
>> > Mark all functions apart from the kernel entry points with the
>> > internal attribute and then run global dead code elimination (it
>> > should remove most of the unused functions).
>> >
>> > You can use the opt tool to do this.
>> >
>> > e.g. if you had kernel entry points foo and bar you could run the
>> > following
>> >
>> > $ opt -internalize-public-api-list=foo,bar -globaldce your_program.bc
>> >> transformed_program.bc
>> >
>> > Hope that helps.
>> > _______________________________________________
>> > LLVM Developers mailing list
>> > LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>



More information about the llvm-dev mailing list