-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Make result variables obey their dynamic values in subsequent expressions #168611
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
Open
jimingham
wants to merge
3
commits into
llvm:main
Choose a base branch
from
jimingham:result-val-dyn-type
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+387
−51
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -65,7 +65,7 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager, | |||||||||||||||||||
| ExecutionContext &exe_ctx, | ||||||||||||||||||||
| const EvaluateExpressionOptions &options, | ||||||||||||||||||||
| lldb::UserExpressionSP &shared_ptr_to_me, | ||||||||||||||||||||
| lldb::ExpressionVariableSP &result) { | ||||||||||||||||||||
| lldb::ExpressionVariableSP &result_sp) { | ||||||||||||||||||||
| // The expression log is quite verbose, and if you're just tracking the | ||||||||||||||||||||
| // execution of the expression, it's quite convenient to have these logs come | ||||||||||||||||||||
| // out with the STEP log as well. | ||||||||||||||||||||
|
|
@@ -250,8 +250,14 @@ LLVMUserExpression::DoExecute(DiagnosticManager &diagnostic_manager, | |||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (FinalizeJITExecution(diagnostic_manager, exe_ctx, result, | ||||||||||||||||||||
| if (FinalizeJITExecution(diagnostic_manager, exe_ctx, result_sp, | ||||||||||||||||||||
| function_stack_bottom, function_stack_top)) { | ||||||||||||||||||||
| // if (result_sp) { | ||||||||||||||||||||
| // // This is a bit of a hack, replace with a real API. Trying to | ||||||||||||||||||||
| // force | ||||||||||||||||||||
| // // fetching all the dynamic info at this point. | ||||||||||||||||||||
| // result_sp->GetValueObject(); | ||||||||||||||||||||
| // } | ||||||||||||||||||||
| return lldb::eExpressionCompleted; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -289,8 +295,14 @@ bool LLVMUserExpression::FinalizeJITExecution( | |||||||||||||||||||
| result = | ||||||||||||||||||||
| GetResultAfterDematerialization(exe_ctx.GetBestExecutionContextScope()); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if (result) | ||||||||||||||||||||
| if (result) { | ||||||||||||||||||||
| EvaluateExpressionOptions *options = GetOptions(); | ||||||||||||||||||||
| // TransferAddress also does the offset_to_top calculation, so record the | ||||||||||||||||||||
| // dynamic option before we do that. | ||||||||||||||||||||
| if (options) | ||||||||||||||||||||
| result->PreserveDynamicOption(options->GetUseDynamic()); | ||||||||||||||||||||
|
Comment on lines
+299
to
+303
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||
| result->TransferAddress(); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| m_dematerializer_sp.reset(); | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -76,10 +76,11 @@ class EntityPersistentVariable : public Materializer::Entity { | |||||
|
|
||||||
| const bool zero_memory = false; | ||||||
| IRMemoryMap::AllocationPolicy used_policy; | ||||||
| auto address_or_error = map.Malloc( | ||||||
| uint64_t malloc_size = | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| llvm::expectedToOptional(m_persistent_variable_sp->GetByteSize()) | ||||||
| .value_or(0), | ||||||
| 8, lldb::ePermissionsReadable | lldb::ePermissionsWritable, | ||||||
| .value_or(0); | ||||||
| auto address_or_error = map.Malloc( | ||||||
| malloc_size, 8, lldb::ePermissionsReadable | lldb::ePermissionsWritable, | ||||||
| IRMemoryMap::eAllocationPolicyMirror, zero_memory, &used_policy); | ||||||
| if (!address_or_error) { | ||||||
| err = Status::FromErrorStringWithFormat( | ||||||
|
|
@@ -90,8 +91,9 @@ class EntityPersistentVariable : public Materializer::Entity { | |||||
| } | ||||||
| lldb::addr_t mem = *address_or_error; | ||||||
|
|
||||||
| LLDB_LOGF(log, "Allocated %s (0x%" PRIx64 ") successfully", | ||||||
| m_persistent_variable_sp->GetName().GetCString(), mem); | ||||||
| LLDB_LOGF( | ||||||
| log, "Allocated 0x%" PRIx64 "bytes for %s (0x%" PRIx64 ") successfully", | ||||||
| malloc_size, m_persistent_variable_sp->GetName().GetCString(), mem); | ||||||
|
|
||||||
| // Put the location of the spare memory into the live data of the | ||||||
| // ValueObject. | ||||||
|
|
@@ -143,12 +145,12 @@ class EntityPersistentVariable : public Materializer::Entity { | |||||
| void DestroyAllocation(IRMemoryMap &map, Status &err) { | ||||||
| Status deallocate_error; | ||||||
|
|
||||||
| map.Free((lldb::addr_t)m_persistent_variable_sp->m_live_sp->GetValue() | ||||||
| .GetScalar() | ||||||
| .ULongLong(), | ||||||
| lldb::ValueObjectSP live_valobj_sp = | ||||||
| m_persistent_variable_sp->GetLiveObject(); | ||||||
| map.Free((lldb::addr_t)live_valobj_sp->GetValue().GetScalar().ULongLong(), | ||||||
| deallocate_error); | ||||||
|
|
||||||
| m_persistent_variable_sp->m_live_sp.reset(); | ||||||
| live_valobj_sp.reset(); | ||||||
|
|
||||||
| if (!deallocate_error.Success()) { | ||||||
| err = Status::FromErrorStringWithFormat( | ||||||
|
|
@@ -183,17 +185,17 @@ class EntityPersistentVariable : public Materializer::Entity { | |||||
| return; | ||||||
| } | ||||||
|
|
||||||
| lldb::ValueObjectSP live_valobj_sp = | ||||||
| m_persistent_variable_sp->GetLiveObject(); | ||||||
| if ((m_persistent_variable_sp->m_flags & | ||||||
| ExpressionVariable::EVIsProgramReference && | ||||||
| m_persistent_variable_sp->m_live_sp) || | ||||||
| live_valobj_sp) || | ||||||
| m_persistent_variable_sp->m_flags & | ||||||
| ExpressionVariable::EVIsLLDBAllocated) { | ||||||
| Status write_error; | ||||||
|
|
||||||
| map.WriteScalarToMemory( | ||||||
| load_addr, | ||||||
| m_persistent_variable_sp->m_live_sp->GetValue().GetScalar(), | ||||||
| map.GetAddressByteSize(), write_error); | ||||||
| map.WriteScalarToMemory(load_addr, live_valobj_sp->GetValue().GetScalar(), | ||||||
| map.GetAddressByteSize(), write_error); | ||||||
|
|
||||||
| if (!write_error.Success()) { | ||||||
| err = Status::FromErrorStringWithFormat( | ||||||
|
|
@@ -229,13 +231,15 @@ class EntityPersistentVariable : public Materializer::Entity { | |||||
| m_delegate->DidDematerialize(m_persistent_variable_sp); | ||||||
| } | ||||||
|
|
||||||
| lldb::ValueObjectSP live_valobj_sp = | ||||||
| m_persistent_variable_sp->GetLiveObject(); | ||||||
| if ((m_persistent_variable_sp->m_flags & | ||||||
| ExpressionVariable::EVIsLLDBAllocated) || | ||||||
| (m_persistent_variable_sp->m_flags & | ||||||
| ExpressionVariable::EVIsProgramReference)) { | ||||||
| if (m_persistent_variable_sp->m_flags & | ||||||
| ExpressionVariable::EVIsProgramReference && | ||||||
| !m_persistent_variable_sp->m_live_sp) { | ||||||
| !live_valobj_sp) { | ||||||
| // If the reference comes from the program, then the | ||||||
| // ClangExpressionVariable's live variable data hasn't been set up yet. | ||||||
| // Do this now. | ||||||
|
|
@@ -255,7 +259,7 @@ class EntityPersistentVariable : public Materializer::Entity { | |||||
|
|
||||||
| m_persistent_variable_sp->m_live_sp = ValueObjectConstResult::Create( | ||||||
| map.GetBestExecutionContextScope(), | ||||||
| m_persistent_variable_sp.get()->GetCompilerType(), | ||||||
| m_persistent_variable_sp->GetCompilerType(), | ||||||
| m_persistent_variable_sp->GetName(), location, eAddressTypeLoad, | ||||||
| llvm::expectedToOptional(m_persistent_variable_sp->GetByteSize()) | ||||||
| .value_or(0)); | ||||||
|
|
@@ -277,19 +281,17 @@ class EntityPersistentVariable : public Materializer::Entity { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| lldb::addr_t mem = m_persistent_variable_sp->m_live_sp->GetValue() | ||||||
| .GetScalar() | ||||||
| .ULongLong(); | ||||||
|
|
||||||
| if (!m_persistent_variable_sp->m_live_sp) { | ||||||
| if (!live_valobj_sp) { | ||||||
| err = Status::FromErrorStringWithFormat( | ||||||
| "couldn't find the memory area used to store %s", | ||||||
| m_persistent_variable_sp->GetName().GetCString()); | ||||||
| return; | ||||||
| } | ||||||
|
|
||||||
| if (m_persistent_variable_sp->m_live_sp->GetValue() | ||||||
| .GetValueAddressType() != eAddressTypeLoad) { | ||||||
| lldb::addr_t mem = live_valobj_sp->GetValue().GetScalar().ULongLong(); | ||||||
|
|
||||||
| if (live_valobj_sp->GetValue().GetValueAddressType() != | ||||||
| eAddressTypeLoad) { | ||||||
| err = Status::FromErrorStringWithFormat( | ||||||
| "the address of the memory area for %s is in an incorrect format", | ||||||
| m_persistent_variable_sp->GetName().GetCString()); | ||||||
|
|
@@ -326,7 +328,6 @@ class EntityPersistentVariable : public Materializer::Entity { | |||||
| read_error.AsCString()); | ||||||
| return; | ||||||
| } | ||||||
|
|
||||||
| m_persistent_variable_sp->m_flags &= | ||||||
| ~ExpressionVariable::EVNeedsFreezeDry; | ||||||
| } | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| CXX_SOURCES := two-bases.cpp | ||
|
|
||
| include Makefile.rules |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to comment this out?