LLVM LTO pass: How to get module name/ output binary name?

I built a llvm-lto pass to collect some callsite metadata from llvm. I am using LLVM 12 with lld to run my pass plugin. I run this pass using following command:

clang++ -flto ex1.cpp -o ex1.o
`clang++ -flto ex2.cpp -o ex2.o`
clang++ -flto -fuse-ld=lld -Wl,-mllvm=-load=myPass.so ex1.o ex2.o -o cool_name.exe`

This gives me desired output. Now the problem is that I want to somehow store the data I get and I want to use cool_name suffix to store my data in a file.

What I have tried -

I use Module.getName() to get the name of final module. But It always gives me ld-temp.o instead of say - cool_name.exe or something. I also tried M.getModuleIdentifier() and M.getSourceFileName(). But it also always gives me ‘ld-temp.o’.

I use following cl::opt<std::string> OutputFilename("o", cl::desc("Specify output filename"), cl::value_desc("filename")); to somehow catch the output file name. But it always return an empty string.

I tried to collect positional args -

cl::list<std::string> InputFilenames(cl::Positional, cl::desc("<Input files>"), cl::OneOrMore, cl::Required);
  for (unsigned i = 0; i != InputFilenames.size(); ++i) {
    errs() << InputFilenames[i] << "\n";

But that gives me empty list.

Lastly, I tried to add an env variable say env=cool_name.exe and then it fetched it using getenv(). This obviously works. But, this is not scalable for bigger programs with lots or output binaries.

How can I achieve this? Thanks so much for reading and appreciate your reply.