Skip to content

Commit 45a4ad5

Browse files
vmustyaigcbot
authored andcommitted
Fix incorrectly-produced alignment attributes in VC
For some legacy tests, the LLVM-16 SPIR-V reader incorrectly emits `align` attributes on non-pointer function arguments. This causes failures in the LLVM verifier, which expects only pointer arguments to have alignment attributes. This change removes the incorrect `align` attributes from non-pointer function arguments in the SPIR-V reader.
1 parent b29a434 commit 45a4ad5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

IGC/VectorCompiler/lib/Driver/SPIRVWrapper.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ void PrepareModuleStructs(Module &M) {
9898
Func->eraseFromParent();
9999
}
100100

101+
void fixAlignmentAttributes(Module &M) {
102+
for (auto &F : M.functions()) {
103+
for (auto &Arg : F.args()) {
104+
// Remove align attribute if the argument type is not a pointer
105+
if (!Arg.getType()->isPointerTy())
106+
F.removeParamAttr(Arg.getArgNo(), Attribute::Alignment);
107+
}
108+
}
109+
}
110+
101111
int spirvReadVerify(
102112
const char *pIn, size_t InSz, const uint32_t *SpecConstIds,
103113
const uint64_t *SpecConstVals, unsigned SpecConstSz, LLVMContext &Context,
@@ -128,6 +138,7 @@ int spirvReadVerify(
128138
return -1;
129139
}
130140
PrepareModuleStructs(*SpirM);
141+
fixAlignmentAttributes(*SpirM);
131142
// Bool-value need to separate functionality and debug errors
132143
bool BrokenDebugInfo = false;
133144
Status = llvm::verifyModule(*SpirM, nullptr, &BrokenDebugInfo);

0 commit comments

Comments
 (0)