Commit 30ae859c authored by Johannes Doerfert's avatar Johannes Doerfert
Browse files

[Attributor][FIX] Store alignment only holds for the pointer value

We accidentally used the store alignment for the value operand as well,
which is incorrect and crashed the SPASS application in the test suite.
parent 59733525
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -3420,9 +3420,10 @@ static unsigned int getKnownAlignForUse(Attributor &A,
  }

  const Value *UseV = U->get();
  if (auto *SI = dyn_cast<StoreInst>(I))
  if (auto *SI = dyn_cast<StoreInst>(I)) {
    if (SI->getPointerOperand() == UseV)
      Alignment = SI->getAlignment();
  else if (auto *LI = dyn_cast<LoadInst>(I))
  } else if (auto *LI = dyn_cast<LoadInst>(I))
    Alignment = LI->getAlignment();

  if (Alignment <= 1)
+7 −0
Original line number Diff line number Diff line
@@ -501,6 +501,13 @@ define i64* @int2ptr(i64 %i) {
  ret i64* %i2p
}

; Use the store alignment only for the pointer operand.
define void @aligned_store(i8* %Value, i8** %Ptr) {
; ATTRIBUTOR: define void @aligned_store(i8* nofree writeonly %Value, i8** nocapture nofree nonnull writeonly align 32 dereferenceable(8) %Ptr)
  store i8* %Value, i8** %Ptr, align 32
  ret void
}

attributes #0 = { nounwind uwtable noinline }
attributes #1 = { uwtable noinline }
attributes #2 = { "null-pointer-is-valid"="true" }