1 /*========================== begin_copyright_notice ============================
2 
3 Copyright (C) 2018-2021 Intel Corporation
4 
5 SPDX-License-Identifier: MIT
6 
7 ============================= end_copyright_notice ===========================*/
8 
9 #pragma once
10 
11 #include "llvm/Config/llvm-config.h"
12 #include "common/LLVMWarningsPush.hpp"
13 #include "common/LLVMWarningsPop.hpp"
14 #include "Compiler/IGCPassSupport.h"
15 #include "DebugInfo/VISAModule.hpp"
16 #include "DebugInfo/VISAIDebugEmitter.hpp"
17 #include "ShaderCodeGen.hpp"
18 #include "Compiler/IGCPassSupport.h"
19 #include "llvm/IR/DIBuilder.h"
20 #include "Probe/Assertion.h"
21 
22 using namespace llvm;
23 using namespace IGC;
24 using namespace IGC::IGCMD;
25 using namespace std;
26 
27 namespace IGC
28 {
29     class DbgDecoder;
30     class CVariable;
31 
32     class DebugInfoPass : public llvm::ModulePass
33     {
34     public:
35         DebugInfoPass(CShaderProgram::KernelShaderMap&);
getPassName() const36         virtual llvm::StringRef getPassName() const  override { return "DebugInfoPass"; }
37         virtual ~DebugInfoPass();
38 
39     private:
40         static char ID;
41         CShaderProgram::KernelShaderMap& kernels;
42         CShader* m_currShader = nullptr;
43         IDebugEmitter* m_pDebugEmitter = nullptr;
44 
45         virtual bool runOnModule(llvm::Module& M) override;
46         virtual bool doInitialization(llvm::Module& M) override;
47         virtual bool doFinalization(llvm::Module& M) override;
48 
getAnalysisUsage(llvm::AnalysisUsage & AU) const49         virtual void getAnalysisUsage(llvm::AnalysisUsage& AU) const override
50         {
51             AU.addRequired<MetaDataUtilsWrapper>();
52             AU.setPreservesAll();
53         }
54 
55         void EmitDebugInfo(bool, DbgDecoder*);
56     };
57 
58     class CatchAllLineNumber : public llvm::FunctionPass
59     {
60     public:
61         CatchAllLineNumber();
62         virtual ~CatchAllLineNumber();
63         static char ID;
64 
getPassName() const65         llvm::StringRef getPassName() const override {
66             return "CatchAllLineNumber";
67         }
68 
69     private:
70 
71         virtual bool runOnFunction(llvm::Function& F) override;
72 
getAnalysisUsage(llvm::AnalysisUsage & AU) const73         virtual void getAnalysisUsage(llvm::AnalysisUsage& AU) const override
74         {
75             AU.setPreservesAll();
76         }
77     };
78 };
79