Skip to content

[DirectX] Pointer type bitcast must be have same size. #139013

Open
@farzonl

Description

@farzonl

DXILPrepare.cpp adds NoOp bitcasts that are causing problems in the validator

// Emtting NoOp bitcast instructions allows the ValueEnumerator to be
// unmodified as it reserves instruction IDs during contruction.
if (auto LI = dyn_cast<LoadInst>(&I)) {
if (Value *NoOpBitcast = maybeGenerateBitcast(
Builder, PointerTypes, I, LI->getPointerOperand(),
LI->getType())) {
LI->replaceAllUsesWith(
Builder.CreateLoad(LI->getType(), NoOpBitcast));
LI->eraseFromParent();
}
continue;
}
if (auto SI = dyn_cast<StoreInst>(&I)) {
if (Value *NoOpBitcast = maybeGenerateBitcast(
Builder, PointerTypes, I, SI->getPointerOperand(),
SI->getValueOperand()->getType())) {
SI->replaceAllUsesWith(
Builder.CreateStore(SI->getValueOperand(), NoOpBitcast));
SI->eraseFromParent();
}
continue;
}
if (auto GEP = dyn_cast<GetElementPtrInst>(&I)) {
if (Value *NoOpBitcast = maybeGenerateBitcast(
Builder, PointerTypes, I, GEP->getPointerOperand(),
GEP->getSourceElementType()))
GEP->setOperand(0, NoOpBitcast);
continue;
}

It is changing

store float 2.000000e+00, ptr addrspace(3) getelementptr (float, ptr addrspace(3) @arrayofVecData.scalarized.1dim, i32 1), align 4

to:

%2 = bitcast ptr addrspace(3) getelementptr (float, ptr addrspace(3) @arrayofVecData.scalarized.1dim, i32 1) to ptr addrspace(3)
store float 2.000000e+00, ptr addrspace(3) %2, align 4

commenting out these no ops resolves all 848 ptr bitcast errors.

Metadata

Metadata

Assignees

Type

Projects

Status

Active

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions