After reading the llvm source code, I realize that if we use clang directly with
clang test.cpp ..., we actually use clang like a driver. It just get the options and invokes an executable, which might not allow us to trace its execution.
In my case, I would like to use the clang Compiler Instance, which can be accessed with
-cc1. However, with
-cc1, we need to specify all the configurations as we use the compiler instance programmatically.
Another way might be to use
-Xclang, which allow us to access the clang flags for the next argument. However, it seems not working with
-fprofile-instrument-path. When I try
clang ./test.cpp -Xclang -fprofile-instrument-path=./, I do get the object file as the output but missing the instrumentation symbols inside the file.
I wonder if I miss anything or my understanding is not correct. I would appreciate any help and clarification. Thank you so much!