Skip to content

Fix MCCAS after changed made to MC layer upstream #11184

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
wants to merge 22 commits into
base: next
Choose a base branch
from

Conversation

rastogishubham
Copy link

The MC layer has gone through many changes, which affect MCCAS, especially the changes made to MCFragments.

This PR addresses them all

rdar://156159206

The MCPseudoProbeAddrFragment type has been removed as a type of
fragment and has been merged with the MCLEBFragment.
…class

The MCSection class has been refactored to no longer have
printSwitchToSection, and useCodeAlign function. It also no longer can
contain a classof function. This change removes these functions to make
it compile properly again.
The create function in the MCFRAGMENT_NODE_REF macro has to take an
MCFragment object because of the changes in MCFragment which removed
the concept that different fragment types would have their own class.
The MCAlignFragment class has been removed from MCSection.h and the
Align Fragment is now part of the MCFragment class.

The Align fragment has also been significantly changed. In the past, the
Align fragment would only contain alignment data, however, now it can
also contain regular data as well (similar to an MCDataFragment, but
with alignment data as well). This patch makes the necessary changes to
make MCCAS work properly with the new MCAlignFragment.
Since the create function in MCFRAGMENT_NODE_REF just takes an
MCFragment object as an argument, this change just makes the change for
MCBoundaryAlignFragmentRef::create.
Since the create function in MCFRAGMENT_NODE_REF just takes an
MCFragment object as an argument, this change just makes the change for
MCCVInlineLineTableFragmentRef::create.
Since the create function in MCFRAGMENT_NODE_REF just takes an
MCFragment object as an argument, this change just makes the necessary
changes for MCFillFragmentRef::create.
Since the create function in MCFRAGMENT_NODE_REF just takes an
MCFragment object as an argument, this change just makes the change for
MCLEBFragmentRef::create.
Since the create function in MCFRAGMENT_NODE_REF just takes an
MCFragment object as an argument, this change just makes the necessary
changes for MCNopsFragmentRef::create.
Since the create function in MCFRAGMENT_NODE_REF just takes an
MCFragment object as an argument, this change just makes the necessary
changes for MCOrgFragmentRef::create.
Since the create function in MCFRAGMENT_NODE_REF just takes an
MCFragment object as an argument, this change just makes the necessary
changes for MCSymbolIdFragmentRef::create.
The MCFragments have been changed, they can now have both a fixed
content and a variable content as well. This patch makes the necessary
changes to the getFragmentContents() function to make it work properly.
MCCASBuilder::mergeMCFragmentContents merges all content from all
the fragments in a section into one buffer. However, since the way
content is stored in a fragemnts has changed, this function had to be
updated as well.
There is no concept on an EncodedFragment anymore, hence we have to list
all fragments that are mergeable.
There is no class called MCDataFragment, it has been folded into the
MCFragment class. Change the cast<MCDataFragment> to cast<MCFragment>.
// CASObjects, one can use a conditional breakpoint to find the Fragment
// which might have a bug.
#ifndef NDEBUG
uint64_t TotalFragmentWithoutAddendsSize = 0;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do get the warning

[236/236] Building CXX object lib/MCCAS/CMakeFiles/LLVMMCCAS.dir/MCCASObjectV1.cpp.o
/Users/shubhamrastogi/Development/llvm-project-cas/llvm-project/llvm/lib/MCCAS/MCCASObjectV1.cpp:3131:14: warning: variable 'TotalFragmentWithoutAddendsSize' set but not used [-Wunused-but-set-variable]
 3131 |     uint64_t TotalFragmentWithoutAddendsSize = 0;
      |              

This is because TotalFragmentWithoutAddendsSize is never read from, but this is really useful for debugging MCCAS. Any ideas on what to do?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest use debug macros: https://llvm.org/docs/ProgrammersManual.html#the-llvm-debug-macro-and-debug-option

For non-assert build just add a reference:

(void) TotalFragmentWithoutAddendsSize;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it look okay now?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want to add #define DEBUG_TYPE for the file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In rare cases (like in the case of armv7-cas.ll), where we still produce
DWARF4, we are still trying to read the information from a non-existent
DebugStringOffsets section.

We do not need the data from that section to partition compile units.

That code has been removed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants