我總覺得開源是一種信仰。在一個想像的共同體下大家用自己的雙手把這個共同體不斷變得更好。編譯器這麼博大精深,除了會碰到的東西之外,這場會議讓我有機會看到大家正在 LLVM 這個巨大的 mono-repo 底下正在做什麼樣的 project 和努力,某些時刻真的是倍感溫馨。
Continue reading “2022 LLVM Dev Mtg, San Jose”Tag: LLVM
Introduction to Zve, Zvl and its LLVM implementation
This is a technical write-up of my first contribution to the LLVM RISC-V backend (specifically on the V extension). If you have any questions to the blog post, please feel free to contact me.
Continue reading “Introduction to Zve, Zvl and its LLVM implementation”Google Summer of Code 2021
這不是一篇技術筆記,主要紀錄今年 Google Summer of Code 的參與。當然,對 LLVM 的參與並不會隨著專案告一個段落而結束。在此分享自己參與的方式與經驗,也想跟大家說 LLVM 社群真的是一個很酷的地方。
Continue reading “Google Summer of Code 2021”If your perf is not working…
I was trying to perf LLVM opt this week and got confused because the perf report showed mangled function calls on the stack traces. So I might as well write an article of it and hope it would get some Google juice and save others from confusion.
- To build LLVM with complete stack traces, build with “
CMAKE_BUILD_TYPE=Debug“ - To allow
perfto work on LLVM, build with “LLVM_USE_PERF:=ON“
At the very first place I thought the mangle-ed function call names exist because of perf not recognizing the symbols. It turned out I was wrong. If perf does not recognize the symbol it would simply show Unknown. The mixed-up symbol names are name mangling for function calls. (see more here)
You can remove the mangling simply with llvm-cxxfilt (see more here). For the exact correct mapping you may need to use llvm-cxxmap (see from here).
With the correct build I still get mangled-output. Turned out that the perf I apt-get-ed from is compiled with the de-mangling function turned off. It was a bug filed in linux since 2014 November and I’m still falling into this error on 2021 June 🤢. (on Ubuntu 16.04 linux 4.4.0-131 generic x86_64)

There’s 3 links in the bug thread above that may lead you to the solution. Personally I’ve download the perf tool in mirrors.edge.kernel.org, followed the instructions here to build the correct perf I needed.
- Stack Overflow – perf enable demangling of callgraph
- Stack Overflow – perf shows mangled function names
- Stack Overflow – perf report function names and extra characters

NOTE: you may need to apt-get some dependencies to enable some feature in perf. Be sure to checkout the compile messages when you build from source. You can checkout features enabled with perf version --build-options.
PS: Just in case you came in with your perf not working on your self-compiled code with clang or gcc, you may want to look at this stack-overflow answer.