This is an archive of the discontinued LLVM Phabricator instance.

Remove last Host usage from ArchSpec
ClosedPublic

Authored by labath on Nov 10 2017, 4:01 AM.

Details

Summary

In D39387, I was quick to jump to conclusion that ArchSpec has no
external dependencies. It turns there still was one call to
HostInfo::GetArchitecture left -- for implementing the "systemArch32"
architecture and friends.

Since GetAugmentedArchSpec is the place we handle these "incomplete"
triples that don't specify os or vendor and "systemArch" looks very much
like an incomplete triple, I move its handling there.

After this ArchSpec *really* does not have external dependencies, and
I'd like to move it to the Utility module as a follow-up.

Diff Detail

Repository
rL LLVM

Event Timeline

labath created this revision.Nov 10 2017, 4:01 AM
clayborg accepted this revision.Nov 10 2017, 11:10 AM
This revision is now accepted and ready to land.Nov 10 2017, 11:10 AM

I just saw Jim's email for this, Please comment in this bug so we can all see the info in one location. Accepting pending the outcome of the discussion that Jim start in email that I am pasting below:

I'm not sure we have enough instances to decide on better organization, but ArchSpec really doesn't feel like a Utility for lldb. That would be like moving the llvm triple handling to ADT, that seems a little weird. Similarly having the register stuff in Utility seems odd as well. I would never think to look for it there. Pavel asked me a while ago to talk a bit about what the strategy for the directories in lldb was originally and I started to answer and then got sidetracked by events and never answered.

The relevant historical bit for this discussion was originally the directory layout had nothing to do with building (Xcode doesn't care about files being in different directories, and we didn't envision building pieces of lldb separately at that point. I did it originally with the sole intent making an organization for people new to the code to find and remember where files were. We weren't super-rigorous about this - particularly as Xcode got better at finding files for you so finding them in directories was less important on our end. So for the purposes of reflecting code organization, we could probably stand another round of organization to make the structure more obvious. But I do think that's still a worthy goal.

Anyway, then just because of the way cmake works (or is used in llvm I don't actually know which) we've switch the meaning of the directories to "files that are built into a .a file". And then, because of the need to shrink the code size of lldb-server, it became important to make at least the lower-level stuff that lldb-server depended on independent of as much of the rest of lldb as possible. So it became important for at least some directories to contain "files that are built into .a files that don't depend on some/most of the other .a files." That's introduced a somewhat orthogonal design principle for the directory layout.

Note, Greg and I used to argue about the strategy for lldb-server. My notion was on modern systems the actual file size difference between an lldb-server that used all of lldb.framework, and one that could use a cut down library was really not all that important. If you're making a stub for an hard embedded system, you probably aren't going to use lldb-server, you'll use a much smaller gdb-protocol stub, and we didn't really have the intent to provide that functionality. So lldb server as intended for things like phones etc, where "small" means small in modern terms, not "a kilobyte matters" type small.

I always felt the appropriate discipline to impose was making sure that if you didn't use something in lldb (symbols for instance) you don't pay memory/time cost for it. If that was true, and the bigger size was not an issue, than having lldb-server built with the full lldb.framework would mean that you would have flexibility to move work from the host to the lldb-server end of a remote debugging session, which could be really convenient since you could offload work to the remote end w/o having to come back over the slower remote communication channel. We never really convinced on another either way and since he directed most of the development of lldb-server on our end, he won by dint of implementation. But that's why for me the breakup of LLDB.framework into independent pieces was never a particularly present goal.

Any, that's water under the bridge at this point. But I'd also like not to lose the benefit of comprehension that was the original reason for the directory layout. And in this instance, ArchSpec really doesn't seem like a Utility, which brought this back up in my thinking. There doesn't seem a critical mass of files in Utility to make decisions at this point, but as we break up Core, it might be nice to have a place for things that aren't Support or ADT type stuff, but more the core business of a debugger, but also don't drag in Symbol and other parts of lldb that aren't appropriate for lldb-server.

Jim

zturner edited edge metadata.Nov 10 2017, 11:25 AM

I'd be open to having another organizational component that isn't Utility. But as Jim said, there isn't a critical mass of stuff yet in Utility to figure out where it makes sense to draw the line.

In all honesty, that second component might just end up being "Core" again, if enough stuff can be moved out of Core that it doesn't have to depend on Symbol, Host, Interpreter, Breakpoint, etc.

BTW, I'm curious why you say that having Triple in llvm/ADT would be confusing. Isn't that where it already is? Or are you saying it's already confusing?

There's been some discussion on the LLVM side recently about how Support is just a catch-all for random stuff that doesn't really belong anywhere else, and there seems to be general support for separating some things out. I actually made a small effort towards that end several months ago, when I took all of the object file format stuff out of Support and made a new target called BinaryFormat out of it. But, it was easy to see what the best way to do that was because there was already a critical mass of stuff there, so it was easy to identify a logical grouping that could be separated.

jingham edited edge metadata.Nov 10 2017, 12:09 PM

Yes, my intention was not to gate this patch on figuring out the right role for Utility/Core/Whatever. It just seemed an apropos moment to bring this up.

You're right, the Triple stuff is in ADT! I was using it as an example of something you clearly wouldn't do so I didn't actually check to see if it was done. That's pretty funny.

I thought that ADT stood for Abstract Data Types - though I actually I don't remember where I got that impression... Having Triple there does seem confusing. That is a "how we specify Targets type thing", not a fancy data type type thing... I would never think to look for that facility alongside StringRef & DenseMap etc.

Drive by comment:

You're right, the Triple stuff is in ADT! I was using it as an example of something you clearly wouldn't do so I didn't actually check to see if it was done. That's pretty funny.

I thought that ADT stood for Abstract Data Types - though I actually I don't remember where I got that impression... Having Triple there does seem confusing. That is a "how we specify Targets type thing", not a fancy data type type thing... I would never think to look for that facility alongside StringRef & DenseMap etc.

Triple.h is in ADT; Triple.cpp is in Support. I agree it belongs in Support, and I'm not sure why it's schizo like that.

Drive by comment:

You're right, the Triple stuff is in ADT! I was using it as an example of something you clearly wouldn't do so I didn't actually check to see if it was done. That's pretty funny.

I thought that ADT stood for Abstract Data Types - though I actually I don't remember where I got that impression... Having Triple there does seem confusing. That is a "how we specify Targets type thing", not a fancy data type type thing... I would never think to look for that facility alongside StringRef & DenseMap etc.

Triple.h is in ADT; Triple.cpp is in Support. I agree it belongs in Support, and I'm not sure why it's schizo like that.

Ok now that's just crazy. You're making me want to go fix this...

If I understand correctly, everyone agrees with this change, so I will commit it soon(ish). Below are my thoughs on some of the things said in this thread.

@zturner wrote:

Super awesome. When you do move it to Utility, can you run the deps python script to see if any cmake dependencies can be updated?

The only change necessary was to *add* Utility as a dependency of the ArchitectureArm plugin, which did not depend (directly) on Utility before this.

Drive by comment:

Triple.h is in ADT; Triple.cpp is in Support. I agree it belongs in Support, and I'm not sure why it's schizo like that.

That's because there is no llvm/lib/ADT, and there couldn't be one in the present form because of all the mutual dependencies between ADT and Support headers. So all of the ADT cpp files live in Support, but it's not so glaringly obvious as most of ADT is header-only. Triple is one of few headers that actually has a cpp file. (That said, I can see some reasoning behind it being in ADT, but I do think it would look better in Support.)

Note, Greg and I used to argue about the strategy for lldb-server. My notion was on modern systems the actual file size difference between an lldb-server that used all of lldb.framework, and one that could use a cut down library was really not all that important. If you're making a stub for an hard embedded system, you probably aren't going to use lldb-server, you'll use a much smaller gdb-protocol stub, and we didn't really have the intent to provide that functionality. So lldb server as intended for things like phones etc, where "small" means small in modern terms, not "a kilobyte matters" type small.

In our distribution model, we copy the lldb-server to the phone the first time you start a debug session, so size is still important to us (we're not counting every kilobyte, but a megabyte more or less matters). liblldb is currently ~61 MB, while lldb-server (x86_64) is 9.6 (less, when you compile with -Os). Initially, the two numbers were nearly equal. Right now we're mostly happy with the size (although we wouldn't mind it being smaller), so size is not my primary motivation here.

I'd be open to having another organizational component that isn't Utility. But as Jim said, there isn't a critical mass of stuff yet in Utility to figure out where it makes sense to draw the line.

In all honesty, that second component might just end up being "Core" again, if enough stuff can be moved out of Core that it doesn't have to depend on Symbol, Host, Interpreter, Breakpoint, etc.

I agree. At one point in not too distant future we will need to sit down and figure out how to split up Utility (otherwise, the layering problem can be vacuously "solved" by moving everything into a single layer). I don't think it will be easy though, as there is a natural tendency for the lowest layers of anything to become a collection of random unrelated tidbits (which is what happened to llvm support).

My ideas for the next steps are roughly as follows:

  • move ProcessInfo class and friends to Utility or Host. This is so that the "get me the list of processes on this machine" functionality can work without including Process.h
  • move the symbol-finding code from Host to Platform -- most of this is not host- but target-specific. E.g. the linux way of finding symbols could easily work for remote debugging from other OSes, if you had a suitable sysroot copied or network-mounted.
  • move RegisterValue to Utility -- useful in lldb-server, unlike a lot of the stuff in Core.
This revision was automatically updated to reflect the committed changes.