[LLVMdev] RFC: Replacing publicly accessible class IDs with getters

Duncan Sands baldrick at free.fr
Tue Feb 5 06:47:05 PST 2013


Hi Matthew,

> In the process of porting the Polly plug-in to Windows we encountered a couple
> of issues stemming from the use (within Polly) of global data from LLVM.
>
> By far the most common occurrence of this is the definition by a class of a
> publicly accessible static ID, the address of which is used to uniquely identify
> the class. For example
>
>     class AliasAnalysis {
>
>     public:
>        static char ID; // Class identification, replacement for typeinfo
>
>     };
>
>
> This turns out to be problematic on Windows for two reasons:
>
> 1) We found that Visual Studio actually defines two copies of the ID, one within
> the clang executable and another within the Polly library. This results in Polly
> being unable to identify LLVM passes. (This seems like a bug in Visual Studio,
> but we could not find a resolution other than changing LLVM as noted below).

this sounds like the kind of thing you get on linux if both clang and polly are
linked with the same LLVM libraries.  Are you sure it isn't something analogous
on windows?

> 2) We chose to use delay loading for symbols imported by Polly from clang. This
> allows the Polly dll to be loaded into any executable that provides the required
> symbols. However delay loading precludes the importing of data[1].
>
> We would like to resolve these issues by replacing public access of the ID with
> a getter:
>
>     class AliasAnalysis {
>
>     private:
>        static char ID; // Class identification, replacement for typeinfo
>
>     public:
>        static const void *getClassPassID();
>     };

That said, this looks pretty reasonable to me.

Ciao, Duncan.

>
>
> Thoughts?
>
> Matthew Curtis
>
> [1] http://msdn.microsoft.com/en-us/library/yx1x886y.aspx
>
>
>
> --
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
>
>
>
> _______________________________________________
> 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