aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshat Oke <Akshat.Oke@amd.com>2025-06-02 09:00:13 +0000
committerAkshat Oke <Akshat.Oke@amd.com>2025-06-02 09:01:38 +0000
commita313c87fe132fc576304a7334ee7153acfb5433a (patch)
treea5eee760d5b11e34206837378f3155cd76a16739
parent61d3ad963c9a8764a20c01c26374000d9ba5975d (diff)
downloadllvm-users/optimisan/06-02-codegenprepare_null_check_pointers.zip
llvm-users/optimisan/06-02-codegenprepare_null_check_pointers.tar.gz
llvm-users/optimisan/06-02-codegenprepare_null_check_pointers.tar.bz2
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 76f2762..a191dce 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -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();
@@ -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");
}