-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[ctxprof] Support for "move" semantics for the contextual root #134192
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,31 @@ static cl::opt<bool> UseSourceFilenameForPromotedLocals( | |
"This requires that the source filename has a unique name / " | ||
"path to avoid name collisions.")); | ||
|
||
extern cl::list<GlobalValue::GUID> MoveSymbolGUID; | ||
|
||
FunctionImportGlobalProcessing::FunctionImportGlobalProcessing( | ||
Module &M, const ModuleSummaryIndex &Index, | ||
SetVector<GlobalValue *> *GlobalsToImport, bool ClearDSOLocalOnDeclarations) | ||
: M(M), ImportIndex(Index), GlobalsToImport(GlobalsToImport), | ||
ClearDSOLocalOnDeclarations(ClearDSOLocalOnDeclarations) { | ||
// If we have a ModuleSummaryIndex but no function to import, | ||
// then this is the primary module being compiled in a ThinLTO | ||
// backend compilation, and we need to see if it has functions that | ||
// may be exported to another backend compilation. | ||
if (!GlobalsToImport) | ||
HasExportedFunctions = ImportIndex.hasExportedFunctions(M); | ||
|
||
#ifndef NDEBUG | ||
SmallVector<GlobalValue *, 4> Vec; | ||
// First collect those in the llvm.used set. | ||
collectUsedGlobalVariables(M, Vec, /*CompilerUsed=*/false); | ||
// Next collect those in the llvm.compiler.used set. | ||
collectUsedGlobalVariables(M, Vec, /*CompilerUsed=*/true); | ||
Used = {llvm::from_range, Vec}; | ||
#endif | ||
Comment on lines
+41
to
+48
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. I don't understand what 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 code that moved from the .h as-is. I could split it into a NFC, but seemed overkill. To your question, IDK, but wouldn't address it here. 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. Add a TODO to cleanup? |
||
SymbolsToMove.insert_range(MoveSymbolGUID); | ||
} | ||
|
||
/// Checks if we should import SGV as a definition, otherwise import as a | ||
/// declaration. | ||
bool FunctionImportGlobalProcessing::doImportAsDefinition( | ||
|
@@ -147,7 +172,9 @@ FunctionImportGlobalProcessing::getLinkage(const GlobalValue *SGV, | |
// and/or optimization, but are turned into declarations later | ||
// during the EliminateAvailableExternally pass. | ||
if (doImportAsDefinition(SGV) && !isa<GlobalAlias>(SGV)) | ||
return GlobalValue::AvailableExternallyLinkage; | ||
return SymbolsToMove.contains(SGV->getGUID()) | ||
? GlobalValue::ExternalLinkage | ||
: GlobalValue::AvailableExternallyLinkage; | ||
// An imported external declaration stays external. | ||
return SGV->getLinkage(); | ||
|
||
|
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.
nit: braces for the loop body.
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.
no: https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements
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.
Ah since this 2 levels of nesting. I'll be back when I see 3.