Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attribute vector_size doesn't allow value dependent expressions in templates #17360

Closed
llvmbot opened this issue Aug 24, 2013 · 6 comments
Closed
Labels
bugzilla Issues migrated from bugzilla c++ C++ language related issues duplicate Resolved as "DUPLICATE"

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 24, 2013

Bugzilla Link 16986
Resolution DUPLICATE
Resolved on Aug 05, 2020 03:39
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@zygoloid,@yuyichao

Extended Description

template
union point
{
T vec attribute((vector_size((sizeof(T)<<1))));
struct { T x,y; };
};

error: 'vector_size' attribute requires an integer constant
T vec attribute((vector_size((sizeof(T)<<1))));
^ ~~~~~~~~~~~~~~

@zygoloid
Copy link
Mannequin

zygoloid mannequin commented Aug 26, 2013

We should generalize the handling of dependent expressions from the alignment attributes to deal with this case too.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Nov 16, 2014

I hit the same issue.

typedef double attribute( ( vector_size( 64 ) ) ) float64x8_v0_t;
typedef double attribute( ( vector_size( 32 * 2 ) ) ) float64x8_v1_t;
typedef double attribute( ( vector_size( sizeof(double) * 8 ) ) ) float64x8_v2_t;

template<typename T, int N>
struct Traits {
typedef T attribute( ( vector_size( N*sizeof(T) ) ) ) type; // the following fails
};

test.cc:13:30: error: 'vector_size' attribute requires an integer constant
typedef T attribute( ( vector_size( N*sizeof(T) ) ) ) type;

Any updates?

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jun 15, 2015

We should generalize the handling of dependent expressions from the
alignment attributes to deal with this case too.

Richard, as far as I know, alignment attributes only appertain to variables or typedefs (which both have AST nodes). I don't think we can generalize this approach for vector_size attribute as it appertains to types (which do not have AST nodes).
What about creating a new property for VectorType that would state that this vector type is dependent (dependent vector types are vector types with dependent base types and/or dependent size expressions)? It seems to be somewhat more appropriate to me.
What do you think?

@yuyichao
Copy link
Contributor

This seems to be fixed on 7.0 ?

I can still reproduce the issue with both versions above on a clang 6.0.0 from a Ubuntu 18.04.2 but I don't have this issue anymore on a clang 7.0.1 from an up to date ArchLinux.

@yuyichao
Copy link
Contributor

And as a workaround on older version. The solution from https://stackoverflow.com/a/48377726/904262 seems to work if you can use a typedef. The resulting vector type seems to have the correct layout and C++ name mangling so I assume it's the correct type...

@llvmbot
Copy link
Collaborator Author

llvmbot commented Aug 5, 2020

*** This bug has been marked as a duplicate of bug #16102 ***

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++ C++ language related issues duplicate Resolved as "DUPLICATE"
Projects
None yet
Development

No branches or pull requests

2 participants