Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update llpc to handle new version of llvm #2799

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions llpc/translator/lib/SPIRV/SPIRVReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "lgc/Pipeline.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Analysis/ConstantFolding.h"
#include "llvm/Analysis/VectorUtils.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/IR/CFG.h"
Expand Down Expand Up @@ -2011,8 +2012,12 @@ Constant *SPIRVToLLVM::buildConstStoreRecursively(SPIRVType *const spvType, Type
return ConstantArray::get(cast<ArrayType>(storeType), constElements);
}
// If the store was a bool or vector of bool, need to zext the storing value.
if (spvType->isTypeBool() || (spvType->isTypeVector() && spvType->getVectorComponentType()->isTypeBool()))
constStoreValue = ConstantExpr::getZExtOrBitCast(constStoreValue, storeType);
if (spvType->isTypeBool() || (spvType->isTypeVector() && spvType->getVectorComponentType()->isTypeBool())) {
if (constStoreValue->getType() != storeType) {
constStoreValue = ConstantFoldCastOperand(Instruction::ZExt, constStoreValue, storeType, m_m->getDataLayout());
assert(constStoreValue && "constant folding should succeed");
}
}

// If the LLVM type is a not a vector, we need to change the constant into an array.
if (spvType->isTypeVector() && !storeType->isVectorTy()) {
Expand Down Expand Up @@ -4478,7 +4483,8 @@ Constant *SPIRVToLLVM::transInitializer(SPIRVValue *const spvValue, Type *const
// in memory.
assert(initializer->getType()->isIntOrIntVectorTy(1));
assert(type->isIntOrIntVectorTy(32));
initializer = ConstantExpr::getZExt(initializer, type);
initializer = ConstantFoldCastOperand(Instruction::ZExt, initializer, type, m_m->getDataLayout());
assert(initializer && "constant folding should not fail on integers");
}
return initializer;
}
Expand Down
Loading