[all-commits] [llvm/llvm-project] 0309e5: [Driver] Fix ToolChain::getSanitizerArgs

Yaxun (Sam) Liu via All-commits all-commits at lists.llvm.org
Thu Nov 11 14:17:48 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0309e50f33f616baa8fcac8365b728be3ccf06dd
      https://github.com/llvm/llvm-project/commit/0309e50f33f616baa8fcac8365b728be3ccf06dd
  Author: Yaxun (Sam) Liu <yaxun.liu at amd.com>
  Date:   2021-11-11 (Thu, 11 Nov 2021)

  Changed paths:
    M clang/include/clang/Basic/DiagnosticDriverKinds.td
    M clang/include/clang/Driver/SanitizerArgs.h
    M clang/include/clang/Driver/ToolChain.h
    M clang/lib/Driver/Driver.cpp
    M clang/lib/Driver/SanitizerArgs.cpp
    M clang/lib/Driver/ToolChain.cpp
    M clang/lib/Driver/ToolChains/AIX.h
    M clang/lib/Driver/ToolChains/AMDGPU.h
    M clang/lib/Driver/ToolChains/BareMetal.h
    M clang/lib/Driver/ToolChains/Clang.cpp
    M clang/lib/Driver/ToolChains/CloudABI.cpp
    M clang/lib/Driver/ToolChains/CloudABI.h
    M clang/lib/Driver/ToolChains/CommonArgs.cpp
    M clang/lib/Driver/ToolChains/CrossWindows.cpp
    M clang/lib/Driver/ToolChains/CrossWindows.h
    M clang/lib/Driver/ToolChains/Cuda.h
    M clang/lib/Driver/ToolChains/Darwin.cpp
    M clang/lib/Driver/ToolChains/Darwin.h
    M clang/lib/Driver/ToolChains/FreeBSD.cpp
    M clang/lib/Driver/ToolChains/FreeBSD.h
    M clang/lib/Driver/ToolChains/Fuchsia.cpp
    M clang/lib/Driver/ToolChains/Fuchsia.h
    M clang/lib/Driver/ToolChains/Gnu.cpp
    M clang/lib/Driver/ToolChains/Gnu.h
    M clang/lib/Driver/ToolChains/HIP.cpp
    M clang/lib/Driver/ToolChains/Haiku.h
    M clang/lib/Driver/ToolChains/Linux.cpp
    M clang/lib/Driver/ToolChains/Linux.h
    M clang/lib/Driver/ToolChains/MSP430.h
    M clang/lib/Driver/ToolChains/MSVC.cpp
    M clang/lib/Driver/ToolChains/MSVC.h
    M clang/lib/Driver/ToolChains/MinGW.cpp
    M clang/lib/Driver/ToolChains/MinGW.h
    M clang/lib/Driver/ToolChains/NetBSD.cpp
    M clang/lib/Driver/ToolChains/OpenBSD.h
    M clang/lib/Driver/ToolChains/PS4CPU.cpp
    M clang/lib/Driver/ToolChains/PS4CPU.h
    M clang/lib/Driver/ToolChains/TCE.cpp
    M clang/lib/Driver/ToolChains/TCE.h
    M clang/lib/Driver/ToolChains/VEToolchain.cpp
    M clang/lib/Driver/ToolChains/VEToolchain.h
    M clang/lib/Driver/ToolChains/WebAssembly.cpp
    M clang/lib/Driver/ToolChains/WebAssembly.h
    M clang/lib/Driver/ToolChains/XCore.cpp
    M clang/lib/Driver/ToolChains/XCore.h
    M clang/lib/Driver/ToolChains/ZOS.h
    M clang/test/Driver/hip-sanitize-options.hip

  Log Message:
  -----------
  [Driver] Fix ToolChain::getSanitizerArgs

The driver uses class SanitizerArgs to store parsed sanitizer arguments. It keeps a cached
SanitizerArgs object in ToolChain and uses it for different jobs. This does not work if
the sanitizer options are different for different jobs, which could happen when an
offloading toolchain translates the options for different jobs.

To fix this, SanitizerArgs should be created by using the actual arguments passed
to jobs instead of the original arguments passed to the driver, since the toolchain
may change the original arguments. And the sanitizer arguments should be diagnose
once.

This patch also fixes HIP toolchain for handling -fgpu-sanitize: a warning is emitted
for GPU's not supporting sanitizer and skipped. This is for backward compatibility
with existing -fsanitize options. -fgpu-sanitize is also turned on by default.

Reviewed by: Artem Belevich, Evgenii Stepanov

Differential Revision: https://reviews.llvm.org/D111443




More information about the All-commits mailing list