Skip to content

Commit 1c28c74

Browse files
zboszorigcbot
authored andcommitted
Fix build with LLVM 12
Removed TargetLibraryInfo.h include from AddressSpaceAliasAnalysis.cpp as this was causing treat-warning-as-error buildbreak, Added casts to fix warnings, Replaced ConstantPropagation and IPConstantPropagation passes with IPSCCP passes, reasoning here: https://lists.llvm.org/pipermail/llvm-dev/2020-July/143788.html Original pull-request: #171 Signed-off-by: Zoltán Böszörményi [email protected] Co-authored-by: Pawel Szymichowski [email protected] Co-authored-by: Zoltán Böszörményi [email protected]
1 parent 6134d60 commit 1c28c74

File tree

67 files changed

+269
-201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+269
-201
lines changed

IGC/AdaptorCommon/LegalizeFunctionSignatures.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ inline Type* LegalizedIntVectorType(Module& M, const Type* const oldTy)
140140
else if (size <= 64) newSize = 64;
141141
else IGC_ASSERT_MESSAGE(0, "Currently don't support upscaling int sizes > 64 bits");
142142

143-
return IGCLLVM::FixedVectorType::get(IntegerType::get(M.getContext(), newSize), (unsigned)cast<VectorType>(oldTy)->getNumElements());
143+
return IGCLLVM::FixedVectorType::get(IntegerType::get(M.getContext(), newSize), (unsigned)cast<IGCLLVM::FixedVectorType>(oldTy)->getNumElements());
144144
}
145145

146146
void LegalizeFunctionSignatures::FixFunctionSignatures()

IGC/AdaptorOCL/SPIRV/SPIRVReader.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,7 +1577,7 @@ void SPIRVToLLVMDbgTran::transDbgInfo(SPIRVValue *SV, Value *V) {
15771577
Line->getColumn(), scope, iat);
15781578

15791579
if(scope && !isa<DIFile>(scope))
1580-
I->setDebugLoc(DebugLoc::get(Line->getLine(), Line->getColumn(),
1580+
I->setDebugLoc(DILocation::get(scope->getContext(), Line->getLine(), Line->getColumn(),
15811581
scope, iat));
15821582
}
15831583
}
@@ -1929,7 +1929,7 @@ SPIRVToLLVM::transType(SPIRVType *T) {
19291929
auto name = isSubgroupAvcINTELTypeOpCode(OC) ?
19301930
OCLSubgroupINTELTypeOpCodeMap::rmap(OC) :
19311931
BuiltinOpaqueGenericTypeOpCodeMap::rmap(OC);
1932-
auto *pST = M->getTypeByName(name);
1932+
auto *pST = IGCLLVM::getTypeByName(M, name);
19331933
pST = pST ? pST : StructType::create(*Context, name);
19341934

19351935
return mapType(T, PointerType::get(pST, getOCLOpaqueTypeAddrSpace(OC)));
@@ -2407,7 +2407,7 @@ Value *SPIRVToLLVM::promoteBool(Value *pVal, BasicBlock *BB)
24072407

24082408
auto *PromoType = isa<VectorType>(pVal->getType()) ?
24092409
cast<Type>(IGCLLVM::FixedVectorType::get(Type::getInt8Ty(pVal->getContext()),
2410-
(unsigned)cast<VectorType>(pVal->getType())->getNumElements())) :
2410+
(unsigned)cast<IGCLLVM::FixedVectorType>(pVal->getType())->getNumElements())) :
24112411
Type::getInt8Ty(pVal->getContext());
24122412

24132413
if (auto *C = dyn_cast<Constant>(pVal))
@@ -2449,7 +2449,7 @@ Value *SPIRVToLLVM::truncBool(Value *pVal, BasicBlock *BB)
24492449

24502450
auto *TruncType = isa<VectorType>(pVal->getType()) ?
24512451
cast<Type>(IGCLLVM::FixedVectorType::get(Type::getInt1Ty(pVal->getContext()),
2452-
(unsigned)cast<VectorType>(pVal->getType())->getNumElements())) :
2452+
(unsigned)cast<IGCLLVM::FixedVectorType>(pVal->getType())->getNumElements())) :
24532453
Type::getInt1Ty(pVal->getContext());
24542454

24552455
if (auto *C = dyn_cast<Constant>(pVal))
@@ -2495,7 +2495,7 @@ Type *SPIRVToLLVM::truncBoolType(SPIRVType *SPVType, Type *LLType)
24952495

24962496
return isa<VectorType>(LLType) ?
24972497
cast<Type>(IGCLLVM::FixedVectorType::get(Type::getInt1Ty(LLType->getContext()),
2498-
(unsigned)cast<VectorType>(LLType)->getNumElements())) :
2498+
(unsigned)cast<IGCLLVM::FixedVectorType>(LLType)->getNumElements())) :
24992499
Type::getInt1Ty(LLType->getContext());
25002500
}
25012501

@@ -2652,7 +2652,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
26522652
{
26532653
if(CV[i]->getType()->isVectorTy())
26542654
{
2655-
for(uint32_t j = 0; j < cast<VectorType>(CV[i]->getType())->getNumElements(); j++)
2655+
for(uint32_t j = 0; j < cast<IGCLLVM::FixedVectorType>(CV[i]->getType())->getNumElements(); j++)
26562656
{
26572657
Value *v = ExtractElementInst::Create( CV[i],ConstantInt::get( *Context,APInt( 32,j ) ),BCC->getName(),BB );
26582658
elm1 = CreateCompositeConstruct( elm1,v,pos++ );
@@ -3346,7 +3346,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
33463346
auto Vector = transValue(BI->getOperand(0), F, BB);
33473347
auto Scalar = transValue(BI->getOperand(1), F, BB);
33483348

3349-
auto VecType = cast<VectorType>(Vector->getType());
3349+
auto VecType = cast<IGCLLVM::FixedVectorType>(Vector->getType());
33503350
auto Undef = UndefValue::get(VecType);
33513351

33523352
auto ScalarVec = InsertElementInst::Create(Undef, Scalar,
@@ -3371,7 +3371,7 @@ SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
33713371
a->getType()->getScalarSizeInBits() - 1);
33723372
auto *ShiftOp = isa<VectorType>(a->getType()) ?
33733373
ConstantVector::getSplat(
3374-
IGCLLVM::getElementCount((unsigned)cast<VectorType>(a->getType())->getNumElements()), ShiftAmt) :
3374+
IGCLLVM::getElementCount((unsigned)cast<IGCLLVM::FixedVectorType>(a->getType())->getNumElements()), ShiftAmt) :
33753375
ShiftAmt;
33763376

33773377
// OCL C:
@@ -3715,15 +3715,15 @@ SPIRVToLLVM::transSPIRVBuiltinFromInst(SPIRVInstruction *BI, BasicBlock *BB) {
37153715
"",
37163716
BB);
37173717
}
3718-
else if (cast<VectorType>(coordType)->getNumElements() != 4)
3718+
else if (cast<IGCLLVM::FixedVectorType>(coordType)->getNumElements() != 4)
37193719
{
37203720
Value *undef = UndefValue::get(coordType);
37213721

37223722
SmallVector<Constant*, 4> shuffleIdx;
3723-
for (unsigned i = 0; i < cast<VectorType>(coordType)->getNumElements(); i++)
3723+
for (unsigned i = 0; i < cast<IGCLLVM::FixedVectorType>(coordType)->getNumElements(); i++)
37243724
shuffleIdx.push_back(ConstantInt::get(Type::getInt32Ty(*Context), i));
37253725

3726-
for (uint64_t i = (unsigned)cast<VectorType>(coordType)->getNumElements(); i < 4; i++)
3726+
for (uint64_t i = (unsigned)cast<IGCLLVM::FixedVectorType>(coordType)->getNumElements(); i < 4; i++)
37273727
shuffleIdx.push_back(ConstantInt::get(Type::getInt32Ty(*Context), 0));
37283728

37293729
imageCoordinateWiden = new ShuffleVectorInst(

IGC/AdaptorOCL/SPIRV/SPIRVUtil.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ saveLLVMModule(Module *M, const std::string &OutputFile) {
9393
PointerType*
9494
getOrCreateOpaquePtrType(Module *M, const std::string &Name,
9595
unsigned AddrSpace) {
96-
auto OpaqueType = M->getTypeByName(Name);
96+
auto OpaqueType = IGCLLVM::getTypeByName(M, Name);
9797
if (!OpaqueType)
9898
OpaqueType = StructType::create(M->getContext(), Name);
9999
return PointerType::get(OpaqueType, AddrSpace);
@@ -159,7 +159,7 @@ std::string recursive_mangle(const Type* pType)
159159
return "i" + utostr(pType->getIntegerBitWidth());
160160
case IGCLLVM::VectorTyID:
161161
{
162-
unsigned vecLen = (unsigned)cast<VectorType>(pType)->getNumElements();
162+
unsigned vecLen = (unsigned)cast<IGCLLVM::FixedVectorType>(pType)->getNumElements();
163163
Type* pEltType = cast<VectorType>(pType)->getElementType();
164164
return "v" + utostr(vecLen) + recursive_mangle(pEltType);
165165
}

IGC/Compiler/CISACodeGen/AdvMemOpt.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ IN THE SOFTWARE.
3333
#include <llvm/Support/Debug.h>
3434
#include <llvm/Support/raw_ostream.h>
3535
#include <llvm/Transforms/Utils/Local.h>
36+
#include "llvmWrapper/Transforms/Utils/LoopUtils.h"
3637
#include "common/LLVMWarningsPop.hpp"
3738
#include "GenISAIntrinsics/GenIntrinsics.h"
3839
#include "Compiler/CISACodeGen/ShaderCodeGen.hpp"
@@ -134,7 +135,7 @@ bool AdvMemOpt::runOnFunction(Function& F) {
134135
for (auto I = LI->begin(), E = LI->end(); I != E; ++I)
135136
for (auto DFI = df_begin(*I), DFE = df_end(*I); DFI != DFE; ++DFI) {
136137
Loop* L = *DFI;
137-
if (L->empty())
138+
if (IGCLLVM::isInnermost(L))
138139
InnermostLoops.push_back(L);
139140
}
140141

IGC/Compiler/CISACodeGen/CShader.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ void CShader::CreateAliasVars()
434434
continue;
435435

436436
Type* Ty = V->getType();
437-
VectorType* VTy = dyn_cast<VectorType>(Ty);
437+
IGCLLVM::FixedVectorType* VTy = dyn_cast<IGCLLVM::FixedVectorType>(Ty);
438438
Type* BTy = VTy ? VTy->getElementType() : Ty;
439439
int nelts = (VTy ? (int)VTy->getNumElements() : 1);
440440

@@ -984,7 +984,7 @@ bool CShader::InsideDivergentCF(llvm::Instruction* inst)
984984
uint CShader::GetNbVectorElementAndMask(llvm::Value* val, uint32_t& mask)
985985
{
986986
llvm::Type* type = val->getType();
987-
uint nbElement = int_cast<uint>(cast<VectorType>(type)->getNumElements());
987+
uint nbElement = int_cast<uint>(cast<IGCLLVM::FixedVectorType>(type)->getNumElements());
988988
mask = 0;
989989
// we don't process vector bigger than 31 elements as the mask has only 32bits
990990
// If we want to support longer vectors we need to extend the mask size
@@ -1189,15 +1189,15 @@ uint32_t CShader::GetExtractMask(llvm::Value* vecVal)
11891189
{
11901190
return it->second;
11911191
}
1192-
const unsigned int numChannels = vecVal->getType()->isVectorTy() ? (unsigned)cast<VectorType>(vecVal->getType())->getNumElements() : 1;
1192+
const unsigned int numChannels = vecVal->getType()->isVectorTy() ? (unsigned)cast<IGCLLVM::FixedVectorType>(vecVal->getType())->getNumElements() : 1;
11931193
IGC_ASSERT_MESSAGE(numChannels <= 32, "Mask has 32 bits maximally!");
11941194
return (1ULL << numChannels) - 1;
11951195
}
11961196

11971197
uint16_t CShader::AdjustExtractIndex(llvm::Value* vecVal, uint16_t index)
11981198
{
11991199
uint16_t result = index;
1200-
if (cast<VectorType>(vecVal->getType())->getNumElements() < 32)
1200+
if (cast<IGCLLVM::FixedVectorType>(vecVal->getType())->getNumElements() < 32)
12011201
{
12021202
uint32_t mask = GetExtractMask(vecVal);
12031203
for (uint i = 0; i < index; ++i)
@@ -1614,7 +1614,7 @@ auto sizeToSIMDMode = [](uint32_t size)
16141614

16151615
CVariable* CShader::GetConstant(llvm::Constant* C, CVariable* dstVar)
16161616
{
1617-
llvm::VectorType* VTy = llvm::dyn_cast<llvm::VectorType>(C->getType());
1617+
IGCLLVM::FixedVectorType* VTy = llvm::dyn_cast<IGCLLVM::FixedVectorType>(C->getType());
16181618
if (C && VTy)
16191619
{ // Vector constant
16201620
llvm::Type* eTy = VTy->getElementType();
@@ -1839,7 +1839,7 @@ uint32_t CShader::GetNumElts(llvm::Type* type, bool isUniform)
18391839
{
18401840
IGC_ASSERT(type->getContainedType(0)->isIntegerTy() || type->getContainedType(0)->isFloatingPointTy());
18411841

1842-
auto VT = cast<VectorType>(type);
1842+
auto VT = cast<IGCLLVM::FixedVectorType>(type);
18431843
numElts *= (uint16_t)VT->getNumElements();
18441844
}
18451845
return numElts;

IGC/Compiler/CISACodeGen/ConstantCoalescing.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static void checkInsertExtractMatch(InsertElementInst* insertInst, Value* base,
224224

225225
static bool canReplaceInsert(InsertElementInst* insertElt)
226226
{
227-
VectorType* VTy = cast<VectorType>(insertElt->getOperand(0)->getType());
227+
IGCLLVM::FixedVectorType* VTy = cast<IGCLLVM::FixedVectorType>(insertElt->getOperand(0)->getType());
228228
ConstantInt* index = dyn_cast<ConstantInt>(insertElt->getOperand(2));
229229
if (!index || index->getZExtValue() != VTy->getNumElements() - 1)
230230
{
@@ -312,7 +312,7 @@ void ConstantCoalescing::VectorizePrep(llvm::BasicBlock* bb)
312312
{
313313
if (load->getType()->isVectorTy() && wiAns->isUniform(load))
314314
{
315-
srcNElts = (uint32_t)cast<VectorType>(load->getType())->getNumElements();
315+
srcNElts = (uint32_t)cast<IGCLLVM::FixedVectorType>(load->getType())->getNumElements();
316316
DenseMap<uint64_t, Instruction*> extractElementMap;
317317

318318
for (auto iter = load->user_begin(); iter != load->user_end(); iter++)
@@ -396,7 +396,7 @@ bool ConstantCoalescing::isProfitableLoad(
396396
(isa<LoadInst>(I) && wiAns->isUniform(I)) ?
397397
16 : 4;
398398

399-
if (cast<VectorType>(LoadTy)->getNumElements() > MaxVectorInput)
399+
if (cast<IGCLLVM::FixedVectorType>(LoadTy)->getNumElements() > MaxVectorInput)
400400
return false;
401401

402402
MaxEltPlus = CheckVectorElementUses(I);
@@ -1843,7 +1843,7 @@ void ConstantCoalescing::AdjustChunk(BufChunk* cov_chunk, uint start_adj, uint s
18431843
WIAnalysis::WIDependancy loadDep = wiAns->whichDepend(cov_chunk->chunkIO);
18441844
irBuilder->SetInsertPoint(cov_chunk->chunkIO->getNextNode());
18451845
Value* vec = UndefValue::get(originalType);
1846-
for (unsigned i = 0; i < cast<VectorType>(originalType)->getNumElements(); i++)
1846+
for (unsigned i = 0; i < cast<IGCLLVM::FixedVectorType>(originalType)->getNumElements(); i++)
18471847
{
18481848
Value* channel = irBuilder->CreateExtractElement(
18491849
cov_chunk->chunkIO, irBuilder->getInt32(i + start_adj));
@@ -1907,7 +1907,7 @@ void ConstantCoalescing::MoveExtracts(BufChunk* cov_chunk, Instruction* load, ui
19071907
irBuilder->SetInsertPoint(load->getNextNode());
19081908
Type* vecType = load->getType();
19091909
Value* vec = UndefValue::get(vecType);
1910-
for (unsigned i = 0; i < cast<VectorType>(vecType)->getNumElements(); i++)
1910+
for (unsigned i = 0; i < cast<IGCLLVM::FixedVectorType>(vecType)->getNumElements(); i++)
19111911
{
19121912
Value* channel = irBuilder->CreateExtractElement(
19131913
cov_chunk->chunkIO, irBuilder->getInt32(i + start_adj));
@@ -1971,7 +1971,7 @@ void ConstantCoalescing::EnlargeChunk(BufChunk* cov_chunk, uint size_adj)
19711971
WIAnalysis::WIDependancy loadDep = wiAns->whichDepend(cov_chunk->chunkIO);
19721972
irBuilder->SetInsertPoint(cov_chunk->chunkIO->getNextNode());
19731973
Value* vec = UndefValue::get(originalType);
1974-
for (unsigned i = 0; i < cast<VectorType>(originalType)->getNumElements(); i++)
1974+
for (unsigned i = 0; i < cast<IGCLLVM::FixedVectorType>(originalType)->getNumElements(); i++)
19751975
{
19761976
Value* channel = irBuilder->CreateExtractElement(
19771977
cov_chunk->chunkIO, irBuilder->getInt32(i));
@@ -2408,7 +2408,7 @@ void ConstantCoalescing::ReplaceLoadWithSamplerLoad(
24082408
if (dstTy->isVectorTy())
24092409
{
24102410
result = UndefValue::get(dstTy);
2411-
for (uint i = 0; i < cast<VectorType>(dstTy)->getNumElements(); i++)
2411+
for (uint i = 0; i < cast<IGCLLVM::FixedVectorType>(dstTy)->getNumElements(); i++)
24122412
{
24132413
Value* tmpData = ExtractFromSamplerData(cast<VectorType>(dstTy)->getElementType(), i);
24142414
result = irBuilder->CreateInsertElement(result, tmpData, irBuilder->getInt32(i));

IGC/Compiler/CISACodeGen/DeSSA.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ IN THE SOFTWARE.
8585
#include "llvmWrapper/IR/Instructions.h"
8686
#include <llvm/IR/InstIterator.h>
8787
#include <llvm/IR/InlineAsm.h>
88+
#include <llvmWrapper/IR/DerivedTypes.h>
8889
#include "common/LLVMWarningsPop.hpp"
8990
#include <algorithm>
9091
#include "Probe/Assertion.h"
@@ -1319,7 +1320,7 @@ int DeSSA::checkInsertElementAlias(
13191320
//
13201321
// If found, return the actual vector size;
13211322
// otherwise, return 0.
1322-
VectorType* VTy = cast<VectorType>(IEI->getType());
1323+
IGCLLVM::FixedVectorType* VTy = cast<IGCLLVM::FixedVectorType>(IEI->getType());
13231324
IGC_ASSERT(nullptr != VTy);
13241325
int nelts = (int)VTy->getNumElements();
13251326
AllIEIs.resize(nelts, nullptr);

0 commit comments

Comments
 (0)