From 12ac0403b1d9a1eef1a06f8ef710580874d43b7d Mon Sep 17 00:00:00 2001 From: Hongtao Yu Date: Fri, 26 Mar 2021 13:18:26 -0700 Subject: [PATCH] [CSSPGO][NFC] Fix a debug dump issue. During context promotion, intermediate nodes that are on a call path but do not come with a profile can be promoted together with their parent nodes. Do not print sample context string for such nodes since they do not have profile. Reviewed By: wenlei Differential Revision: https://reviews.llvm.org/D99441 --- llvm/lib/Transforms/IPO/SampleContextTracker.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/IPO/SampleContextTracker.cpp b/llvm/lib/Transforms/IPO/SampleContextTracker.cpp index 9b7af45..5ad0ba2 100644 --- a/llvm/lib/Transforms/IPO/SampleContextTracker.cpp +++ b/llvm/lib/Transforms/IPO/SampleContextTracker.cpp @@ -542,8 +542,11 @@ ContextTrieNode &SampleContextTracker::promoteMergeContextSamplesTree( } else { // Destination node exists, merge samples for the context tree mergeContextNode(FromNode, *ToNode, ContextStrToRemove); - LLVM_DEBUG(dbgs() << " Context promoted and merged to: " - << ToNode->getFunctionSamples()->getContext() << "\n"); + LLVM_DEBUG({ + if (ToNode->getFunctionSamples()) + dbgs() << " Context promoted and merged to: " + << ToNode->getFunctionSamples()->getContext() << "\n"; + }); // Recursively promote and merge children for (auto &It : FromNode.getAllChildContext()) { -- 2.7.4