Skip to content

Commit adfd46c

Browse files
kcyganik1igcbot
authored andcommitted
[Autobackout][FuncReg]Revert of change: 89e6a4b
Force alignment 1 for every element of packed struct The packed struct is definied by align 1. In our code the first buffer was created with the correct byte-size, but then the re-alignment took place to align struct's members. The second alignment that took place didn't remember about packed-struct align 1, so this PR forces it.
1 parent 1517ea6 commit adfd46c

File tree

3 files changed

+5
-71
lines changed

3 files changed

+5
-71
lines changed

IGC/Compiler/Optimizer/OpenCLPasses/ProgramScopeConstants/ProgramScopeConstantAnalysis.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -412,22 +412,10 @@ void ProgramScopeConstantAnalysis::addData(Constant* initializer,
412412
DataVector& inlineProgramScopeBuffer,
413413
PointerOffsetInfoList& pointerOffsetInfoList,
414414
BufferOffsetMap& inlineProgramScopeOffsets,
415-
unsigned addressSpace,
416-
bool forceAlignmentOne)
415+
unsigned addressSpace)
417416
{
418417
// Initial alignment padding before insert the current constant into the buffer.
419-
alignment_t typeAlignment = m_DL->getABITypeAlignment(initializer->getType());
420-
if (forceAlignmentOne)
421-
typeAlignment = 1;
422-
alignBuffer(inlineProgramScopeBuffer, typeAlignment);
423-
424-
// If the initializer is packed struct make sure, that every variable inside
425-
// will have also align 1
426-
if (StructType* s = dyn_cast<StructType>(initializer->getType()))
427-
{
428-
if (cast<StructType>(s)->isPacked())
429-
forceAlignmentOne = true;
430-
}
418+
alignBuffer(inlineProgramScopeBuffer, m_DL->getABITypeAlignment(initializer->getType()));
431419

432420
// We need to do extra work with pointers here: we don't know their actual addresses
433421
// at compile time so we find the offset from the base of the buffer they point to
@@ -613,7 +601,7 @@ void ProgramScopeConstantAnalysis::addData(Constant* initializer,
613601
Constant* C = initializer->getAggregateElement(i);
614602
IGC_ASSERT_MESSAGE(C, "getAggregateElement returned null, unsupported constant");
615603
// Since the type may not be primitive, extra alignment is required.
616-
addData(C, inlineProgramScopeBuffer, pointerOffsetInfoList, inlineProgramScopeOffsets, addressSpace, forceAlignmentOne);
604+
addData(C, inlineProgramScopeBuffer, pointerOffsetInfoList, inlineProgramScopeOffsets, addressSpace);
617605
}
618606
}
619607
// And, finally, we have to handle base types - ints and floats.
@@ -644,5 +632,5 @@ void ProgramScopeConstantAnalysis::addData(Constant* initializer,
644632

645633
// final padding. This gets used by the vec3 types that will insert zero padding at the
646634
// end after inserting the actual vector contents (this is due to sizeof(vec3) == 4 * sizeof(scalarType)).
647-
alignBuffer(inlineProgramScopeBuffer, typeAlignment);
635+
alignBuffer(inlineProgramScopeBuffer, m_DL->getABITypeAlignment(initializer->getType()));
648636
}

IGC/Compiler/Optimizer/OpenCLPasses/ProgramScopeConstants/ProgramScopeConstantAnalysis.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,7 @@ namespace IGC
8181
DataVector& inlineConstantBuffer,
8282
PointerOffsetInfoList& pointerOffsetInfo,
8383
BufferOffsetMap& inlineProgramScopeOffsets,
84-
unsigned addressSpace,
85-
bool forceAlignmentOne=false);
84+
unsigned addressSpace);
8685

8786
/// @brief Align the buffer according to the required alignment
8887
/// @param buffer The buffer to align.

IGC/Compiler/tests/ProgramScopeConstantAnalysis/packed-struct.ll

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)