mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-04 06:09:05 +00:00
When rewriting the pointer operand to a load or store which has
alignment guarantees attached, re-compute the alignment so that we consider offsets which impact alignment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164690 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
81b001a220
commit
238fd1591e
@ -1992,6 +1992,9 @@ private:
|
||||
Value *NewPtr = getAdjustedAllocaPtr(IRB,
|
||||
LI.getPointerOperand()->getType());
|
||||
LI.setOperand(0, NewPtr);
|
||||
if (LI.getAlignment())
|
||||
LI.setAlignment(MinAlign(NewAI.getAlignment(),
|
||||
BeginOffset - NewAllocaBeginOffset));
|
||||
DEBUG(dbgs() << " to: " << LI << "\n");
|
||||
|
||||
deleteIfTriviallyDead(OldOp);
|
||||
@ -2043,6 +2046,9 @@ private:
|
||||
Value *NewPtr = getAdjustedAllocaPtr(IRB,
|
||||
SI.getPointerOperand()->getType());
|
||||
SI.setOperand(1, NewPtr);
|
||||
if (SI.getAlignment())
|
||||
SI.setAlignment(MinAlign(NewAI.getAlignment(),
|
||||
BeginOffset - NewAllocaBeginOffset));
|
||||
DEBUG(dbgs() << " to: " << SI << "\n");
|
||||
|
||||
deleteIfTriviallyDead(OldOp);
|
||||
|
@ -28,6 +28,24 @@ entry:
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @test2() {
|
||||
; CHECK: @test2
|
||||
; CHECK: alloca i16, align 2
|
||||
; CHECK: load i8* %{{.*}}, align 1
|
||||
; CHECK: store i8 42, i8* %{{.*}}, align 1
|
||||
; CHECK: ret void
|
||||
|
||||
entry:
|
||||
%a = alloca { i8, i8, i8, i8 }, align 2
|
||||
%gep1 = getelementptr { i8, i8, i8, i8 }* %a, i32 0, i32 1
|
||||
%cast1 = bitcast i8* %gep1 to i16*
|
||||
store volatile i16 0, i16* %cast1
|
||||
%gep2 = getelementptr { i8, i8, i8, i8 }* %a, i32 0, i32 2
|
||||
%result = load i8* %gep2, align 2
|
||||
store i8 42, i8* %gep2, align 2
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @PR13920(<2 x i64>* %a, i16* %b) {
|
||||
; Test that alignments on memcpy intrinsics get propagated to loads and stores.
|
||||
; CHECK: @PR13920
|
||||
|
Loading…
Reference in New Issue
Block a user