From 73b64ddb4709652d7413752c12aea0a841f96e65 Mon Sep 17 00:00:00 2001 From: Corbin Robeck Date: Thu, 12 Dec 2024 18:02:10 +0000 Subject: [PATCH] move some target specfific code to the backend --- python/src/llvm.cc | 6 ------ third_party/amd/backend/compiler.py | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/python/src/llvm.cc b/python/src/llvm.cc index d2a864b5dce7e..8872935b22222 100644 --- a/python/src/llvm.cc +++ b/python/src/llvm.cc @@ -390,12 +390,6 @@ void init_triton_llvm(py::module &&m) { "support on the AMD backend\n"; throw std::runtime_error(ErrMsg); } - for (llvm::Function &f : mod->functions()) { - if (f.isIntrinsic() || f.isDeclaration()) - continue; - f.addFnAttr("target-features", "+xnack"); - f.addFnAttr(llvm::Attribute::SanitizeAddress); - } AddressSanitizerOptions Opts; mpm.addPass(AddressSanitizerPass(Opts)); } diff --git a/third_party/amd/backend/compiler.py b/third_party/amd/backend/compiler.py index 5b2787f6552c8..74a6dccff432a 100644 --- a/third_party/amd/backend/compiler.py +++ b/third_party/amd/backend/compiler.py @@ -335,6 +335,9 @@ def make_llir(src, metadata, options): fns[0].add_fn_attr("amdgpu-waves-per-eu", f"{options.waves_per_eu}") denormal_mode = "preserve-sign" if options.allow_flush_denorm else "ieee" fns[0].add_fn_attr("denormal-fp-math-f32", denormal_mode) + if os.environ.get("TRITON_ENABLE_ASAN", "0") == "1": + fns[0].add_fn_attr("target-features", target_features) + fns[0].add_fn_attr("sanitize_address") # Hint the compiler that we'd like the firmware to set the kernel arguments # to user SGPRs so that the kernel does not need to s_load its arguments