We have to keep track of pointer pointee types with opaque pointers.
Details
- Reviewers
dmgreen simon_tatham - Group Reviewers
Restricted Project - Commits
- rGb0270f6e9583: [clang] Remove Address::deprecated from MveEmitter
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I'm very out of my depth with tablegen, let me know if there's a more elegant way of doing this
clang/utils/TableGen/MveEmitter.cpp | ||
---|---|---|
1197 | Should be either cast or check for nullptr before dereferencing? |
I'm very out of my depth with tablegen, let me know if there's a more elegant way of doing this
I think this sounds OK. Providing all the tests pass it looks OK (but I'm not a big expert myself)
Whereas I'm familiar with this code but not with the opaque-pointers effort, so I had to look up the other half of what was going on :-)
If I've understood this correctly, the point is that we should no longer be looking inside a pointer-typed llvm::Value to find out its pointee type, because at some point in the future it will stop storing one at all? And therefore the codegen layer above, if it wants to know the pointee type for a Value it's already made, has to take responsibility for remembering it itself from the point where the Value was constructed.
This seems fine to me, and the uses of address in the actual arm_mve.td don't look as if they're likely to cause trouble with this.
clang/utils/TableGen/MveEmitter.cpp | ||
---|---|---|
1197 | Not sure I follow the question - which variable are you pointing to that needs a null check before its use? |
clang/utils/TableGen/MveEmitter.cpp | ||
---|---|---|
1197 | Oh yes, good point, I see it. dyn_cast<DagInit>(D->getArg(0)) might return nullptr, because the point of dyn_cast is that the thing you're casting might not have the right type. So you should check the return from dyn_cast before you dereference it to call its getOperator method. (Alternatively, as @nikic hints, if you think that in this case the cast cannot fail, then you can change it to a straight cast which doesn't do the runtime check.) |
clang/utils/TableGen/MveEmitter.cpp | ||
---|---|---|
1197 | the parentheses were confusing, fixed |
clang/utils/TableGen/MveEmitter.cpp | ||
---|---|---|
1197 | oh, right, thanks @simon_tatham - sorry, didn't catch that. |
Should be either cast or check for nullptr before dereferencing?