This is an archive of the discontinued LLVM Phabricator instance.

[clang] Remove Address::deprecated from MveEmitter
ClosedPublic

Authored by aeubanks on Mar 18 2022, 4:03 PM.

Details

Summary

We have to keep track of pointer pointee types with opaque pointers.

Diff Detail

Event Timeline

aeubanks created this revision.Mar 18 2022, 4:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 18 2022, 4:03 PM
Herald added a subscriber: dmgreen. · View Herald Transcript
aeubanks requested review of this revision.Mar 18 2022, 4:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 18 2022, 4:03 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
aeubanks added reviewers: dmgreen, Restricted Project.Mar 18 2022, 4:03 PM

I'm very out of my depth with tablegen, let me know if there's a more elegant way of doing this

nikic added a subscriber: nikic.Mar 20 2022, 2:05 PM
nikic added inline comments.
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)

simon_tatham accepted this revision.Mar 21 2022, 2:33 AM

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.

This revision is now accepted and ready to land.Mar 21 2022, 2:33 AM
dblaikie added inline comments.
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?

simon_tatham added inline comments.Mar 21 2022, 7:59 AM
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.)

aeubanks updated this revision to Diff 416989.Mar 21 2022, 9:28 AM

fix dyn_cast

aeubanks added inline comments.Mar 21 2022, 9:39 AM
clang/utils/TableGen/MveEmitter.cpp
1197

the parentheses were confusing, fixed

This revision was landed with ongoing or failed builds.Mar 21 2022, 9:39 AM
This revision was automatically updated to reflect the committed changes.
dblaikie added inline comments.Mar 21 2022, 9:49 AM
clang/utils/TableGen/MveEmitter.cpp
1197

oh, right, thanks @simon_tatham - sorry, didn't catch that.