@@ -20,68 +20,67 @@ branch. LLVM should be built with at least
2020
2121An example ` bash ` session to build Comgr on Linux using GNUMakefiles is:
2222
23- $ LLVM_PROJECT=~/llvm-project
24- $ DEVICE_LIBS=~/llvm-project/amd/device-libs
25- $ COMGR=~/llvm-project/amd/comgr
26- $ mkdir -p "$LLVM_PROJECT/build"
27- $ cd "$LLVM_PROJECT/build"
23+ $ LLVM_PROJECT=~/llvm-project/build
24+ $ DEVICE_LIBS=~/llvm-project/amd/device-libs/build
25+ $ mkdir -p "$LLVM_PROJECT"
26+ $ cd "$LLVM_PROJECT"
2827 $ cmake \
2928 -DCMAKE_BUILD_TYPE=Release \
3029 -DLLVM_ENABLE_PROJECTS="llvm;clang;lld" \
3130 -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" \
3231 ../llvm
3332 $ make
34- $ mkdir -p "$DEVICE_LIBS/build "
35- $ cd "$DEVICE_LIBS/build "
33+ $ mkdir -p "$DEVICE_LIBS"
34+ $ cd "$DEVICE_LIBS"
3635 $ cmake \
3736 -DCMAKE_BUILD_TYPE=Release \
38- -DCMAKE_PREFIX_PATH="$LLVM_PROJECT/build " \
37+ -DCMAKE_PREFIX_PATH="$LLVM_PROJECT" \
3938 ..
4039 $ make
41- $ mkdir -p "$COMGR/build"
42- $ cd "$COMGR/ build"
40+ $ cd ~/llvm-project/amd/comgr
41+ $ mkdir -p build; cd build;
4342 $ cmake \
4443 -DCMAKE_BUILD_TYPE=Release \
45- -DCMAKE_PREFIX_PATH="$LLVM_PROJECT/build ;$DEVICE_LIBS/build " \
44+ -DCMAKE_PREFIX_PATH="$LLVM_PROJECT;$DEVICE_LIBS" \
4645 ..
4746 $ make
4847 $ make test
4948
5049The equivalent on Windows in ` cmd.exe ` using Visual Studio project files is:
5150
52- > set LLVM_PROJECT="%HOMEPATH%\llvm-project"
53- > set DEVICE_LIBS="%HOMEPATH%\llvm-project\amd\device-libs"
54- > set COMGR="%HOMEPATH%\llvm-project\amd\comgr"
55- > mkdir "%LLVM_PROJECT%\build"
56- > cd "%LLVM_PROJECT%\build"
51+ > set LLVM_PROJECT="%HOMEPATH%\llvm-project\build"
52+ > set DEVICE_LIBS="%HOMEPATH%\llvm-project\amd\device-libs\build"
53+ > mkdir "%LLVM_PROJECT%"
54+ > cd "%LLVM_PROJECT%"
5755 > cmake ^
5856 -DLLVM_ENABLE_PROJECTS="llvm;clang;lld" ^
5957 -DLLVM_TARGETS_TO_BUILD="AMDGPU;X86" ^
6058 ..\llvm
6159 > msbuild /p:Configuration=Release ALL_BUILD.vcxproj
62- > mkdir "%DEVICE_LIBS%\build "
63- > cd "%DEVICE_LIBS%\build "
60+ > mkdir "%DEVICE_LIBS%"
61+ > cd "%DEVICE_LIBS%"
6462 > cmake ^
65- -DCMAKE_PREFIX_PATH="%LLVM_PROJECT%\build " ^
63+ -DCMAKE_PREFIX_PATH="%LLVM_PROJECT%" ^
6664 ..
6765 > msbuild /p:Configuration=Release ALL_BUILD.vcxproj
68- > mkdir "%COMGR%\build"
69- > cd "%COMGR%\build"
66+ > cd "%HOMEPATH%\llvm-project\amd\comgr"
67+ > mkdir build
68+ > cd build
7069 > cmake ^
71- -DCMAKE_PREFIX_PATH="%LLVM_PROJECT%\build ;%DEVICE_LIBS%\build " ^
70+ -DCMAKE_PREFIX_PATH="%LLVM_PROJECT%;%DEVICE_LIBS%" ^
7271 ..
7372 > msbuild /p:Configuration=Release ALL_BUILD.vcxproj
7473 > msbuild /p:Configuration=Release RUN_TESTS.vcxproj
7574
76- Optionally,
75+ ** ASAN support: ** Optionally,
7776[ AddressSanitizer] ( https://github.com/google/sanitizers/wiki/AddressSanitizer )
7877may be enabled during development via ` -DADDRESS_SANITIZER=On ` during the Comgr
7978` cmake ` step.
8079
81- Comgr can be built as a static library by passing
80+ ** Static Comgr: ** Comgr can be built as a static library by passing
8281` -DCOMGR_BUILD_SHARED_LIBS=OFF ` during the Comgr ` cmake ` step.
8382
84- To enable SPIRV support, checkout
83+ ** SPIRV Support: ** To enable SPIRV support, checkout
8584[ SPIRV-LLVM-Translator] ( https://github.com/ROCm/SPIRV-LLVM-Translator ) in
8685` llvm/projects ` or ` llvm/tools ` and build using the above instructions, with the
8786exception that the ` -DCMAKE_PREFIX_PATH ` for llvm-project must be an install
@@ -92,6 +91,37 @@ Comgr SPIRV-related APIs can be disabled by passing
9291` -DCOMGR_DISABLE_SPIRV=1 ` during the Comgr ` cmake ` step. This removes any
9392dependency on LLVM SPIRV libraries or the llvm-spirv tool.
9493
94+ ** Code Coverage Instrumentation:** Comgr supports source-based [ code coverage
95+ via clang] ( https://clang.llvm.org/docs/SourceBasedCodeCoverage.html ) , and
96+ leverages the same CMake variables as
97+ [ LLVM] ( https://www.llvm.org/docs/CMake.html#llvm-related-variables )
98+ (LLVM_BUILD_INSTRUMENTED_COVERAGE, etc.).
99+
100+ Example of insturmenting with covereage, generating profiles, and creating an
101+ HTML for investigation:
102+
103+ $ cmake -DCMAKE_STRIP="" -DLLVM_PROFILE_DATA_DIR=`pwd`/profiles \
104+ -DLLVM_BUILD_INSTRUMENTED_COVERAGE=On \
105+ -DCMAKE_CXX_COMPILER="$LLVM_PROJECT/bin/clang++" \
106+ -DCMAKE_C_COMPILER="$LLVM_PROJECT/bin/clang" \
107+ -DCMAKE_BUILD_TYPE=Release \
108+ -DCMAKE_PREFIX_PATH="$LLVM_PROJECT;$DEVICE_LIBS" ..
109+ $ make -j
110+ $ make test test-lit
111+ $ cd profiles
112+ # Manually aggregate the data and create text report.
113+ $ $LLVM_PROJECT/bin/llvm-profdata merge -sparse *.profraw -o \
114+ comgr_test.profdata # merge and index data
115+ $ $LLVM_PROJECT/bin/llvm-cov report ../libamd_comgr.so \
116+ -instr-profile=comgr_test.profdata \
117+ -ignore-filename-regex="[cl].*/include/*" # show test report without \
118+ includes
119+ # Or use python script to aggregate the data and create html report.
120+ $ $LLVM_PROJECT/../llvm/utils/prepare-code-coverage-artifact.py \
121+ --preserve-profiles $LLVM_PROJECT/bin/llvm-profdata \
122+ $LLVM_PROJECT/bin/llvm-cov . html ../libamd_comgr.so \
123+ # create html report
124+
95125Depending on the Code Object Manager
96126------------------------------------
97127
0 commit comments