Why should I know this?

LLVM debug tips 본문

LLVM-STUDY

LLVM debug tips

die4taoam 2024. 1. 14. 20:53

https://youtu.be/y4b-sgp6VYA?si=FBwXN-abkikLJwx0

 

cmake .. -GNinja  \

-DCMAKE_BUILD_TYPE=Release \

-DLLVM_ENABLE_LLD=ON \

-DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt"  \

-DLLVM_TARGETS_TO_BUILD="AArch64;ARM;X86"  \

-DLLVM_ENABLE_ASSERTION=OFF 

 

-E : Stop before compiling

-S : Stop before assembling

-c : Stop before linking

 

Dumping LEXER Tokens

clang -Xclang -dump-tokens -E foo.cpp

clang -Xclang -help -E foo.cpp

clang -Xclang -emit-html -o foo.html foo.cpp

clang -Xclang -asp-dump -E foo.cpp

// Only can be used in debug build

clang -Xclang -ast-view -E foo.cpp

 

Dumping LLVM IR

clang foo.cpp -emit-llvm -S -o - -fno-discard-value-names -g0

-emit-llvm : produce LLVM IR
-S : as human readable foo.ll, not binary foo.bc

-o - : output to stdout rather than to .ll or .bc. file

-fno-discard-value-names : identifiers from source rather than numbers

-g0 : less debug info in IR

 

 

clang -emit-llvm -S -O2 -Xclang -disable-llvm-passes foo.cpp

opt -O2 -s foo.ll

 

clang -emit-llvm -S -O2 foo.cpp

 

// print what happen during each pass

opt -O2 -print-after-all -S foo.cpp

 

LOWERING WITH LLC

llc foo.ll

llc -filetype=obj foo.ll

llc --print-after-all foo.ll

llc -debug-pass=Structure foo.ll

 

 

// PER PASS DEBUG INFO

opt -licm -debug-only=licm foo.ll -S -o -

clang -O2 -Rpass=licm -c foo.cpp

 

others, these option can be uses to clang with -mllvm prefixed

-print-after-all

-print-after=

-print-before-all

-print-before=

-stop-after=

-print-module-scope

-debug-pass=Arguments

 

 

//TABLE GEN

 

https://www.youtube.com/watch?v=45gmF77JFBY&ab_channel=FOSDEM

https://llvm.org/docs/TableGen/

 

TableGen Overview — LLVM 18.0.0git documentation

TableGen has a syntax that is loosely based on C++ templates, with built-in types and specification. In addition, TableGen’s syntax introduces some automation concepts like multiclass, foreach, let, etc. TableGen files consist of two key parts: ‘classe

llvm.org

https://llvm.org/docs/TableGen/BackEnds.html

 

TableGen BackEnds — LLVM 18.0.0git documentation

Warning This portion is incomplete. Each section below needs three subsections: description of its purpose with a list of users, output generated from generic input, and finally why it needed a new backend (in case there’s something similar). Overall, ea

llvm.org

https://llvm.org/docs/TableGen/BackEnds.html

 

TableGen BackEnds — LLVM 18.0.0git documentation

Warning This portion is incomplete. Each section below needs three subsections: description of its purpose with a list of users, output generated from generic input, and finally why it needed a new backend (in case there’s something similar). Overall, ea

llvm.org

https://llvm.org/docs/TableGen/ProgRef.html

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

'LLVM-STUDY' 카테고리의 다른 글

LLVM 원라인 패치 목록  (0) 2024.03.17
LLVM 최적화 패치 제출까지의 순서 정리  (0) 2024.03.03
LLVM 내부에서 활용되는 논리식 모음  (0) 2023.12.15
[TODO] DomConditionCache  (0) 2023.12.11
SubclassOptionalData  (0) 2023.12.11
Comments