{"id":13831654,"url":"https://github.com/rcorcs/llvm-heat-printer","last_synced_at":"2025-07-09T15:32:44.672Z","repository":{"id":22729711,"uuid":"96920229","full_name":"rcorcs/llvm-heat-printer","owner":"rcorcs","description":"LLVM Profiling Visualization","archived":false,"fork":false,"pushed_at":"2022-01-11T17:34:54.000Z","size":1264,"stargazers_count":80,"open_issues_count":1,"forks_count":8,"subscribers_count":12,"default_branch":"master","last_synced_at":"2024-08-05T10:18:16.503Z","etag":null,"topics":["compilers","llvm","llvm-ir","profiling","visualization"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rcorcs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-11T17:41:06.000Z","updated_at":"2024-06-14T10:26:50.000Z","dependencies_parsed_at":"2022-07-27T03:32:04.843Z","dependency_job_id":null,"html_url":"https://github.com/rcorcs/llvm-heat-printer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcorcs%2Fllvm-heat-printer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcorcs%2Fllvm-heat-printer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcorcs%2Fllvm-heat-printer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rcorcs%2Fllvm-heat-printer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rcorcs","download_url":"https://codeload.github.com/rcorcs/llvm-heat-printer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225565893,"owners_count":17489279,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compilers","llvm","llvm-ir","profiling","visualization"],"created_at":"2024-08-04T10:01:35.612Z","updated_at":"2024-11-20T13:31:09.214Z","avatar_url":"https://github.com/rcorcs.png","language":"C++","funding_links":[],"categories":["C++"],"sub_categories":[],"readme":"# LLVM Heat Printer\n\nLLVM Heat Printer provides visualization assistance for profiling.\nIt implements analysis passes that generate visualization (dot) files that depict the (profiled) execution frequency of a piece of code using a cool/warm color map.\n\nCool/Warm color map:\n![CoolWarm Map](https://github.com/rcorcs/llvm-heat-printer/raw/master/images/coolwarm.png)\n\nLLVM Heat Printer supports profiling annotation.\nIn order to see how to use profiling information, look at Section [Using Profiling].\nIf no profiling is used, the basic block frequencies are estimated by means of heuristics.\n\n## Build\n\nAssuming that you already have LLVM libraries installed (LLVM version 5.x.x).\nIn a build directory, use the following commands for building the LLVM Heat Printer libraries.\n```\n$\u003e cmake \u003cpath to LLVM Heat Printer root directory\u003e [-DLLVM_DIR=\u003cllvm build directory\u003e]\n$\u003e make\n```\nThe argument -DLLVM_DIR is optional, in case you want to specify a directory that contains a build of LLVM.\n\n## Heat CFG Printer\n\nThe analysis pass '-dot-heat-cfg' generates the heat map of the CFG (control-flow graph) based on the basic block frequency.\nUse '-dot-heat-cfg-only' for the simplified output without the LLVM code for each basic block.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://github.com/rcorcs/llvm-heat-printer/raw/master/images/heat-cfg.png\" width=\"250\"\u003e\n\u003cimg src=\"https://github.com/rcorcs/llvm-heat-printer/raw/master/images/heat-cfg-only.png\" width=\"250\"\u003e\n\u003c/p\u003e\n\nThe user can also choose between an intra-function or inter-function maximum frequency reference.\nFor the intra-function heat map, activated with the flag '-heat-cfg-per-function', the heat scale will consider only the frequencies of the basic blocks inside the current function, i.e., every function will have a basic block with maximum heat.\nFor the inter-function heat map (default), the heat scale will consider all functions of the current module (translation unit), i.e., it first computes the maximum frequency for all basic blocks in the whole module, such that the heat of each basic block will be scaled in respect of that maximum frequency.\nWith the inter-function heat map, the CFGs for some functions can be completely cold.\n\nIn order to generate the heat CFG .dot file, use the following command:\n```\n$\u003e opt -load ../build/src/libHeatCFGPrinter.so -dot-heat-cfg  \u003c.bc file\u003e \u003e/dev/null\n```\n\n## Heat CallGraph Printer\n\nThe analysis pass '-dot-heat-callgraph' generates the heat map of the call-graph based on either the profiled number of calls or the maximum basic block frequency inside each function.\nThe following figure illustrates the heat call-graph highlighting the maximum basic block frequency inside each function.\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://github.com/rcorcs/llvm-heat-printer/raw/master/images/heat-callgraph.png\" width=\"512\"\u003e\n\u003c/p\u003e\n\nIn order to generate the heat call-graph .dot file, use the following command:\n```\n$\u003e opt -load ../build/src/libHeatCallPrinter.so -dot-heat-callgraph  \u003c.bc file\u003e \u003e/dev/null\n```\n\n## Using Profiling\n\nIn order to use profiling information with the heat map visualizations, you first need to instrument your code for collecting the profiling information, and then annotate the original code with the collected profiling.\n\nInstrumenting the code for profiling basic block frequencies:\n```\n$\u003e clang -fprofile-generate ...\n```\nor, alternatively, you can use the older profiling implementation:\n```\n$\u003e clang -fprofile-instr-generate ...\n```\n\nIn both cases, execute the instrumented code with some representative inputs in order to generate profiling information.\nAfter each execution a .profraw file will be created.\nUse llvm-profdata to combine all .profraw files:\n```\nllvm-profdata merge -output=\u003cfile.profdata\u003e \u003clist of .profraw files\u003e\n```\n\nIn order to annotate the code, re-compile the original code with the profiling information:\n```\n$\u003e clang -fprofile-use=\u003cfile.profdata\u003e -emit-llvm -c ...\n```\nor, again, you can use the older profiling implementation:\n```\n$\u003e clang -fprofile-instr-use=\u003cfile.profdata\u003e -emit-llvm -c ...\n```\nThis last command will generate LLVM bitcode files with the profiling annotations.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcorcs%2Fllvm-heat-printer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frcorcs%2Fllvm-heat-printer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frcorcs%2Fllvm-heat-printer/lists"}