[LLVMdev] Query about materializable functions and passes

Fraser Cormack fraser at codeplay.com
Fri Jan 23 06:26:17 PST 2015


Hi,

I know I'm a bit late to the table, but I've come across a problem with 
the new (mid-October last year) changes made to materializable functions.

When developing OpenCL and other on-line compilation models we often 
want to link in a large set of kernel library functions for use by the 
user program. There's so many of these functions that we don't want to 
run passes on them, as most of them will be discarded later in the 
compilation pipeline. This is where materializable functions came in 
handy. We could lazy-load the kernel library module and link it in to 
the user program, knowing only that declarations were being linked in 
for the time being, e.g:

; Materializable
; Function Attrs: nounwind readnone
declarespir_func i32 @_Z5mul24ii(i32 %s1, i32 %s2) #4

Then several passes would run that determined which functions were 
needed, and would materialize the function bodies. Once all the required 
functions were determined, we could strip the dead prototypes and 
continue on our way.

Now it seems that materializable functions are treated like empty 
function declarations:

; Materializable
; Function Attrs: nounwind readnone
define spir_func i32 @_Z5mul24ii(i32 %s1, i32 %s2) #4 {}

This means that if we keep them around in a module beyond passes that we 
control, a function pass will run and assert because the function 
doesn't contain basic blocks, or crash for some other reason.

Is there something that can be done about this? I know the changes were 
made for a reason (seems like it was LTO), but is there a way we can 
bring this functionality back in some form?

Cheers,
Fraser

-- 
Fraser Cormack
Compiler Developer
Codeplay Software Ltd
45 York Place, Edinburgh, EH1 3HP
Tel: 0131 466 0503
Fax: 0131 557 6600
Website: http://www.codeplay.com
Twitter: https://twitter.com/codeplaysoft

This email and any attachments may contain confidential and /or privileged information and  is for use  by the addressee only. If you are not the intended recipient, please notify Codeplay Software Ltd immediately and delete the message from your computer. You may not copy or forward it,or use or disclose its contents to any other person. Any views or other information in this message which do not relate to our business are not authorized by Codeplay software Ltd, nor does this message form part of any contract unless so stated.
As internet communications are capable of data corruption Codeplay Software Ltd does not accept any responsibility for any changes made to this message after it was sent. Please note that Codeplay Software Ltd does not accept any liability or responsibility for viruses and it is your responsibility to scan any attachments.
Company registered in England and Wales, number: 04567874
Registered office: 81 Linkfield Street, Redhill RH1 6BY




More information about the llvm-dev mailing list