diff options
author | Akshat Oke <Akshat.Oke@amd.com> | 2025-06-02 09:00:13 +0000 |
---|---|---|
committer | Akshat Oke <Akshat.Oke@amd.com> | 2025-06-02 09:01:38 +0000 |
commit | a313c87fe132fc576304a7334ee7153acfb5433a (patch) | |
tree | a5eee760d5b11e34206837378f3155cd76a16739 | |
parent | 61d3ad963c9a8764a20c01c26374000d9ba5975d (diff) | |
download | llvm-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 |
CodeGenPrepare: Null check pointersusers/optimisan/06-02-codegenprepare_null_check_pointers
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 9 |
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"); } |