-
Notifications
You must be signed in to change notification settings - Fork 14.4k
WIP: Extend SourceLocation to 64 bits. #146314
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
Closed
Closed
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
7346173
64-bit source location
hokein 5a2700e
Test Bits=64 perf
hokein 755e671
Switch Bits back to 40.
hokein 68ffab3
Reduce SubstNonTypeTemplateParmExpr size: 48 -> 40 bytes
hokein b1f6205
Reduce OpaqueValueExpr: 32 -> 24 bytes
hokein 86f0440
Reduce CXXDependentScopeMemberExpr size: 88 -> 80 bytes
hokein 9dbf694
Reduce DeclRefExpr size: 48 -> 40 bytes.
hokein da34ffe
Fix some merge conflicts.
hokein 6be8784
Move the Loc back to the StmtBitFields if possible to save AST size.
hokein c5a21c5
Improve getFildIDLocal binary search.
hokein 7f125a0
Optimize binary search by using a dedicate offset table
hokein 9845547
Revert the static_assert change for ObjCContainerDeclBitfields.
hokein 4794062
Fix the compile failures for include-cleaner.
hokein 25aa128
Fix clang-tidy build.
hokein 3527a02
Fix clangd unittest
hokein 31c773f
Fix windows build failures.
hokein e63c988
More windows fix
hokein 9dd6cdf
Change the underlying StmtBitField type to uint64_t, fix windows
hokein 181420a
More window fix
hokein 51c4afc
Merge branch 'main' into perf/64-sloc-new2
hokein 4379826
Fix merge failures
hokein 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
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 |
---|---|---|
|
@@ -682,6 +682,11 @@ class DeclarationNameTable { | |
DeclarationName getCXXLiteralOperatorName(const IdentifierInfo *II); | ||
}; | ||
|
||
struct CXXOperatorSourceInfo { | ||
SourceLocation BeginOpNameLoc; | ||
SourceLocation EndOpNameLoc; | ||
}; | ||
|
||
/// DeclarationNameLoc - Additional source/type location info | ||
/// for a declaration name. Needs a DeclarationName in order | ||
/// to be interpreted correctly. | ||
|
@@ -698,8 +703,7 @@ class DeclarationNameLoc { | |
|
||
// The location (if any) of the operator keyword is stored elsewhere. | ||
struct CXXOpName { | ||
SourceLocation BeginOpNameLoc; | ||
SourceLocation EndOpNameLoc; | ||
CXXOperatorSourceInfo* OInfo; | ||
}; | ||
|
||
// The location (if any) of the operator keyword is stored elsewhere. | ||
|
@@ -719,11 +723,6 @@ class DeclarationNameLoc { | |
|
||
void setNamedTypeLoc(TypeSourceInfo *TInfo) { NamedType.TInfo = TInfo; } | ||
|
||
void setCXXOperatorNameRange(SourceRange Range) { | ||
CXXOperatorName.BeginOpNameLoc = Range.getBegin(); | ||
CXXOperatorName.EndOpNameLoc = Range.getEnd(); | ||
} | ||
|
||
void setCXXLiteralOperatorNameLoc(SourceLocation Loc) { | ||
CXXLiteralOperatorName.OpNameLoc = Loc; | ||
} | ||
|
@@ -739,12 +738,17 @@ class DeclarationNameLoc { | |
|
||
/// Return the beginning location of the getCXXOperatorNameRange() range. | ||
SourceLocation getCXXOperatorNameBeginLoc() const { | ||
return CXXOperatorName.BeginOpNameLoc; | ||
if (!CXXOperatorName.OInfo) | ||
return {}; | ||
return | ||
CXXOperatorName.OInfo->BeginOpNameLoc; | ||
} | ||
|
||
/// Return the end location of the getCXXOperatorNameRange() range. | ||
SourceLocation getCXXOperatorNameEndLoc() const { | ||
return CXXOperatorName.EndOpNameLoc; | ||
if (!CXXOperatorName.OInfo) | ||
return {}; | ||
return CXXOperatorName.OInfo->EndOpNameLoc; | ||
} | ||
|
||
/// Return the range of the operator name (without the operator keyword). | ||
|
@@ -769,17 +773,12 @@ class DeclarationNameLoc { | |
DNL.setNamedTypeLoc(TInfo); | ||
return DNL; | ||
} | ||
|
||
/// Construct location information for a non-literal C++ operator. | ||
static DeclarationNameLoc makeCXXOperatorNameLoc(SourceLocation BeginLoc, | ||
SourceLocation EndLoc) { | ||
return makeCXXOperatorNameLoc(SourceRange(BeginLoc, EndLoc)); | ||
} | ||
|
||
|
||
/// Construct location information for a non-literal C++ operator. | ||
static DeclarationNameLoc makeCXXOperatorNameLoc(SourceRange Range) { | ||
static DeclarationNameLoc | ||
makeCXXOperatorNameLoc(CXXOperatorSourceInfo *OInfo) { | ||
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. This is a weird function to exist... am I correct in that it is only called 1x? I find myself thinkin perhaps we should just inline it manually. |
||
DeclarationNameLoc DNL; | ||
DNL.setCXXOperatorNameRange(Range); | ||
DNL.CXXOperatorName.OInfo = OInfo; | ||
return DNL; | ||
} | ||
|
||
|
@@ -839,7 +838,7 @@ struct DeclarationNameInfo { | |
return nullptr; | ||
return LocInfo.getNamedTypeInfo(); | ||
} | ||
|
||
/// setNamedTypeInfo - Sets the source type info associated to | ||
/// the name. Assumes it is a constructor, destructor or conversion. | ||
void setNamedTypeInfo(TypeSourceInfo *TInfo) { | ||
|
@@ -849,6 +848,13 @@ struct DeclarationNameInfo { | |
LocInfo = DeclarationNameLoc::makeNamedTypeLoc(TInfo); | ||
} | ||
|
||
/// Sets the range of the operator name (without the operator keyword). | ||
/// Assumes it is a C++ operator. | ||
void setCXXOperatorNameInfo(CXXOperatorSourceInfo *OInfo) { | ||
assert(Name.getNameKind() == DeclarationName::CXXOperatorName); | ||
LocInfo = DeclarationNameLoc::makeCXXOperatorNameLoc(OInfo); | ||
} | ||
|
||
/// getCXXOperatorNameRange - Gets the range of the operator name | ||
/// (without the operator keyword). Assumes it is a (non-literal) operator. | ||
SourceRange getCXXOperatorNameRange() const { | ||
|
@@ -857,13 +863,6 @@ struct DeclarationNameInfo { | |
return LocInfo.getCXXOperatorNameRange(); | ||
} | ||
|
||
/// setCXXOperatorNameRange - Sets the range of the operator name | ||
/// (without the operator keyword). Assumes it is a C++ operator. | ||
void setCXXOperatorNameRange(SourceRange R) { | ||
assert(Name.getNameKind() == DeclarationName::CXXOperatorName); | ||
LocInfo = DeclarationNameLoc::makeCXXOperatorNameLoc(R); | ||
} | ||
|
||
/// getCXXLiteralOperatorNameLoc - Returns the location of the literal | ||
/// operator name (not the operator keyword). | ||
/// Assumes it is a literal operator. | ||
|
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.
How much does this indirection save perf wise?
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.
I don't see the performance impact on this indirection -- this is for the C++ operation call, which is rare in practice (the perf here https://llvm-compile-time-tracker.com/compare.php?from=ff5a67315305f59f91041bad8b905e161b872442&to=38c519de69b127faa823078d3faff5670bc60209&stat=instructions:u)