Skip to content

Commit

Permalink
[NFC][IR] Remove unused assignment to Offset
Browse files Browse the repository at this point in the history
This value is overwritten anyway, so let's remove it
  • Loading branch information
AtariDreams authored and arsenm committed Dec 30, 2022
1 parent 98265db commit dd50e26
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions llvm/lib/IR/Operator.cpp
Expand Up @@ -63,19 +63,17 @@ Align GEPOperator::getMaxPreservedAlignment(const DataLayout &DL) const {
Align Result = Align(llvm::Value::MaximumAlignment);
for (gep_type_iterator GTI = gep_type_begin(this), GTE = gep_type_end(this);
GTI != GTE; ++GTI) {
int64_t Offset = 1;
uint64_t Offset;
ConstantInt *OpC = dyn_cast<ConstantInt>(GTI.getOperand());

if (StructType *STy = GTI.getStructTypeOrNull()) {
const StructLayout *SL = DL.getStructLayout(STy);
Offset = SL->getElementOffset(OpC->getZExtValue());
} else {
assert(GTI.isSequential() && "should be sequencial");
/// If the index isn't know we take 1 because it is the index that will
/// If the index isn't known, we take 1 because it is the index that will
/// give the worse alignment of the offset.
int64_t ElemCount = 1;
if (OpC)
ElemCount = OpC->getZExtValue();
const uint64_t ElemCount = OpC ? OpC->getZExtValue() : 1;
Offset = DL.getTypeAllocSize(GTI.getIndexedType()) * ElemCount;
}
Result = Align(MinAlign(Offset, Result.value()));
Expand Down

0 comments on commit dd50e26

Please sign in to comment.