[PATCH] D159319: [AIX] Add threadId and use nanosecond timestamp in sinit/sterm symbols
wael yehia via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 7 10:47:23 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG11d5c7bd289c: [AIX] Add threadId and use nanosecond timestamp in sinit/sterm symbols (authored by w2yehia).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D159319/new/
https://reviews.llvm.org/D159319
Files:
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
llvm/test/CodeGen/PowerPC/aix-static-init-no-unique-module-id.ll
Index: llvm/test/CodeGen/PowerPC/aix-static-init-no-unique-module-id.ll
===================================================================
--- llvm/test/CodeGen/PowerPC/aix-static-init-no-unique-module-id.ll
+++ llvm/test/CodeGen/PowerPC/aix-static-init-no-unique-module-id.ll
@@ -7,18 +7,16 @@
ret void
}
-; FIXME: Adjust the comment after we use source file full path to generate unique
-; module id instead.
-; Use the Pid and timestamp to generate a unique module id when strong external
+; Use the Pid, threadId, and timestamp to generate a unique module id when strong external
; symbols are not available in current module. The module id generated in this
; way is not reproducible. A function name sample would be:
-; __sinit80000000_clangPidTime_119189_1597348415_0
+; __sinit80000000_clangPidTidTime_56689326_1_57027228417827568_0
; CHECK: .lglobl foo[DS]
; CHECK: .lglobl .foo
; CHECK: .csect foo[DS]
-; CHECK-NEXT: __sinit80000000_clangPidTime_[[PID:[0-9]+]]_[[TIMESTAMP:[0-9]+]]_0:
+; CHECK-NEXT: __sinit80000000_clangPidTidTime_[[PID:[0-9]+]]_[[TID:[0-9]+]]_[[TIMESTAMP:[0-9]+]]_0:
; CHECK: .foo:
-; CHECK-NEXT: .__sinit80000000_clangPidTime_[[PID]]_[[TIMESTAMP]]_0:
-; CHECK: .globl __sinit80000000_clangPidTime_[[PID]]_[[TIMESTAMP]]_0
-; CHECK: .globl .__sinit80000000_clangPidTime_[[PID]]_[[TIMESTAMP]]_0
+; CHECK-NEXT: .__sinit80000000_clangPidTidTime_[[PID]]_[[TID]]_[[TIMESTAMP]]_0:
+; CHECK: .globl __sinit80000000_clangPidTidTime_[[PID]]_[[TID]]_[[TIMESTAMP]]_0
+; CHECK: .globl .__sinit80000000_clangPidTidTime_[[PID]]_[[TID]]_[[TIMESTAMP]]_0
Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -68,6 +68,7 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/thread.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/TargetParser/Triple.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
@@ -2740,14 +2741,18 @@
// and add a format indicator as a part of function name in case we
// will support more than one format.
FormatIndicatorAndUniqueModId = "clang_" + UniqueModuleId.substr(1);
- else
- // Use the Pid and current time as the unique module id when we cannot
- // generate one based on a module's strong external symbols.
- // FIXME: Adjust the comment accordingly after we use source file full
- // path instead.
+ else {
+ // Use threadId, Pid, and current time as the unique module id when we
+ // cannot generate one based on a module's strong external symbols.
+ auto CurTime =
+ std::chrono::duration_cast<std::chrono::nanoseconds>(
+ std::chrono::steady_clock::now().time_since_epoch())
+ .count();
FormatIndicatorAndUniqueModId =
- "clangPidTime_" + llvm::itostr(sys::Process::getProcessId()) +
- "_" + llvm::itostr(time(nullptr));
+ "clangPidTidTime_" + llvm::itostr(sys::Process::getProcessId()) +
+ "_" + llvm::itostr(llvm::this_thread::get_id()) + "_" +
+ llvm::itostr(CurTime);
+ }
}
emitSpecialLLVMGlobal(&G);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D159319.556179.patch
Type: text/x-patch
Size: 3462 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230907/e08b318a/attachment.bin>
More information about the llvm-commits
mailing list