================ @@ -0,0 +1,170 @@ +//===-- AMDGPUTargetVerifier.cpp - AMDGPU -----------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines target verifier interfaces that can be used for some +// validation of input to the system, and for checking that transformations +// haven't done something bad. In contrast to the Verifier or Lint, the +// TargetVerifier looks for constructions invalid to a particular target +// machine. +// +// To see what specifically is checked, look at an individual backend's +// TargetVerifier. +// +//===----------------------------------------------------------------------===// + +#include "AMDGPU.h" + +#include "llvm/IR/Function.h" +#include "llvm/IR/IntrinsicInst.h" +#include "llvm/IR/IntrinsicsAMDGPU.h" +#include "llvm/IR/Module.h" +#include "llvm/IR/Value.h" +#include "llvm/Support/Debug.h" + +#include "llvm/Support/raw_ostream.h" + +using namespace llvm; + +// Check - We know that cond should be true, if not print an error message. +#define Check(C, ...) \ + do { \ + if (!(C)) { \ + TargetVerify::checkFailed(__VA_ARGS__); \ + } \ + } while (false) + +namespace llvm { + +class AMDGPUTargetVerify : public TargetVerify { +public: + AMDGPUTargetVerify(Module *Mod) : TargetVerify(Mod) {} + bool run(Function &F) override; +}; + +static bool isShader(CallingConv::ID CC) { + switch (CC) { + case CallingConv::AMDGPU_VS: + case CallingConv::AMDGPU_LS: + case CallingConv::AMDGPU_HS: + case CallingConv::AMDGPU_ES: + case CallingConv::AMDGPU_GS: + case CallingConv::AMDGPU_PS: + case CallingConv::AMDGPU_CS_Chain: + case CallingConv::AMDGPU_CS_ChainPreserve: + case CallingConv::AMDGPU_CS: + return true; + default: + return false; + } +} + +bool AMDGPUTargetVerify::run(Function &F) { + // Ensure shader calling convention returns void + if (isShader(F.getCallingConv())) ---------------- shiltian wrote:
Based on previous discussion with @arsenm , this check should go to the IR verifier. https://github.com/llvm/llvm-project/pull/123609 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits