Skip to content

CodeGenPrepare: Null check pointers #142350

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 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions llvm/lib/CodeGen/CodeGenPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ PreservedAnalyses CodeGenPreparePass::run(Function &F,
}

bool CodeGenPrepare::run(Function &F, FunctionAnalysisManager &AM) {
assert(TM && "TargetMachine is required for CodeGenPrepare");
DL = &F.getDataLayout();
SubtargetInfo = TM->getSubtargetImpl(F);
TLI = SubtargetInfo->getTargetLowering();
Expand Down Expand Up @@ -589,16 +590,16 @@ bool CodeGenPrepare::_run(Function &F) {
// counts based hotness overwrite the cold attribute.
// This is a conservative behabvior.
if (F.hasFnAttribute(Attribute::Hot) ||
PSI->isFunctionHotInCallGraph(&F, *BFI))
(PSI && PSI->isFunctionHotInCallGraph(&F, *BFI)))
F.setSectionPrefix("hot");
// If PSI shows this function is not hot, we will placed the function
// into unlikely section if (1) PSI shows this is a cold function, or
// (2) the function has a attribute of cold.
else if (PSI->isFunctionColdInCallGraph(&F, *BFI) ||
else if ((PSI && PSI->isFunctionColdInCallGraph(&F, *BFI)) ||
F.hasFnAttribute(Attribute::Cold))
F.setSectionPrefix("unlikely");
else if (ProfileUnknownInSpecialSection && PSI->hasPartialSampleProfile() &&
PSI->isFunctionHotnessUnknown(F))
else if (ProfileUnknownInSpecialSection && PSI &&
PSI->hasPartialSampleProfile() && PSI->isFunctionHotnessUnknown(F))
F.setSectionPrefix("unknown");
}

Expand Down
Loading