SWDEV-430963 - Address MIGraphX failures due to unsafe buffer access usage

Compiler seem to be stricter in compiler staging builds related to
safe buffer programming when compared to other component staging builds.
This seem to result in additional errors when -Werror is enabled
in MIGraphX tests.

Removes all the clang pragmas to ignore several type of warnings in all
the headers and adds a single pragma which ignores all warnings using
#pragma clang diagnostic ignored "-Weverything" in hiprtc builtins.

Change-Id: I95f302bb285b2451b19dd5dfdb7df29164b0f750
Этот коммит содержится в:
Satyanvesh Dittakavi
2023-11-07 09:15:32 +00:00
родитель 9fdee05aee
Коммит b5d286a6d3
17 изменённых файлов: 7 добавлений и 221 удалений
-9
Просмотреть файл
@@ -23,11 +23,6 @@ THE SOFTWARE.
#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_CHANNEL_DESCRIPTOR_H
#define HIP_INCLUDE_HIP_AMD_DETAIL_CHANNEL_DESCRIPTOR_H
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wold-style-cast"
#endif
#if !defined(__HIPCC_RTC__)
#include <hip/hip_common.h>
#include <hip/driver_types.h>
@@ -360,8 +355,4 @@ struct hipChannelFormatDesc hipCreateChannelDesc(int x, int y, int z, int w,
#endif /* __cplusplus */
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
#endif /* !HIP_INCLUDE_HIP_AMD_DETAIL_CHANNEL_DESCRIPTOR_H */
-27
Просмотреть файл
@@ -23,22 +23,6 @@ THE SOFTWARE.
#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_DEVICE_FUNCTIONS_H
#define HIP_INCLUDE_HIP_AMD_DETAIL_DEVICE_FUNCTIONS_H
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-macro-identifier"
#pragma clang diagnostic ignored "-Wreserved-identifier"
#pragma clang diagnostic ignored "-Wsign-conversion"
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
#pragma clang diagnostic ignored "-Wold-style-cast"
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
#pragma clang diagnostic ignored "-Wimplicit-int-conversion"
#pragma clang diagnostic ignored "-Wimplicit-float-conversion"
#pragma clang diagnostic ignored "-Wmissing-noreturn"
#pragma clang diagnostic ignored "-Wimplicit-fallthrough"
#pragma clang diagnostic ignored "-Wunneeded-internal-declaration"
#pragma clang diagnostic ignored "-Wshift-count-overflow"
#endif
#if !defined(__HIPCC_RTC__)
#include <hip/amd_detail/amd_hip_common.h>
#include "host_defines.h"
@@ -459,10 +443,6 @@ __device__ static inline unsigned long long int __double2ull_ru(double x) {
__device__ static inline unsigned long long int __double2ull_rz(double x) {
return (unsigned long long int)x;
}
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
#endif
__device__ static inline long long int __double_as_longlong(double x) {
static_assert(sizeof(long long) == sizeof(double), "");
@@ -471,9 +451,6 @@ __device__ static inline long long int __double_as_longlong(double x) {
return tmp;
}
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
/*
__device__ unsigned short __float2half_rn(float x);
@@ -1121,8 +1098,4 @@ static inline __device__ void* memset(void* ptr, int val, size_t size) {
}
#endif // !__OPENMP_AMDGCN__
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
#endif
-12
Просмотреть файл
@@ -22,14 +22,6 @@ THE SOFTWARE.
#pragma once
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++98-compat"
#pragma clang diagnostic ignored "-Wold-style-cast"
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
#pragma clang diagnostic ignored "-Wsign-conversion"
#endif
#if !defined(__HIPCC_RTC__)
#include "amd_device_functions.h"
#endif
@@ -1635,8 +1627,4 @@ unsigned long long atomicXor(
return __atomic_fetch_xor(address, val, __ATOMIC_RELAXED);
}
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
#endif // __hip_atomic_compare_exchange_strong
-16
Просмотреть файл
@@ -25,18 +25,6 @@ THE SOFTWARE.
#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COMPLEX_H
#define HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COMPLEX_H
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wfloat-equal"
#pragma clang diagnostic ignored "-Wc++98-compat"
#pragma clang diagnostic ignored "-Wold-style-cast"
#pragma clang diagnostic ignored "-Wreserved-macro-identifier"
#pragma clang diagnostic ignored "-Wimplicit-int-float-conversion"
#pragma clang diagnostic ignored "-Wimplicit-float-conversion"
#pragma clang diagnostic ignored "-Wdouble-promotion"
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
#endif
#if !defined(__HIPCC_RTC__)
#include "hip/amd_detail/amd_hip_vector_types.h"
#endif
@@ -183,8 +171,4 @@ __HOST_DEVICE__ static inline hipDoubleComplex hipCfma(hipDoubleComplex p, hipDo
return make_hipDoubleComplex(real, imag);
}
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
#endif //HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COMPLEX_H
-13
Просмотреть файл
@@ -32,15 +32,6 @@ THE SOFTWARE.
#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COOPERATIVE_GROUPS_H
#define HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COOPERATIVE_GROUPS_H
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++98-compat"
#pragma clang diagnostic ignored "-Wsign-conversion"
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wreserved-macro-identifier"
#pragma clang diagnostic ignored "-Wpadded"
#endif
#if __cplusplus
#if !defined(__HIPCC_RTC__)
#include <hip/amd_detail/hip_cooperative_groups_helper.h>
@@ -842,9 +833,5 @@ __CG_QUALIFIER__ thread_block_tile<size, ParentCGTy> tiled_partition(const Paren
}
} // namespace cooperative_groups
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
#endif // __cplusplus
#endif // HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COOPERATIVE_GROUPS_H
-18
Просмотреть файл
@@ -24,20 +24,6 @@ THE SOFTWARE.
#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_HIP_FP16_H
#define HIP_INCLUDE_HIP_AMD_DETAIL_HIP_FP16_H
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-identifier"
#pragma clang diagnostic ignored "-Wreserved-macro-identifier"
#pragma clang diagnostic ignored "-Wc++98-compat"
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
#pragma clang diagnostic ignored "-Wsign-conversion"
#pragma clang diagnostic ignored "-Wfloat-conversion"
#pragma clang diagnostic ignored "-Wdouble-promotion"
#pragma clang diagnostic ignored "-Wnested-anon-types"
#pragma clang diagnostic ignored "-Wgnu-anonymous-struct"
#pragma clang diagnostic ignored "-Wfloat-equal"
#endif
#if defined(__HIPCC_RTC__)
#define __HOST_DEVICE__ __device__
#else
@@ -1820,8 +1806,4 @@ THE SOFTWARE.
#endif
#endif // !defined(__clang__) && defined(__GNUC__)
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
#endif // HIP_INCLUDE_HIP_AMD_DETAIL_HIP_FP16_H
-9
Просмотреть файл
@@ -24,11 +24,6 @@ THE SOFTWARE.
#ifdef __cplusplus
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wold-style-cast"
#endif
/**
* @brief Unsafe floating point rmw atomic add.
*
@@ -567,8 +562,4 @@ __device__ inline double safeAtomicMin(double* addr, double val) {
#endif
}
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
#endif
-10
Просмотреть файл
@@ -22,12 +22,6 @@ THE SOFTWARE.
#pragma once
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundef"
#pragma clang diagnostic ignored "-Wreserved-macro-identifier"
#endif
#if !defined(__HIPCC_RTC__)
#include "hip_fp16_math_fwd.h"
#include "amd_hip_vector_types.h"
@@ -108,7 +102,3 @@ uint amd_mixed_dot(uint a, uint b, uint c, bool saturate) {
#if !defined(__HIPCC_RTC__)
#include <hip/amd_detail/amd_hip_runtime.h>
#endif
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
-17
Просмотреть файл
@@ -23,19 +23,6 @@ THE SOFTWARE.
#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_SURFACE_FUNCTIONS_H
#define HIP_INCLUDE_HIP_AMD_DETAIL_SURFACE_FUNCTIONS_H
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-macro-identifier"
#pragma clang diagnostic ignored "-Wc++17-extensions"
#pragma clang diagnostic ignored "-Wreserved-identifier"
#pragma clang diagnostic ignored "-Wc++98-compat"
#pragma clang diagnostic ignored "-Wold-style-cast"
#pragma clang diagnostic ignored "-Wextra-semi-stmt"
#pragma clang diagnostic ignored "-Wunused-variable"
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wunused-template"
#endif
#if defined(__cplusplus)
#if !defined(__HIPCC_RTC__)
@@ -254,8 +241,4 @@ static __device__ __hip_img_chk__ void surfCubemapLayeredwrite(T* data, hipSurfa
#endif
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
#endif
-15
Просмотреть файл
@@ -23,17 +23,6 @@ THE SOFTWARE.
#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_WARP_FUNCTIONS_H
#define HIP_INCLUDE_HIP_AMD_DETAIL_WARP_FUNCTIONS_H
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-identifier"
#pragma clang diagnostic ignored "-Wreserved-macro-identifier"
#pragma clang diagnostic ignored "-Wsign-conversion"
#pragma clang diagnostic ignored "-Wold-style-cast"
#pragma clang diagnostic ignored "-Wc++98-compat"
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
#endif
__device__ static inline unsigned __hip_ds_bpermute(int index, unsigned src) {
union { int i; unsigned u; float f; } tmp; tmp.u = src;
tmp.i = __builtin_amdgcn_ds_bpermute(index, tmp.i);
@@ -502,8 +491,4 @@ unsigned long long __shfl_xor(unsigned long long var, int lane_mask, int width =
return tmp1;
}
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
#endif
-11
Просмотреть файл
@@ -31,13 +31,6 @@ THE SOFTWARE.
#ifndef HIP_INCLUDE_HIP_AMD_DETAIL_DEVICE_LIBRARY_DECLS_H
#define HIP_INCLUDE_HIP_AMD_DETAIL_DEVICE_LIBRARY_DECLS_H
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
#pragma clang diagnostic ignored "-Wreserved-identifier"
#pragma clang diagnostic ignored "-Wold-style-cast"
#endif
#if !defined(__HIPCC_RTC__)
#include "hip/amd_detail/host_defines.h"
#endif
@@ -137,8 +130,4 @@ __device__ inline static __local void* __to_local(unsigned x) { return (__local
#define __CLK_LOCAL_MEM_FENCE 0x01
typedef unsigned __cl_mem_fence_flags;
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
#endif
-11
Просмотреть файл
@@ -40,14 +40,6 @@ THE SOFTWARE.
#define __align__(x) __attribute__((aligned(x)))
#endif
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-macro-identifier"
#pragma clang diagnostic ignored "-Wc++98-compat"
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
#endif
#if !defined(__CG_QUALIFIER__)
#define __CG_QUALIFIER__ __device__ __forceinline__
#endif
@@ -247,9 +239,6 @@ __CG_STATIC_QUALIFIER__ unsigned int masked_bit_count(lane_mask x, unsigned int
/**
* @}
*/
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
#endif // __cplusplus
#endif // HIP_INCLUDE_HIP_AMD_DETAIL_HIP_COOPERATIVE_GROUPS_HELPER_H
-10
Просмотреть файл
@@ -22,12 +22,6 @@ THE SOFTWARE.
#pragma once
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundef"
#pragma clang diagnostic ignored "-Wreserved-identifier"
#endif
#if !defined(__HIPCC_RTC__)
#include "host_defines.h"
#include "amd_hip_vector_types.h" // For Native_vec_
@@ -702,7 +696,3 @@ double __ocml_fma_rtz_f64(double, double, double);
#if defined(__cplusplus)
} // extern "C"
#endif
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
-9
Просмотреть файл
@@ -22,11 +22,6 @@ THE SOFTWARE.
#pragma once
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-identifier"
#endif
#if !defined(__HIPCC_RTC__)
#include <hip/hip_vector_types.h>
#endif
@@ -180,7 +175,3 @@ __device__ int __ockl_image_channel_order_CM(unsigned int ADDRESS_SPACE_CONSTANT
__device__ int __ockl_image_channel_order_CMa(unsigned int ADDRESS_SPACE_CONSTANT* i);
}
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
-16
Просмотреть файл
@@ -22,18 +22,6 @@ THE SOFTWARE.
#pragma once
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++17-extensions"
#pragma clang diagnostic ignored "-Wreserved-identifier"
#pragma clang diagnostic ignored "-Wc++98-compat"
#pragma clang diagnostic ignored "-Wold-style-cast"
#pragma clang diagnostic ignored "-Wextra-semi-stmt"
#pragma clang diagnostic ignored "-Wunused-variable"
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wunused-template"
#endif
#if defined(__cplusplus)
#if !defined(__HIPCC_RTC__)
@@ -501,7 +489,3 @@ static __forceinline__ __device__ __hip_img_chk__ __hip_tex2dgather_ret_t<T, rea
}
#endif
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
-15
Просмотреть файл
@@ -22,17 +22,6 @@ THE SOFTWARE.
#pragma once
#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++17-extensions"
#pragma clang diagnostic ignored "-Wreserved-identifier"
#pragma clang diagnostic ignored "-Wc++98-compat"
#pragma clang diagnostic ignored "-Wold-style-cast"
#pragma clang diagnostic ignored "-Wunused-variable"
#pragma clang diagnostic ignored "-Wunused-parameter"
#pragma clang diagnostic ignored "-Wunused-template"
#endif
#if defined(__cplusplus)
#if !defined(__HIPCC_RTC__)
@@ -487,7 +476,3 @@ static __device__ __hip_img_chk__ void texCubemapLayeredGrad(T *ptr, hipTextureO
}
#endif
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
+7 -3
Просмотреть файл
@@ -86,11 +86,16 @@ endfunction(get_hiprtc_macros)
# To allow concatenating above macros during build time, call this file in script mode.
if(HIPRTC_ADD_MACROS)
# Read the existing content of the preprocessed file into a temporary variable
FILE(READ "${HIPRTC_PREPROCESSED_FILE}" ORIGINAL_PREPROCESSED_FILE)
# Prepend the pragma to the original content
set(MODIFIED_PREPROCESSED_FILE "#pragma clang diagnostic ignored \"-Weverything\"
\n${ORIGINAL_PREPROCESSED_FILE}")
# Write the modified preprocessed content back to the original file
FILE(WRITE ${HIPRTC_PREPROCESSED_FILE} "${MODIFIED_PREPROCESSED_FILE}")
message(STATUS "Appending hiprtc macros to ${HIPRTC_PREPROCESSED_FILE}.")
get_hiprtc_macros(HIPRTC_DEFINES)
FILE(APPEND ${HIPRTC_PREPROCESSED_FILE} "${HIPRTC_DEFINES}")
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-macro-identifier"
set(HIPRTC_HEADER_LIST ${HIPRTC_HEADERS})
separate_arguments(HIPRTC_HEADER_LIST)
# appends all the headers from the list to the hiprtc preprocessed file
@@ -98,7 +103,6 @@ if(HIPRTC_ADD_MACROS)
FILE(READ "${header}" HEADER_FILE)
FILE(APPEND ${HIPRTC_PREPROCESSED_FILE} "${HEADER_FILE}")
endforeach()
#pragma clang diagnostic pop
endif()
macro(generate_hiprtc_header HiprtcHeader)