[llvm] r294055 - [PGO] Add select instr profile in graph dump
Sean Silva via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 3 20:33:53 PST 2017
On Fri, Feb 3, 2017 at 1:57 PM, Xinliang David Li via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: davidxl
> Date: Fri Feb 3 15:57:51 2017
> New Revision: 294055
>
> URL: http://llvm.org/viewvc/llvm-project?rev=294055&view=rev
> Log:
> [PGO] Add select instr profile in graph dump
>
> Differential Revision: http://reviews.llvm.org/D29474
>
>
> Modified:
> llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
>
> Modified: llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/
> Transforms/Instrumentation/PGOInstrumentation.cpp?rev=
> 294055&r1=294054&r2=294055&view=diff
> ============================================================
> ==================
> --- llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
> (original)
> +++ llvm/trunk/lib/Transforms/Instrumentation/PGOInstrumentation.cpp Fri
> Feb 3 15:57:51 2017
> @@ -1331,6 +1331,16 @@ template <> struct GraphTraits<PGOUseFun
> }
> };
>
> +static std::string getSimpleNodeName(const BasicBlock *Node) {
> + if (!Node->getName().empty())
> + return Node->getName();
> +
> + std::string SimpleNodeName;
> + raw_string_ostream OS(SimpleNodeName);
> + Node->printAsOperand(OS, false);
> + return OS.str();
> +}
> +
> template <> struct DOTGraphTraits<PGOUseFunc *> : DefaultDOTGraphTraits {
> explicit DOTGraphTraits(bool isSimple = false)
> : DefaultDOTGraphTraits(isSimple) {}
> @@ -1342,12 +1352,31 @@ template <> struct DOTGraphTraits<PGOUse
> std::string getNodeLabel(const BasicBlock *Node, const PGOUseFunc
> *Graph) {
> std::string Result;
> raw_string_ostream OS(Result);
> - OS << Node->getName().str() << " : ";
> +
> + OS << getSimpleNodeName(Node) << ":\\l";
> UseBBInfo *BI = Graph->findBBInfo(Node);
> + OS << "Count : ";
> if (BI && BI->CountValid)
> - OS << BI->CountValue;
> + OS << BI->CountValue << "\\l";
> else
> - OS << "Unknown";
> + OS << "Unknown\\l";
> +
> + if (!PGOInstrSelect)
> + return Result;
> +
> + for (auto BI = Node->begin(); BI != Node->end(); ++BI) {
> + auto *I = &*BI;
> + if (!isa<SelectInst>(I))
> + continue;
> + // Display scaled counts for SELECT instruction:
> + OS << "SELECT : { T = ";
> + uint64_t TC, FC;
> + bool hasProf = I->extractProfMetadata(TC, FC);
>
s/hasProf/HasProf/
-- Sean Silva
> + if (!hasProf)
> + OS << "Unknown, F = Unknown }\\l";
> + else
> + OS << TC << ", F = " << FC << " }\\l";
> + }
> return Result;
> }
> };
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170203/7030d6b4/attachment-0001.html>
More information about the llvm-commits
mailing list