1 /*========================== begin_copyright_notice ============================ 2 3 Copyright (C) 2017-2021 Intel Corporation 4 5 SPDX-License-Identifier: MIT 6 7 ============================= end_copyright_notice ===========================*/ 8 9 #pragma once 10 #include "Compiler/CodeGenContextWrapper.hpp" 11 12 #include "common/LLVMWarningsPush.hpp" 13 #include <llvm/Pass.h> 14 #include <llvm/IR/InstVisitor.h> 15 #include <llvm/ADT/DenseSet.h> 16 #include "common/LLVMWarningsPop.hpp" 17 18 namespace IGC 19 { 20 /// @brief This pass unset fast math flag on all instructions which influence position output 21 class PositionDepAnalysis : public llvm::FunctionPass, public llvm::InstVisitor<PositionDepAnalysis> 22 { 23 public: 24 /// @brief Pass identification. 25 static char ID; 26 27 PositionDepAnalysis(); 28 ~PositionDepAnalysis()29 ~PositionDepAnalysis() {} 30 31 void visitCallInst(llvm::CallInst& I); 32 getPassName() const33 virtual llvm::StringRef getPassName() const override 34 { 35 return "SetMathPrecisionForPositionOutput"; 36 } 37 38 virtual bool runOnFunction(llvm::Function& F) override; 39 getAnalysisUsage(llvm::AnalysisUsage & AU) const40 virtual void getAnalysisUsage(llvm::AnalysisUsage& AU) const override 41 { 42 AU.setPreservesAll(); 43 AU.addRequired<CodeGenContextWrapper>(); 44 } 45 bool PositionDependsOnInst(llvm::Instruction* inst); 46 private: 47 void UpdateDependency(llvm::Instruction* inst); 48 llvm::DenseSet<llvm::Instruction*> m_PositionDep; 49 }; 50 51 } // namespace IGC 52