pvellien created this revision. pvellien added reviewers: yaxunl, b-sumner. Herald added subscribers: kosarev, kerbowa, tpr, dstuttard, jvesely, kzhuravl. Herald added a project: All. pvellien requested review of this revision. Herald added subscribers: cfe-commits, wdng. Herald added a project: clang.
The asan functions are now attributed as "used" in the device library, no need to keep the declaration of asan device preserve function. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D143495 Files: clang/lib/CodeGen/CodeGenModule.cpp clang/test/CodeGenCUDA/amdgpu-asan.cu Index: clang/test/CodeGenCUDA/amdgpu-asan.cu =================================================================== --- clang/test/CodeGenCUDA/amdgpu-asan.cu +++ /dev/null @@ -1,31 +0,0 @@ -// Create a sample address sanitizer bitcode library. - -// RUN: %clang_cc1 -x ir -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm-bc \ -// RUN: -disable-llvm-passes -o %t.asanrtl.bc %S/Inputs/amdgpu-asanrtl.ll - -// Check sanitizer runtime library functions survive -// optimizations without being removed or parameters altered. - -// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \ -// RUN: -fcuda-is-device -target-cpu gfx906 -fsanitize=address \ -// RUN: -mlink-bitcode-file %t.asanrtl.bc -x hip \ -// RUN: | FileCheck -check-prefixes=ASAN %s - -// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \ -// RUN: -fcuda-is-device -target-cpu gfx906 -fsanitize=address \ -// RUN: -O3 -mlink-bitcode-file %t.asanrtl.bc -x hip \ -// RUN: | FileCheck -check-prefixes=ASAN %s - -// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \ -// RUN: -fcuda-is-device -target-cpu gfx906 -x hip \ -// RUN: | FileCheck %s - -// REQUIRES: amdgpu-registered-target - -// ASAN-DAG: define weak void @__amdgpu_device_library_preserve_asan_functions() -// ASAN-DAG: @__amdgpu_device_library_preserve_asan_functions_ptr = weak addrspace(1) constant ptr @__amdgpu_device_library_preserve_asan_functions -// ASAN-DAG: @llvm.compiler.used = {{.*}}@__amdgpu_device_library_preserve_asan_functions_ptr -// ASAN-DAG: define weak void @__asan_report_load1(i64 %{{.*}}) - -// CHECK-NOT: @__amdgpu_device_library_preserve_asan_functions -// CHECK-NOT: @__asan_report_load1 Index: clang/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -580,20 +580,6 @@ EmitMainVoidAlias(); if (getTriple().isAMDGPU()) { - // Emit reference of __amdgpu_device_library_preserve_asan_functions to - // preserve ASAN functions in bitcode libraries. - if (LangOpts.Sanitize.has(SanitizerKind::Address)) { - auto *FT = llvm::FunctionType::get(VoidTy, {}); - auto *F = llvm::Function::Create( - FT, llvm::GlobalValue::ExternalLinkage, - "__amdgpu_device_library_preserve_asan_functions", &getModule()); - auto *Var = new llvm::GlobalVariable( - getModule(), FT->getPointerTo(), - /*isConstant=*/true, llvm::GlobalValue::WeakAnyLinkage, F, - "__amdgpu_device_library_preserve_asan_functions_ptr", nullptr, - llvm::GlobalVariable::NotThreadLocal); - addCompilerUsedGlobal(Var); - } // Emit amdgpu_code_object_version module flag, which is code object version // times 100. if (getTarget().getTargetOpts().CodeObjectVersion !=
Index: clang/test/CodeGenCUDA/amdgpu-asan.cu =================================================================== --- clang/test/CodeGenCUDA/amdgpu-asan.cu +++ /dev/null @@ -1,31 +0,0 @@ -// Create a sample address sanitizer bitcode library. - -// RUN: %clang_cc1 -x ir -fcuda-is-device -triple amdgcn-amd-amdhsa -emit-llvm-bc \ -// RUN: -disable-llvm-passes -o %t.asanrtl.bc %S/Inputs/amdgpu-asanrtl.ll - -// Check sanitizer runtime library functions survive -// optimizations without being removed or parameters altered. - -// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \ -// RUN: -fcuda-is-device -target-cpu gfx906 -fsanitize=address \ -// RUN: -mlink-bitcode-file %t.asanrtl.bc -x hip \ -// RUN: | FileCheck -check-prefixes=ASAN %s - -// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \ -// RUN: -fcuda-is-device -target-cpu gfx906 -fsanitize=address \ -// RUN: -O3 -mlink-bitcode-file %t.asanrtl.bc -x hip \ -// RUN: | FileCheck -check-prefixes=ASAN %s - -// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \ -// RUN: -fcuda-is-device -target-cpu gfx906 -x hip \ -// RUN: | FileCheck %s - -// REQUIRES: amdgpu-registered-target - -// ASAN-DAG: define weak void @__amdgpu_device_library_preserve_asan_functions() -// ASAN-DAG: @__amdgpu_device_library_preserve_asan_functions_ptr = weak addrspace(1) constant ptr @__amdgpu_device_library_preserve_asan_functions -// ASAN-DAG: @llvm.compiler.used = {{.*}}@__amdgpu_device_library_preserve_asan_functions_ptr -// ASAN-DAG: define weak void @__asan_report_load1(i64 %{{.*}}) - -// CHECK-NOT: @__amdgpu_device_library_preserve_asan_functions -// CHECK-NOT: @__asan_report_load1 Index: clang/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -580,20 +580,6 @@ EmitMainVoidAlias(); if (getTriple().isAMDGPU()) { - // Emit reference of __amdgpu_device_library_preserve_asan_functions to - // preserve ASAN functions in bitcode libraries. - if (LangOpts.Sanitize.has(SanitizerKind::Address)) { - auto *FT = llvm::FunctionType::get(VoidTy, {}); - auto *F = llvm::Function::Create( - FT, llvm::GlobalValue::ExternalLinkage, - "__amdgpu_device_library_preserve_asan_functions", &getModule()); - auto *Var = new llvm::GlobalVariable( - getModule(), FT->getPointerTo(), - /*isConstant=*/true, llvm::GlobalValue::WeakAnyLinkage, F, - "__amdgpu_device_library_preserve_asan_functions_ptr", nullptr, - llvm::GlobalVariable::NotThreadLocal); - addCompilerUsedGlobal(Var); - } // Emit amdgpu_code_object_version module flag, which is code object version // times 100. if (getTarget().getTargetOpts().CodeObjectVersion !=
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits