1
+ /* ===================== begin_copyright_notice ==================================
2
+
3
+ Copyright (c) 2017 Intel Corporation
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a
6
+ copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included
14
+ in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+
25
+ ======================= end_copyright_notice ==================================*/
26
+
27
+ #include " AnnotateUniformAllocas.h"
28
+ #include " Compiler/IGCPassSupport.h"
29
+ #include " IGCIRBuilder.h"
30
+ #include " common/LLVMWarningsPush.hpp"
31
+ #include < llvm/IR/Function.h>
32
+ #include " common/LLVMWarningsPop.hpp"
33
+
34
+ using namespace llvm ;
35
+ using namespace IGC ;
36
+
37
+ #define PASS_FLAG " annotate_uniform_allocas"
38
+ #define PASS_DESCRIPTION " Annotate uniform allocas"
39
+ #define PASS_CFG_ONLY false
40
+ #define PASS_ANALYSIS false
41
+ IGC_INITIALIZE_PASS_BEGIN (AnnotateUniformAllocas, PASS_FLAG, PASS_DESCRIPTION, PASS_CFG_ONLY, PASS_ANALYSIS)
42
+ IGC_INITIALIZE_PASS_END(AnnotateUniformAllocas, PASS_FLAG, PASS_DESCRIPTION, PASS_CFG_ONLY, PASS_ANALYSIS)
43
+
44
+ namespace IGC
45
+ {
46
+ char AnnotateUniformAllocas::ID = 0 ;
47
+
48
+ AnnotateUniformAllocas::AnnotateUniformAllocas () : FunctionPass (ID)
49
+ {
50
+ initializeAnnotateUniformAllocasPass (*PassRegistry::getPassRegistry ());
51
+ }
52
+
53
+ llvm::FunctionPass* createAnnotateUniformAllocasPass ()
54
+ {
55
+ return new AnnotateUniformAllocas ();
56
+ }
57
+
58
+ bool AnnotateUniformAllocas::runOnFunction (Function& F)
59
+ {
60
+ WI = &getAnalysis<WIAnalysis>();
61
+ IGC_ASSERT (WI != nullptr );
62
+ visit (F);
63
+ return m_changed;
64
+ }
65
+
66
+ void AnnotateUniformAllocas::visitAllocaInst (AllocaInst& I)
67
+ {
68
+ bool isUniformAlloca = WI->whichDepend (&I) == WIAnalysis::UNIFORM;
69
+ if (isUniformAlloca)
70
+ {
71
+ IRBuilder<> builder (&I);
72
+ MDNode* node = MDNode::get (I.getContext (), ConstantAsMetadata::get (builder.getInt1 (true )));
73
+ I.setMetadata (" uniform" , node);
74
+ m_changed = true ;
75
+ }
76
+ }
77
+ }
0 commit comments