[LLVMdev] SPIR Portability Discussion

Nadav Rotem nrotem at apple.com
Wed Sep 12 14:16:32 PDT 2012


> 
> OpenCL 1.2 (6.3)/k says the result of sizeof is an ICE. So these are valid:
> 
> int does_this_compile[sizeof(void*) - 3];
> 
> struct how_do_you_represent_this_in_IR {
>   int a : 1;
>   int b : sizeof(void*) * 4;
> };
> 
> Is OpenCL going to be changed to reject these cases?
> 

I don't think that they plan to allow it. I am not sure how much value dynamic sized bitfields bring to OpenCL users. 
In theory they could use opaque types and a number of external functions which can be lowered to legal LLVM-IR once the value of sizeof is known. 

> How do you perform record layout if the size of a pointer is unknown? For instance:
> 
> struct A {
>   int *p;
>   int n;
> } a;
> int arr[offsetof(A, n) - 3]; // or, int arr[(char*)&a.n - (char*)&a.p - 3];
> 

They can replace LLVM's alloca with a fake function which can be lowered to a regular alloca once the size is known. 

> -- Richard
> _______________________________________________
> 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