Skip to content

Commit 910e936

Browse files
amielczaigcbot
authored andcommitted
LLVM API Changes
Adjust the codebase to LLVM17 API changes
1 parent d03500d commit 910e936

File tree

17 files changed

+90
-46
lines changed

17 files changed

+90
-46
lines changed

IGC/Compiler/CISACodeGen/GenIRLowering.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ SPDX-License-Identifier: MIT
2828
#include <llvm/Transforms/Utils/Local.h>
2929
#include "llvmWrapper/IR/Intrinsics.h"
3030
#include "llvmWrapper/IR/DerivedTypes.h"
31+
#include "llvmWrapper/Support/MathExtras.h"
3132
#include "common/LLVMWarningsPop.hpp"
3233
#include "GenISAIntrinsics/GenIntrinsics.h"
3334
#include "common/IGCIRBuilder.h"
@@ -1096,8 +1097,8 @@ bool GenIRLowering::combinePack4i8Or2i16(Instruction *inst, uint64_t numBits) co
10961097
// the packed vector.
10971098
KnownBits kb = computeKnownBits(v, DL);
10981099
uint32_t nonZeroBits = ~(static_cast<uint32_t>(kb.Zero.getZExtValue()));
1099-
uint32_t lsb = findFirstSet(nonZeroBits);
1100-
uint32_t msb = findLastSet(nonZeroBits);
1100+
uint32_t lsb = IGCLLVM::findFirstSet(nonZeroBits);
1101+
uint32_t msb = IGCLLVM::findLastSet(nonZeroBits);
11011102
if (msb != lsb && (msb / numBits) == (lsb / numBits)) {
11021103
uint32_t idx = (prevShlBits / numBits) + (lsb / numBits);
11031104
if (idx < packedVecSize && toPack[idx].first == nullptr) {

IGC/Compiler/CISACodeGen/PatternMatchPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6117,7 +6117,7 @@ bool isSat(llvm::Instruction *sat, llvm::Value *&source, bool &isUnsigned) {
61176117

61186118
bool isCandidateForConstantPool(llvm::Value *val) {
61196119
auto ci = dyn_cast<ConstantInt>(val);
6120-
bool isBigQW = ci && !ci->getValue().isNullValue() && !ci->getValue().isSignedIntN(32);
6120+
bool isBigQW = ci && !ci->getValue().isZero() && !ci->getValue().isSignedIntN(32);
61216121
bool isDF = val->getType()->isDoubleTy();
61226122
return (isBigQW || isDF);
61236123
}

IGC/Compiler/CustomSafeOptPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2279,7 +2279,7 @@ void CustomSafeOptPass::visitInsertElementInst(llvm::InsertElementInst &I) {
22792279
if (NextInst->hasOneUse() && NextInst->getOpcode() == Instruction::InsertElement) {
22802280
CurrentInst = NextInst;
22812281
} else {
2282-
if (VisitedMask.isAllOnesValue()) {
2282+
if (VisitedMask.isAllOnes()) {
22832283
// All elements are inserted, so input vector is fully overwritten.
22842284
CurrentInst->setOperand(0, PoisonValue::get(VType));
22852285
}

IGC/Compiler/Legalizer/TypeLegalizer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ class TypeLegalizer : public FunctionPass {
429429
Value *zext(Value *V, Type *OrigTy) const {
430430
IGC_ASSERT(V->getType()->getIntegerBitWidth() > OrigTy->getIntegerBitWidth());
431431

432-
APInt Mask = APInt::getAllOnesValue(OrigTy->getIntegerBitWidth());
432+
APInt Mask = APInt::getAllOnes(OrigTy->getIntegerBitWidth());
433433
Constant *C = getIntN(V->getType()->getIntegerBitWidth(), Mask.getZExtValue());
434434
return IRB->CreateAnd(V, C, Twine(V->getName(), ".zext"));
435435
}
@@ -438,7 +438,7 @@ class TypeLegalizer : public FunctionPass {
438438
IGC_ASSERT(LHS->getType() == RHS->getType());
439439
IGC_ASSERT(LHS->getType()->getIntegerBitWidth() > OrigTy->getIntegerBitWidth());
440440

441-
APInt Mask = APInt::getAllOnesValue(OrigTy->getIntegerBitWidth());
441+
APInt Mask = APInt::getAllOnes(OrigTy->getIntegerBitWidth());
442442
Constant *C = getIntN(LHS->getType()->getIntegerBitWidth(), Mask.getZExtValue());
443443
return std::make_pair(IRB->CreateAnd(LHS, C, Twine(LHS->getName(), ".zext")),
444444
IRB->CreateAnd(RHS, C, Twine(RHS->getName(), ".zext")));

IGC/Compiler/Optimizer/IntDivConstantReduction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ struct IntDivConstantReduction : public FunctionPass {
119119
result = zero;
120120
else // X/1 == X
121121
result = dividend;
122-
} else if (isSigned && divisorValue.isAllOnesValue()) {
122+
} else if (isSigned && divisorValue.isAllOnes()) {
123123
if (isMod) // X%-1 == 0
124124
result = zero;
125125
else // X/-1 == -X

IGC/Compiler/Optimizer/OpenCLPasses/JointMatrixFuncsResolutionPass/JointMatrixFuncsResolutionPass.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,10 +2957,7 @@ void JointMatrixFuncsResolutionPass::visitAllocaInst(AllocaInst &I) {
29572957

29582958
// update debug info
29592959
{
2960-
TinyPtrVector<DbgDeclareInst *> DDIs;
2961-
for (DbgVariableIntrinsic *DVI : FindDbgAddrUses(&I))
2962-
if (auto *DDI = dyn_cast<DbgDeclareInst>(DVI))
2963-
DDIs.push_back(DDI);
2960+
TinyPtrVector<DbgDeclareInst *> DDIs = FindDbgDeclareUses(&I);
29642961

29652962
for (DbgDeclareInst *ddi : DDIs) {
29662963
auto loc = ddi->getDebugLoc();

IGC/Compiler/Optimizer/OpenCLPasses/PrivateMemory/PrivateMemoryResolution.cpp

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,19 +1003,17 @@ bool PrivateMemoryResolution::resolveAllocaInstructions(bool privateOnStack) {
10031003

10041004
// Attaching this metadata is crucial to both properly interpret this locations as stack based ond to inline it.
10051005
// Because these are stack locations we can safely inline them even with optimizations disabled (O0).
1006-
auto DbgUses = llvm::FindDbgAddrUses(pAI);
1007-
for (auto Use : DbgUses) {
1008-
if (auto DbgDcl = dyn_cast_or_null<DbgDeclareInst>(Use)) {
1009-
unsigned scalarBufferOffset = m_ModAllocaInfo->getBufferOffset(pAI);
1010-
unsigned bufferSize = m_ModAllocaInfo->getBufferStride(pAI);
1011-
1012-
// Attach metadata to instruction containing offset of storage
1013-
auto OffsetMD =
1014-
MDNode::get(builder.getContext(), ConstantAsMetadata::get(builder.getInt32(scalarBufferOffset)));
1015-
DbgDcl->setMetadata("StorageOffset", OffsetMD);
1016-
auto SizeMD = MDNode::get(builder.getContext(), ConstantAsMetadata::get(builder.getInt32(bufferSize)));
1017-
DbgDcl->setMetadata("StorageSize", SizeMD);
1018-
}
1006+
auto DbgDcls = llvm::FindDbgDeclareUses(pAI);
1007+
for (auto DbgDcl : DbgDcls) {
1008+
unsigned scalarBufferOffset = m_ModAllocaInfo->getBufferOffset(pAI);
1009+
unsigned bufferSize = m_ModAllocaInfo->getBufferStride(pAI);
1010+
1011+
// Attach metadata to instruction containing offset of storage
1012+
auto OffsetMD =
1013+
MDNode::get(builder.getContext(), ConstantAsMetadata::get(builder.getInt32(scalarBufferOffset)));
1014+
DbgDcl->setMetadata("StorageOffset", OffsetMD);
1015+
auto SizeMD = MDNode::get(builder.getContext(), ConstantAsMetadata::get(builder.getInt32(bufferSize)));
1016+
DbgDcl->setMetadata("StorageSize", SizeMD);
10191017
}
10201018
}
10211019
// Replace all uses of original alloca with the bitcast
@@ -1307,15 +1305,13 @@ bool PrivateMemoryResolution::resolveAllocaInstructions(bool privateOnStack) {
13071305
// We can only safely inline such locations with optimizations disabled.
13081306
// On O2 we have no guarantee the offsets in registers are gonna be valid throughout the entire variable lifetime.
13091307
if (modMD->compOpt.OptDisable) {
1310-
auto DbgUses = llvm::FindDbgAddrUses(pAI);
1311-
for (auto Use : DbgUses) {
1312-
if (auto DbgDcl = dyn_cast_or_null<DbgDeclareInst>(Use)) {
1313-
// Attach metadata to instruction containing offset of storage
1314-
unsigned int scalarBufferOffset = m_ModAllocaInfo->getBufferOffset(pAI);
1315-
auto OffsetMD =
1316-
MDNode::get(builder.getContext(), ConstantAsMetadata::get(builder.getInt32(scalarBufferOffset)));
1317-
DbgDcl->setMetadata("StorageOffset", OffsetMD);
1318-
}
1308+
auto DbgDcls = llvm::FindDbgDeclareUses(pAI);
1309+
for (auto DbgDcl : DbgDcls) {
1310+
// Attach metadata to instruction containing offset of storage
1311+
unsigned int scalarBufferOffset = m_ModAllocaInfo->getBufferOffset(pAI);
1312+
auto OffsetMD =
1313+
MDNode::get(builder.getContext(), ConstantAsMetadata::get(builder.getInt32(scalarBufferOffset)));
1314+
DbgDcl->setMetadata("StorageOffset", OffsetMD);
13191315
}
13201316
}
13211317

IGC/VectorCompiler/lib/GenXCodeGen/ConstantEncoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ encodeGlobalValue(const GlobalValue &GV, const DataLayout &DL) {
132132
vc::diagnose(GV.getContext(), "ConstantEncoder",
133133
"Relocation of the provided pointer is not supported", &GV);
134134
}
135-
return {APInt::getNullValue(Size.inBits()),
135+
return {APInt::getZero(Size.inBits()),
136136
{vISA::ZERelocEntry{RelType, 0, GV.getName().str()}}};
137137
}
138138

IGC/VectorCompiler/lib/GenXCodeGen/GenXCisaBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4358,7 +4358,7 @@ void GenXKernelBuilder::buildBinaryOperator(BinaryOperator *BO, BaleInfo BI,
43584358
auto C = dyn_cast<ConstantInt>(V);
43594359
if (!C)
43604360
return false;
4361-
return C->getValue().getMinSignedBits() <= genx::WordBits;
4361+
return C->getValue().getSignificantBits() <= genx::WordBits;
43624362
});
43634363
};
43644364
if (auto *VT = dyn_cast<IGCLLVM::FixedVectorType>(BO->getType()))

IGC/VectorCompiler/lib/GenXCodeGen/GenXLegalization.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ SPDX-License-Identifier: MIT
183183
#include "llvm/Transforms/Utils/Local.h"
184184

185185
#include "llvmWrapper/IR/DerivedTypes.h"
186+
#include "llvmWrapper/Support/MathExtras.h"
186187

187188
#define DEBUG_TYPE "GENX_LEGALIZATION"
188189

@@ -1655,7 +1656,7 @@ LegalPredSize GenXLegalization::getLegalPredSize(Value *Pred, unsigned StartIdx,
16551656
// However, Max cannot be any bigger than the misalignment of the offset into
16561657
// the part. For example. if the offset is 4 or 12, the size must be 4, not 8
16571658
// or 16.
1658-
LogMax = std::min(LogMax, findFirstSet(StartIdx - PP.Offset));
1659+
LogMax = std::min(LogMax, IGCLLVM::findFirstSet(StartIdx - PP.Offset));
16591660
IGC_ASSERT_EXIT(LogMax < 32);
16601661
Ret.Max = 1 << LogMax;
16611662
// If Min>Max, then we're at the end of that part and we don't need to ensure

0 commit comments

Comments
 (0)