All Projects → tudasc → MetaCG

tudasc / MetaCG

Licence: BSD-3-Clause license
MetaCG offers an annotated whole program call-graph tool for Clang/LLVM.

Programming Languages

C++
36643 projects - #6 most used programming language
CMake
9771 projects
shell
77523 projects

Projects that are alternatives of or similar to MetaCG

EmbedSanitizer
EmbedSantizer is a runtime race detection tool which extends ThreadSanitizer to detect data races in 32-bit ARM applications.
Stars: ✭ 16 (-23.81%)
Mutual labels:  llvm, clang
Constexpr Everything
Rewrite C++ code to automatically apply `constexpr` where possible
Stars: ✭ 178 (+747.62%)
Mutual labels:  llvm, clang
Webassembly Examples
From Simple To Complex. A complete collection of webassembly examples.
Stars: ✭ 177 (+742.86%)
Mutual labels:  llvm, clang
Clang Llvm Tutorial
clang & llvm examples, e.g. AST Interpreter, Function Pointer Analysis, Value Range Analysis, Data-Flow Analysis, Andersen Pointer Analysis, LLVM Backend...
Stars: ✭ 139 (+561.9%)
Mutual labels:  llvm, clang
codebrowser
Woboq CodeBrowser
Stars: ✭ 985 (+4590.48%)
Mutual labels:  llvm, clang
Cling
The cling C++ interpreter
Stars: ✭ 2,322 (+10957.14%)
Mutual labels:  llvm, clang
vuo
A realtime visual programming language for interactive media.
Stars: ✭ 103 (+390.48%)
Mutual labels:  llvm, clang
Llvm Utils
LLVM/Clang for Visual Studio 2019, 2017, 2015, 2013, 2012 and 2010. clang-cl for Python3 distutils. Utils for Clang Static Analyzer
Stars: ✭ 123 (+485.71%)
Mutual labels:  llvm, clang
Checkedc
Checked C is an extension to C that lets programmers write C code that is guaranteed by the compiler to be type-safe. The goal is to let people easily make their existing C code type-safe and eliminate entire classes of errors. Checked C does not address use-after-free errors. This repo has a wiki for Checked C, sample code, the specification, a…
Stars: ✭ 2,692 (+12719.05%)
Mutual labels:  llvm, clang
Cmake Scripts
A selection of useful scripts for use in CMake projects, include code coverage, sanitizers, and dependency graph generation.
Stars: ✭ 202 (+861.9%)
Mutual labels:  llvm, clang
Gllvm
Whole Program LLVM: wllvm ported to go
Stars: ✭ 126 (+500%)
Mutual labels:  llvm, clang
linux
Linux kernel source tree
Stars: ✭ 234 (+1014.29%)
Mutual labels:  llvm, clang
Proton Clang
Proton Clang toolchains builds in the form of a continuously updating Git repository. Clone with --depth=1.
Stars: ✭ 126 (+500%)
Mutual labels:  llvm, clang
Play with llvm
A book about LLVM & Clang(中文开源书:玩转 LLVM)
Stars: ✭ 175 (+733.33%)
Mutual labels:  llvm, clang
Metareflect
Metareflect is a lightweight reflection system for C++, based on LLVM and Clangs libtooling.
Stars: ✭ 125 (+495.24%)
Mutual labels:  llvm, clang
Dstep
A tool for converting C and Objective-C headers to D modules
Stars: ✭ 177 (+742.86%)
Mutual labels:  llvm, clang
Cppinsights
C++ Insights - See your source code with the eyes of a compiler
Stars: ✭ 1,382 (+6480.95%)
Mutual labels:  llvm, clang
Bsodsurvivor
This project aims to facilitate debugging a kernel driver in windows by adding support for a code change on the fly without reboot/unload, and more!
Stars: ✭ 122 (+480.95%)
Mutual labels:  llvm, clang
Clang Expand
🐉 A clang tool for happy refactoring without source-code gymnastics
Stars: ✭ 182 (+766.67%)
Mutual labels:  llvm, clang
TON-Compiler
Clang compiler for Free TON Virtual Machine
Stars: ✭ 56 (+166.67%)
Mutual labels:  llvm, clang

License

MetaCG

MetaCG provides a common whole-program call-graph representation to exchange information between different tools built on top of LLVM/Clang. It uses the json file format and separates structure from information, i.e., caller/callee relation and meta information.

The package contains an experimental Clang-based tool for call-graph construction, and a converter for the output files of Phasar. Also, the package contains the PGIS analysis tool, which is used as the analysis backend in PIRA.

Once constructed, the graph can be serialized into a JSON format, which contains the following information:

{
 "_MetaCG: {
   "version": "2.0",
   "generator": {
    "name": "ToolName",
    "version": "ToolVersion"
    }
  },
  "_CG": {
   "main": {
    "callers": [],
    "callees": ["foo"],
    "hasBody": true,
    "isVirtual": false,
    "doesOverride": false,
    "overrides": [],
    "overriddenBy": [],
    "meta": {
     "MetaTool": {}
    }
  }
  • _MetaCG contains information about the file itself, such as the file format version.
  • _CG contains the actual serialized call graph. For each function, it lists
    • callers: A set of functions that this function may be called from.
    • callees: A set of functions that this function may call.
    • hasBody: Whether a definition of the function was found in the processed source files.
    • isVirtual: Whether the function is marked as virtual.
    • doesOverride: Whether this function overrides another function.
    • overrides: A set of functions that this function overrides.
    • overriddenBy: A set of functions that this function is overridden by.
    • meta: A special field into which a tool can export its (intermediate) results.

This allows, e.g., the PIRA profiler to export various additional information about the program's functions into the MetaCG file. Examples are empirically determined performance models, runtime measurements, or loop nesting depth per function.

Requirements / Building

MetaCG consists of the graph library, a CG construction tool, and an example analysis tool. The graph library is always built. The CG construction tool CGCollector can be disabled via the CMake option -DWITH_CGCOLLECTOR=OFF. The example analysis tool PGIS can be disabled via the CMake option -DWITH_PGIS=OFF.

Build Requirements (for full build)

Building

Clang/LLVM (v 10) and the cube library are assumed to be available on the system. Extra-P can be built using the build_submodules.sh script provided in the repository, though it is not tested outside of our CI system. It builds and installs Extra-P into ./deps/src and ./deps/install, respectively.

The nlohmann-json, spdlog and cxxopts library are downloaded at configure time, unless -DMETACG_USE_EXTERNAL_JSON=ON or -DMETACG_USE_EXTERNAL_SPDLOG=ON is given. This will search for the respective libraries in the common CMake locations. While CMake looks for nlohmann-json version 3.10., MetaCG should work starting from version 3.9.2. For spdlog, we rely on version 1.8.2 -- other versions may work.

?> ./build_submodules.sh

Thereafter, the package can be configured and built from the top-level CMake. Change the CMAKE_INSTALL_PREFIX to where you want your MetaCG installation to live. Providing SPDLOG_SHARED=ON is necessary to build the shared object version of spdlog and prevent linker errors.

?> cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/tmp/metacg -DCUBE_LIB=$(dirname $(which cube_info))/../lib -DCUBE_INCLUDE=$(dirname $(which cube_info))/../include/cubelib -DEXTRAP_INCLUDE=./extern/src/extrap/extrap-3.0/include -DEXTRAP_LIB=./extern/install/extrap/lib -DSPDLOG_BUILD_SHARED=ON -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
?> cmake --build build --parallel
# Installation installs CGCollector, CGMerge, CGValidate, PGIS
?> cmake --install build

CMake Options

  • Path CUBE_LIB: Path to the libcube library directory
  • Path CUBE_INCLUDE: Path to the libcube include directory
  • Path EXTRAP_LIB: Path to the Extra-P library directory
  • Path EXTRAP_INCLUDE: Path to the Extra-P include directory
  • Bool WITH_CGCOLLECTOR: Whether to build call-graph construction tool
  • Bool WITH_PGIS: Whether to build demo-analysis tool
  • Bool METACG_USE_EXTERNAL_JSON: Search for installed version of nlohmann-json
  • Bool METACG_USE_EXTERNAL_SPDLOG: Search for installed version of spdlog

Usage

Graph Library

Provides the basic data structure and its means to read and write the data structure with the metadata to a JSON file.

CGCollector

Clang-based call-graph generation tool for MetaCG. It has the components CGCollector, CGMerge and CGValidate to construct the partial MCG per translation unit, merge the partial MCGs into the final whole-program MCG and validate edges against a full Score-P profile, respectively.

Using CGCollector

It is easiest to apply CGCollector, when a compilation database (compile_commands.json) is present. Then, CGCollector can be applied to a single source file using

$> cgc target.cpp

cgc is a wrapper script that (tries to) determines the paths to the Clang standard includes.

Subsequently, the resulting partial MCGs are merged using CGMerge to create the final, whole-program call-graph of the application.

?> echo "null" > $IPCG_FILENAME
?> find ./src -name "*.mcg" -exec cgmerge $IPCG_FILENAME $IPCG_FILENAME {} +

Optionally, you can test the call graph for missing edges, by providing an unfiltered application profile that was recorded using Score-P in the Cube library format. This is done using the CGValidate tool, which also allows to patch all missing edges and nodes.

PGIS (The PIRA Analyzer)

This tool is part of the PIRA toolchain. It is used as analysis engine and constructs instrumentation selections guided by both static and dynamic information from a target application.

Using PGIS

The PGIS tool offers a variety of modes to operate. A list of all modes and options can be found with pgis_pira --help. Currently, the user needs to provide any parameter-file, as required by the performance model guided instrumentation or the load imbalance detection. Examples of such files can be found in the heuristics respective integration test directory.

  1. Construct overview instrumentation configurations for Score-P from a MetaCG file.
?> pgis_pira --metacg-format 2 --static mcg-file
  1. Construct hot-spot instrumentation using raw runtime values.
?> pgis_pira --metacg-format 2 --cube cube-file mcg-file
  1. Construct performance model guided instrumentation configurations for Score-P using Extra-P. The Extra-P configuration lists where to find the experiment series. Its content follows what is expected by Extra-P.
{
 "dir": "./002",
 "prefix": "t",
 "postfix": "postfix",
 "reps": 5,
 "iter": 1,
 "params" : {
  "X": ["3", "5", "7", "9", "11"]
 }
}
?> pgis_pira --metacg-format 2 --parameter-file <parameter-file> --extrap extrap-file mcg-file
  1. Evaluate and construct load-imbalance instrumentation configuration.
?> pgis_pira --metacg-format 2 --parameter-file <parameter-file> --lide 1 --cube cube-file mcg-file
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].