This is an archive of the discontinued LLVM Phabricator instance.

Thread ExecutionContextScope through GetByteSize where possible (NFC-ish)
ClosedPublic

Authored by aprantl on Jul 21 2020, 1:24 PM.

Details

Summary

This patch has no effect for C and C++. In more dynamic languages, such as Objective-C and Swift GetByteSize() needs to call into the language runtime, so it's important to pass one in where possible. My primary motivation for this is some work I'm doing on the Swift branch, however, it looks like we are also seeing warnings in Objective-C that this may resolve.
Everything in the SymbolFile hierarchy still passes in nullptrs, because we don't have an execution context in SymbolFile, since SymbolFile transcends processes.

Diff Detail

Event Timeline

aprantl created this revision.Jul 21 2020, 1:24 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 21 2020, 1:25 PM
shafik added inline comments.Jul 21 2020, 2:05 PM
lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
461

Above you use &thread in return_compiler_type.GetByteSize(&thread) ... why do both of these work?

shafik added inline comments.Jul 21 2020, 2:12 PM
lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
308

Is this equivalent to what was being done previously or is this better in some way?

teemperor added inline comments.
lldb/source/Plugins/ABI/ARC/ABISysV_arc.cpp
461

This doesn't compile (but ARC isn't a default target, so probably no one compiled that code).

teemperor added inline comments.Jul 21 2020, 2:28 PM
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
4092

So we already have this dubious stride extra-output here, but now it also requires us to have an execution context parameter. I think we might as well just remove that parameter (in a separate patch).

aprantl updated this revision to Diff 279634.Jul 21 2020, 2:46 PM

Fix &Thread copy&paste errors. Good catch!

aprantl marked 2 inline comments as done.Jul 21 2020, 2:47 PM
aprantl marked 3 inline comments as done.Jul 21 2020, 2:51 PM
aprantl added inline comments.
lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
308

The old code took a TargetSP, wrapped it in an ExecutionContext, and then called GetBestExecutionContextScope(), which returns the Target *. (Target inherits from ExecutionContextScope)

So the new code does exactly the same thing as the old code but it's much shorter.

lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
4092

Are you saying no one uses stride?

Not even a future Fortran lldb Plugin?

The patch lost seems to have lost everything but the PPC, SystemZ and MIPS code...

aprantl updated this revision to Diff 279660.Jul 21 2020, 4:24 PM
aprantl marked an inline comment as done.

Upload the *entire* patch m(

I pointed out a couple of places where you have either at hand or near at hand a useful exe_ctx that you could pass instead of nullptr.

Other than that, this seems good to me. Thanks for pushing this through.

lldb/source/API/SBType.cpp
210

This changes makes it obvious we should add

SBType::GetByteSize(SBExecutionContext &exe_ctx)
SBType::GetArrayElementType(SBExecutionContext &exe_ctx)

but I don't think you need to do that in this patch.

lldb/source/Commands/CommandObjectTarget.cpp
1655

LookupTypeInModule is called by LookupInModule which is only ever called when we have a target on hand. Maybe it would be better to thread the target through so we can get better type descriptions if the target has a live process? Or make it a member function of CommandObjectTargetModulesLookup and it could use m_exe_ctx. It doesn't seem to be gaining anything by being a stand-alone function.

1700–1701

Ditto with this one. Our only caller (the method called LookupTypeHere) definitely had a better ExecutionContextScope (from m_exe_ctx). Be nice to pass it in here.

lldb/source/DataFormatters/FormatManager.cpp
240

We have the ValueObject we are working on in this scope. ValueObjects always have an ExecutionContextRef (GetExecutionContextRef) so you can pass in a better ExecutionContextScope here.

aprantl updated this revision to Diff 279670.Jul 21 2020, 5:17 PM

Add another PPC syntax failure.

aprantl updated this revision to Diff 279675.Jul 21 2020, 5:30 PM
aprantl marked 6 inline comments as done.

Added missed opportunities pointed out by Jim!

jingham accepted this revision.Jul 21 2020, 8:03 PM

I think you missed two more places to pass a target, then this looks good to me. How tedious, thanks for doing it...

lldb/source/Commands/CommandObjectTarget.cpp
1665

You should be able to use the same target here that you did just above, right?

1709–1710

Here too.

This revision is now accepted and ready to land.Jul 21 2020, 8:03 PM
This revision was automatically updated to reflect the committed changes.
aprantl marked an inline comment as done.