[libc-commits] [libc] 00d7e67 - [libc] Fix constant address space on global clock
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Mon May 20 16:00:20 PDT 2024
Author: Joseph Huber
Date: 2024-05-20T18:00:05-05:00
New Revision: 00d7e67f8352308288db483f03294460a38a3773
URL: https://github.com/llvm/llvm-project/commit/00d7e67f8352308288db483f03294460a38a3773
DIFF: https://github.com/llvm/llvm-project/commit/00d7e67f8352308288db483f03294460a38a3773.diff
LOG: [libc] Fix constant address space on global clock
Summary:
I did this wrong in the first version, because `extern "C"` doesn't
imply it's extern when used directly.
Added:
Modified:
libc/src/time/gpu/time_utils.cpp
libc/src/time/gpu/time_utils.h
Removed:
################################################################################
diff --git a/libc/src/time/gpu/time_utils.cpp b/libc/src/time/gpu/time_utils.cpp
index 67fe5b4861acc..1a674b2fdca2e 100644
--- a/libc/src/time/gpu/time_utils.cpp
+++ b/libc/src/time/gpu/time_utils.cpp
@@ -15,8 +15,7 @@ namespace LIBC_NAMESPACE {
// insufficient.
// TODO: Once we have another use-case for this we should put it in a common
// device environment struct.
-extern "C" [[gnu::visibility("protected")]] uint64_t __llvm_libc_clock_freq =
- clock_freq;
+gpu::Constant<uint64_t> __llvm_libc_clock_freq = clock_freq;
#endif
} // namespace LIBC_NAMESPACE
diff --git a/libc/src/time/gpu/time_utils.h b/libc/src/time/gpu/time_utils.h
index da713886b6434..77eeb896f6c37 100644
--- a/libc/src/time/gpu/time_utils.h
+++ b/libc/src/time/gpu/time_utils.h
@@ -23,7 +23,10 @@ constexpr uint64_t clock_freq = 100000000UL;
// We provide an externally visible symbol such that the runtime can set
// this to the correct value.
-extern "C" [[gnu::visibility("protected")]] uint64_t __llvm_libc_clock_freq;
+extern "C" {
+[[gnu::visibility("protected")]]
+extern gpu::Constant<uint64_t> __llvm_libc_clock_freq;
+}
#define GPU_CLOCKS_PER_SEC static_cast<clock_t>(__llvm_libc_clock_freq)
#elif defined(LIBC_TARGET_ARCH_IS_NVPTX)
More information about the libc-commits
mailing list