|
68 | 68 | #include "llvm/Support/ErrorHandling.h"
|
69 | 69 | #include "llvm/Support/Process.h"
|
70 | 70 | #include "llvm/Support/raw_ostream.h"
|
| 71 | +#include "llvm/Support/thread.h" |
71 | 72 | #include "llvm/Target/TargetMachine.h"
|
72 | 73 | #include "llvm/TargetParser/Triple.h"
|
73 | 74 | #include "llvm/Transforms/Utils/ModuleUtils.h"
|
@@ -2740,14 +2741,18 @@ bool PPCAIXAsmPrinter::doInitialization(Module &M) {
|
2740 | 2741 | // and add a format indicator as a part of function name in case we
|
2741 | 2742 | // will support more than one format.
|
2742 | 2743 | FormatIndicatorAndUniqueModId = "clang_" + UniqueModuleId.substr(1);
|
2743 |
| - else |
2744 |
| - // Use the Pid and current time as the unique module id when we cannot |
2745 |
| - // generate one based on a module's strong external symbols. |
2746 |
| - // FIXME: Adjust the comment accordingly after we use source file full |
2747 |
| - // path instead. |
| 2744 | + else { |
| 2745 | + // Use threadId, Pid, and current time as the unique module id when we |
| 2746 | + // cannot generate one based on a module's strong external symbols. |
| 2747 | + auto CurTime = |
| 2748 | + std::chrono::duration_cast<std::chrono::nanoseconds>( |
| 2749 | + std::chrono::steady_clock::now().time_since_epoch()) |
| 2750 | + .count(); |
2748 | 2751 | FormatIndicatorAndUniqueModId =
|
2749 |
| - "clangPidTime_" + llvm::itostr(sys::Process::getProcessId()) + |
2750 |
| - "_" + llvm::itostr(time(nullptr)); |
| 2752 | + "clangPidTidTime_" + llvm::itostr(sys::Process::getProcessId()) + |
| 2753 | + "_" + llvm::itostr(llvm::this_thread::get_id()) + "_" + |
| 2754 | + llvm::itostr(CurTime); |
| 2755 | + } |
2751 | 2756 | }
|
2752 | 2757 |
|
2753 | 2758 | emitSpecialLLVMGlobal(&G);
|
|
0 commit comments