[polly] r256650 - IslExprBuilder: Provide PointerLikeTypeTraits for isl_id

Chandler Carruth via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 30 13:17:56 PST 2015


On Wed, Dec 30, 2015 at 12:15 PM Tobias Grosser via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: grosser
> Date: Wed Dec 30 14:11:48 2015
> New Revision: 256650
>
> URL: http://llvm.org/viewvc/llvm-project?rev=256650&view=rev
> Log:
> IslExprBuilder: Provide PointerLikeTypeTraits for isl_id
>
> Providing an explicit PointerLikeTypeTraits implementation became necessary
> since LLVM started in https://llvm.org/svn/llvm-project/llvm/trunk@256620
> to automatically derive the pointer alignment from the pointer element
> type,
> which does not work for incomplete types as used by isl. To ensure our code
> still compiles, we provide an instantiation of PointerLikeTypeTraits for
> isl_id
> which assumes no minimal alignment. isl pointers are likely to have a
> "higher"
> alignment. We can exploit this later in case this becomes performance
> relevant.
>
> Modified:
>     polly/trunk/include/polly/CodeGen/IslExprBuilder.h
>
> Modified: polly/trunk/include/polly/CodeGen/IslExprBuilder.h
> URL:
> http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/IslExprBuilder.h?rev=256650&r1=256649&r2=256650&view=diff
>
> ==============================================================================
> --- polly/trunk/include/polly/CodeGen/IslExprBuilder.h (original)
> +++ polly/trunk/include/polly/CodeGen/IslExprBuilder.h Wed Dec 30 14:11:48
> 2015
> @@ -23,6 +23,21 @@ class DataLayout;
>  class ScalarEvolution;
>  }
>
> +struct isl_id;
> +
> +namespace llvm {
> +// Provide PointerLikeTypeTraits for isl_id.
> +template <> class PointerLikeTypeTraits<isl_id *> {
>

Unfortunately, this almost guarantees an ODR violation if anyone ever
causes an instantiation of the primary template without having included
this header.

Why does isl_id need to remain incomplete here?

If it truly needs to be opaque, I would suggest changing whatever data
structure to explicitly operate on void* which we provide a generic
template for which assumes at least 4-byte alignment. This template is
intended precisely for the cases where the types of the pointers change,
aren't possibly known ahead of time, etc., and the code actually must erase
the type and make generic assumptions.

I find using void* to do this somewhat more transparent. What do you think?

-Chandler


> +
> +public:
> +  static inline const void *getAsVoidPointer(isl_id *P) { return (void
> *)P; }
> +  static inline const Region *getFromVoidPointer(void *P) {
> +    return (Region *)P;
> +  }
> +  enum { NumLowBitsAvailable = 0 };
> +};
> +}
> +
>  namespace polly {
>
>  /// @brief LLVM-IR generator for isl_ast_expr[essions]
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151230/3e9edd0f/attachment.html>


More information about the llvm-commits mailing list