aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorJoseph Huber <huberjn@outlook.com>2025-02-10 14:25:44 -0600
committerGitHub <noreply@github.com>2025-02-10 14:25:44 -0600
commit3d9409f5bc413b12acf95b4a6c2a5c8860d95d7c (patch)
tree6896e8775154e2a979075ba120d45c331c4b9490 /llvm/lib
parentf332455dd9a2b2b3ecb20f28349673313c5b440b (diff)
downloadllvm-3d9409f5bc413b12acf95b4a6c2a5c8860d95d7c.zip
llvm-3d9409f5bc413b12acf95b4a6c2a5c8860d95d7c.tar.gz
llvm-3d9409f5bc413b12acf95b4a6c2a5c8860d95d7c.tar.bz2
[NVPTX] Make ctor/dtor lowering always enabled in NVPTX (#126544)
Summary: Currently we conditionally enable NVPTX lowering depending on the language (C/C++/OpenMP). Unfortunately this causes problems because this option is only present if the backend was enabled, which causes this to error if you try to make LLVM-IR. This patch instead makes it the only accepted lowering. The reason we had it as opt-in before is because it is not handled by CUDA. So, this pach also introduces diagnostics to prevent *all* creation of device-side global constructors and destructors. We already did this for variables, now we do it for attributes as well. This inverts the responsibility of blocking this from the backend to the langauage like it should be given that support for this is language dependent.
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp21
1 files changed, 0 insertions, 21 deletions
diff --git a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
index ad14338..68a0f4c 100644
--- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -91,11 +91,6 @@
using namespace llvm;
-static cl::opt<bool>
- LowerCtorDtor("nvptx-lower-global-ctor-dtor",
- cl::desc("Lower GPU ctor / dtors to globals on the device."),
- cl::init(false), cl::Hidden);
-
#define DEPOTNAME "__local_depot"
/// DiscoverDependentGlobals - Return a set of GlobalVariables on which \p V
@@ -794,22 +789,6 @@ bool NVPTXAsmPrinter::doInitialization(Module &M) {
if (M.alias_size() && (STI.getPTXVersion() < 63 || STI.getSmVersion() < 30))
report_fatal_error(".alias requires PTX version >= 6.3 and sm_30");
- // OpenMP supports NVPTX global constructors and destructors.
- bool IsOpenMP = M.getModuleFlag("openmp") != nullptr;
-
- if (!isEmptyXXStructor(M.getNamedGlobal("llvm.global_ctors")) &&
- !LowerCtorDtor && !IsOpenMP) {
- report_fatal_error(
- "Module has a nontrivial global ctor, which NVPTX does not support.");
- return true; // error
- }
- if (!isEmptyXXStructor(M.getNamedGlobal("llvm.global_dtors")) &&
- !LowerCtorDtor && !IsOpenMP) {
- report_fatal_error(
- "Module has a nontrivial global dtor, which NVPTX does not support.");
- return true; // error
- }
-
// We need to call the parent's one explicitly.
bool Result = AsmPrinter::doInitialization(M);