summaryrefslogtreecommitdiff
blob: 248f8244e32f0f2d9db8b153919e3a4b68c21261 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
From d9535cc5c3e54b21d56c492d4e21cb13c80b9b7a Mon Sep 17 00:00:00 2001
From: Artem Gindinson <artem.gindinson@intel.com>
Date: Wed, 22 Jun 2022 11:53:02 +0000
Subject: [PATCH]  Update RayTracing for full LLVM 14 buildability

- Address further casting issues
- Use pre-existing LLVM wrappers for function argument manipulations
- Create & use LLVM wrappers for `AAQueryInfo` and
  `CallBase::getRetDereferenceableBytes()`
---
 IGC/AdaptorCommon/RayTracing/AllocaTracking.cpp          | 3 ++-
 IGC/AdaptorCommon/RayTracing/InlineDataPass.cpp          | 3 ++-
 IGC/AdaptorCommon/RayTracing/LowerIntersectionAnyHit.cpp | 2 +-
 IGC/AdaptorCommon/RayTracing/RTSpillShrinkPass.cpp       | 4 ++--
 IGC/AdaptorCommon/RayTracing/RayTracingFinalizePass.cpp  | 4 ++--
 IGC/AdaptorCommon/RayTracing/StackIDSchedulingPass.cpp   | 3 ++-
 IGC/AdaptorCommon/TypesLegalizationPass.cpp              | 2 +-
 .../include/llvmWrapper/Analysis/AliasAnalysis.h         | 7 +++++++
 IGC/WrapperLLVM/include/llvmWrapper/IR/InstrTypes.h      | 9 +++++++++
 9 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/IGC/AdaptorCommon/RayTracing/AllocaTracking.cpp b/IGC/AdaptorCommon/RayTracing/AllocaTracking.cpp
index b5ad27e32ca..67cf302495c 100644
--- a/IGC/AdaptorCommon/RayTracing/AllocaTracking.cpp
+++ b/IGC/AdaptorCommon/RayTracing/AllocaTracking.cpp
@@ -19,6 +19,7 @@ SPDX-License-Identifier: MIT
 #include "common/LLVMWarningsPush.hpp"
 #include <llvm/IR/Instruction.h>
 #include <llvm/IR/IntrinsicInst.h>
+#include <llvmWrapper/IR/Instructions.h>
 #include "common/LLVMWarningsPop.hpp"
 
 using namespace llvm;
@@ -129,7 +130,7 @@ void rewriteTypes(
             "Only handles void right now!");
 
         SmallVector<Type*, 4> Tys;
-        for (auto &Op : II->arg_operands())
+        for (auto &Op : IGCLLVM::args(II))
             Tys.push_back(Op->getType());
 
         auto* NewFTy = FunctionType::get(
diff --git a/IGC/AdaptorCommon/RayTracing/InlineDataPass.cpp b/IGC/AdaptorCommon/RayTracing/InlineDataPass.cpp
index 5e4df4e1a86..9433340d259 100644
--- a/IGC/AdaptorCommon/RayTracing/InlineDataPass.cpp
+++ b/IGC/AdaptorCommon/RayTracing/InlineDataPass.cpp
@@ -46,6 +46,7 @@ SPDX-License-Identifier: MIT
 #include <vector>
 #include "common/LLVMWarningsPush.hpp"
 #include <llvm/IR/InstIterator.h>
+#include <llvmWrapper/IR/InstrTypes.h>
 #include "common/LLVMWarningsPop.hpp"
 
 using namespace llvm;
@@ -155,7 +156,7 @@ bool BindlessInlineDataPass::runOnModule(Module &M)
                 // the size of the Shader Identifier + the size of the Local arguments
                 const uint64_t dereferenceable_size =
                     sizeof(ShaderIdentifier) +
-                    local_buffer_ptr->getDereferenceableBytes(AttributeList::ReturnIndex);
+                    IGCLLVM::getRetDereferenceableBytes(local_buffer_ptr);
 
                 // Return a CallInst* representing the InlinedData intrinsic call
                 // In the shader dumps,
diff --git a/IGC/AdaptorCommon/RayTracing/LowerIntersectionAnyHit.cpp b/IGC/AdaptorCommon/RayTracing/LowerIntersectionAnyHit.cpp
index 8b6bba69f23..2c3a98d04e3 100644
--- a/IGC/AdaptorCommon/RayTracing/LowerIntersectionAnyHit.cpp
+++ b/IGC/AdaptorCommon/RayTracing/LowerIntersectionAnyHit.cpp
@@ -449,7 +449,7 @@ CallInst* LowerIntersectionAnyHit::codeGenReportHit(
                 CustomHitAttrPtr,
                 4,
                 Attrs,
-                std::min(4U, DL.getABITypeAlignment(AttrTy->getPointerElementType())),
+                std::min(4U, (unsigned)DL.getABITypeAlignment(AttrTy->getPointerElementType())),
                 IRB.getInt64(DL.getTypeAllocSize(AttrTy->getPointerElementType())));
         }
 
diff --git a/IGC/AdaptorCommon/RayTracing/RTSpillShrinkPass.cpp b/IGC/AdaptorCommon/RayTracing/RTSpillShrinkPass.cpp
index 4d42b32af36..d8d7ac3c54f 100644
--- a/IGC/AdaptorCommon/RayTracing/RTSpillShrinkPass.cpp
+++ b/IGC/AdaptorCommon/RayTracing/RTSpillShrinkPass.cpp
@@ -61,9 +61,9 @@ class RTSpillShrinkPass : public FunctionPass
 
     unsigned getAlignment(const DataLayout& DL, StoreInst* ST) const
     {
-        unsigned Align = ST->getAlignment();
+        unsigned Align = (unsigned)ST->getAlignment();
         if (Align == 0)
-            Align = DL.getABITypeAlignment(ST->getType());
+            Align = (unsigned)DL.getABITypeAlignment(ST->getType());
         return Align;
     }
 
diff --git a/IGC/AdaptorCommon/RayTracing/RayTracingFinalizePass.cpp b/IGC/AdaptorCommon/RayTracing/RayTracingFinalizePass.cpp
index 87549a6ce85..797e77a548d 100644
--- a/IGC/AdaptorCommon/RayTracing/RayTracingFinalizePass.cpp
+++ b/IGC/AdaptorCommon/RayTracing/RayTracingFinalizePass.cpp
@@ -114,7 +114,7 @@ bool RayTracingFinalizePass::runOnModule(Module &M)
             {
                 // Temporary WA to ensure we don't page fault on unaligned
                 // acceses.
-                uint32_t Align = LI->getAlignment();
+                uint32_t Align = (uint32_t)LI->getAlignment();
                 if (Align == 0)
                     Align = (uint32_t)DL.getTypeAllocSize(LI->getType());
 
@@ -125,7 +125,7 @@ bool RayTracingFinalizePass::runOnModule(Module &M)
             {
                 // Temporary WA to ensure we don't page fault on unaligned
                 // acceses.
-                uint32_t Align = SI->getAlignment();
+                uint32_t Align = (uint32_t)SI->getAlignment();
                 if (Align == 0)
                     Align = (uint32_t)DL.getTypeAllocSize(
                         SI->getValueOperand()->getType());
diff --git a/IGC/AdaptorCommon/RayTracing/StackIDSchedulingPass.cpp b/IGC/AdaptorCommon/RayTracing/StackIDSchedulingPass.cpp
index db5490267fd..d352b67a50f 100644
--- a/IGC/AdaptorCommon/RayTracing/StackIDSchedulingPass.cpp
+++ b/IGC/AdaptorCommon/RayTracing/StackIDSchedulingPass.cpp
@@ -49,6 +49,7 @@ SPDX-License-Identifier: MIT
 #include <llvm/IR/Dominators.h>
 #include <llvm/Analysis/PostDominators.h>
 #include <llvm/Analysis/LoopInfo.h>
+#include "llvmWrapper/Analysis/AliasAnalysis.h"
 #include "llvmWrapper/Analysis/MemoryLocation.h"
 #include "common/LLVMWarningsPop.hpp"
 
@@ -175,7 +176,7 @@ BasicBlock* StackIDSchedulingPass::schedule(
 ModRefInfo StackIDSchedulingPass::getModRefInfo(
     const CallBase* Call, const MemoryLocation& Loc)
 {
-    AAQueryInfo AAQIP;
+    AAQueryInfo AAQIP = IGCLLVM::makeAAQueryInfo();
     return AA->getModRefInfo(Call, Loc, AAQIP);
 }
 
diff --git a/IGC/AdaptorCommon/TypesLegalizationPass.cpp b/IGC/AdaptorCommon/TypesLegalizationPass.cpp
index c3570f39d31..10da29ee242 100644
--- a/IGC/AdaptorCommon/TypesLegalizationPass.cpp
+++ b/IGC/AdaptorCommon/TypesLegalizationPass.cpp
@@ -207,7 +207,7 @@ TypesLegalizationPass::ResolveValue( Instruction *ip,Value *val,SmallVector<unsi
   {
     IGCLLVM::IRBuilder<> builder( ld );
     Value* gep = CreateGEP( builder,ld->getOperand( 0 ),indices );
-    unsigned alignment = ld->getAlignment();
+    unsigned alignment = (unsigned)ld->getAlignment();
     unsigned pointerTypeSize = gep->getType()->getPointerElementType()->getScalarSizeInBits() / 8;
     if ( alignment && pointerTypeSize == alignment )
       return builder.CreateAlignedLoad( gep, IGCLLVM::getAlign(alignment) );
diff --git a/IGC/WrapperLLVM/include/llvmWrapper/Analysis/AliasAnalysis.h b/IGC/WrapperLLVM/include/llvmWrapper/Analysis/AliasAnalysis.h
index 873886cc860..385c04db970 100644
--- a/IGC/WrapperLLVM/include/llvmWrapper/Analysis/AliasAnalysis.h
+++ b/IGC/WrapperLLVM/include/llvmWrapper/Analysis/AliasAnalysis.h
@@ -19,6 +19,13 @@ namespace IGCLLVM
 #else
   using AliasResultEnum = llvm::AliasResult::Kind;
 #endif
+inline llvm::AAQueryInfo makeAAQueryInfo() {
+#if LLVM_VERSION_MAJOR >= 14
+  return llvm::AAQueryInfo(new llvm::SimpleCaptureInfo());
+#else
+  return llvm::AAQueryInfo();
+#endif
+}
 }
 
 #endif
diff --git a/IGC/WrapperLLVM/include/llvmWrapper/IR/InstrTypes.h b/IGC/WrapperLLVM/include/llvmWrapper/IR/InstrTypes.h
index 569eece3fb5..1050c842271 100644
--- a/IGC/WrapperLLVM/include/llvmWrapper/IR/InstrTypes.h
+++ b/IGC/WrapperLLVM/include/llvmWrapper/IR/InstrTypes.h
@@ -50,6 +50,15 @@ namespace IGCLLVM
         CI->addFnAttr(Kind);
 #else
         CI->addAttribute(llvm::AttributeList::FunctionIndex, Kind);
+#endif
+    }
+
+    inline uint64_t getRetDereferenceableBytes(llvm::CallBase* Call)
+    {
+#if LLVM_VERSION_MAJOR >= 14
+        return Call->getRetDereferenceableBytes();
+#else
+        return Call->getDereferenceableBytes(llvm::AttributeList::ReturnIndex);
 #endif
     }
 }