llvm_check_compiler_linker_flag used CMAKE_REQUIRED_FLAGS which affects
flags used both for compilation and linking which is problematic because
some flags may be link-only and trigger unused argument warning when set
during compilation.
This change revises the implementation to address the issue, and aligns
llvm_check_compiler_linker_flag with check_linker_flag. Once we switch
to CMake 3.19 we could replace the former with the latter.