Fix an assert on cbuffer loads of bool vectors. (#2104)
After loading a vector from a cbuffer, we attempt moving the debug info upstream, to the individually loaded elements, assuming that they got converted into a vector by a sequence of insertelement instructions. This is not the case for bool vectors, because the insertelement sequence will be followed by a mem-to-reg conversion. Made the code more resilient to such unexpected patterns (better to lose debug info than to crash compilation).
This commit is contained in:
Родитель
75df1b1436
Коммит
ada42260b2
|
@ -98,7 +98,7 @@ namespace dxilutil {
|
||||||
unsigned numOperands);
|
unsigned numOperands);
|
||||||
bool SimplifyTrivialPHIs(llvm::BasicBlock *BB);
|
bool SimplifyTrivialPHIs(llvm::BasicBlock *BB);
|
||||||
void MigrateDebugValue(llvm::Value *Old, llvm::Value *New);
|
void MigrateDebugValue(llvm::Value *Old, llvm::Value *New);
|
||||||
void ScatterDebugValueToVectorElements(llvm::Value *Val);
|
void TryScatterDebugValueToVectorElements(llvm::Value *Val);
|
||||||
std::unique_ptr<llvm::Module> LoadModuleFromBitcode(llvm::StringRef BC,
|
std::unique_ptr<llvm::Module> LoadModuleFromBitcode(llvm::StringRef BC,
|
||||||
llvm::LLVMContext &Ctx, std::string &DiagStr);
|
llvm::LLVMContext &Ctx, std::string &DiagStr);
|
||||||
std::unique_ptr<llvm::Module> LoadModuleFromBitcode(llvm::MemoryBuffer *MB,
|
std::unique_ptr<llvm::Module> LoadModuleFromBitcode(llvm::MemoryBuffer *MB,
|
||||||
|
|
|
@ -363,8 +363,9 @@ void MigrateDebugValue(Value *Old, Value *New) {
|
||||||
// If we just keep the debug info on the recomposed vector,
|
// If we just keep the debug info on the recomposed vector,
|
||||||
// we will lose it when we break it apart again during later
|
// we will lose it when we break it apart again during later
|
||||||
// optimization stages.
|
// optimization stages.
|
||||||
void ScatterDebugValueToVectorElements(Value *Val) {
|
void TryScatterDebugValueToVectorElements(Value *Val) {
|
||||||
DXASSERT(isa<InsertElementInst>(Val), "Should be a newly gathered vector.");
|
if (!isa<InsertElementInst>(Val) || !Val->getType()->isVectorTy()) return;
|
||||||
|
|
||||||
DbgValueInst *VecDbgValInst = FindDbgValueInst(Val);
|
DbgValueInst *VecDbgValInst = FindDbgValueInst(Val);
|
||||||
if (VecDbgValInst == nullptr) return;
|
if (VecDbgValInst == nullptr) return;
|
||||||
|
|
||||||
|
|
|
@ -5500,7 +5500,7 @@ void TranslateCBAddressUserLegacy(Instruction *user, Value *handle,
|
||||||
Value *newLd = TranslateConstBufMatLdLegacy(
|
Value *newLd = TranslateConstBufMatLdLegacy(
|
||||||
MatTy, handle, legacyIdx, colMajor, hlslOP, /*memElemRepr*/false, DL, Builder);
|
MatTy, handle, legacyIdx, colMajor, hlslOP, /*memElemRepr*/false, DL, Builder);
|
||||||
CI->replaceAllUsesWith(newLd);
|
CI->replaceAllUsesWith(newLd);
|
||||||
dxilutil::ScatterDebugValueToVectorElements(newLd);
|
dxilutil::TryScatterDebugValueToVectorElements(newLd);
|
||||||
CI->eraseFromParent();
|
CI->eraseFromParent();
|
||||||
} else if (group == HLOpcodeGroup::HLSubscript) {
|
} else if (group == HLOpcodeGroup::HLSubscript) {
|
||||||
HLSubscriptOpcode subOp = static_cast<HLSubscriptOpcode>(opcode);
|
HLSubscriptOpcode subOp = static_cast<HLSubscriptOpcode>(opcode);
|
||||||
|
@ -5669,7 +5669,7 @@ void TranslateCBAddressUserLegacy(Instruction *user, Value *handle,
|
||||||
hlslOP, Builder);
|
hlslOP, Builder);
|
||||||
|
|
||||||
ldInst->replaceAllUsesWith(newLd);
|
ldInst->replaceAllUsesWith(newLd);
|
||||||
if (Ty->isVectorTy()) dxilutil::ScatterDebugValueToVectorElements(newLd);
|
dxilutil::TryScatterDebugValueToVectorElements(newLd);
|
||||||
ldInst->eraseFromParent();
|
ldInst->eraseFromParent();
|
||||||
} else if (BitCastInst *BCI = dyn_cast<BitCastInst>(user)) {
|
} else if (BitCastInst *BCI = dyn_cast<BitCastInst>(user)) {
|
||||||
for (auto it = BCI->user_begin(); it != BCI->user_end(); ) {
|
for (auto it = BCI->user_begin(); it != BCI->user_end(); ) {
|
||||||
|
|
|
@ -630,7 +630,7 @@ void replaceDirectInputParameter(Value *param, Function *loadInput,
|
||||||
param->replaceAllUsesWith(newVec);
|
param->replaceAllUsesWith(newVec);
|
||||||
|
|
||||||
// THe individual loadInputs are the authoritative source of values for the vector.
|
// THe individual loadInputs are the authoritative source of values for the vector.
|
||||||
dxilutil::ScatterDebugValueToVectorElements(newVec);
|
dxilutil::TryScatterDebugValueToVectorElements(newVec);
|
||||||
} else if (!Ty->isArrayTy() && !HLMatrixType::isa(Ty)) {
|
} else if (!Ty->isArrayTy() && !HLMatrixType::isa(Ty)) {
|
||||||
DXASSERT(cols == 1, "only support scalar here");
|
DXASSERT(cols == 1, "only support scalar here");
|
||||||
Value *colIdx = hlslOP->GetU8Const(0);
|
Value *colIdx = hlslOP->GetU8Const(0);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче