diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index 275068d8c2740..bb3fcae2dbbd9 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -3796,10 +3796,10 @@ struct AAAlignImpl : AAAlign { ChangeStatus LoadStoreChanged = ChangeStatus::UNCHANGED; // Check for users that allow alignment annotations. - Value &AnchorVal = getIRPosition().getAnchorValue(); - for (const Use &U : AnchorVal.uses()) { + Value &AssociatedValue = getAssociatedValue(); + for (const Use &U : AssociatedValue.uses()) { if (auto *SI = dyn_cast(U.getUser())) { - if (SI->getPointerOperand() == &AnchorVal) + if (SI->getPointerOperand() == &AssociatedValue) if (SI->getAlignment() < getAssumedAlign()) { STATS_DECLTRACK(AAAlign, Store, "Number of times alignment added to a store"); @@ -3807,7 +3807,7 @@ struct AAAlignImpl : AAAlign { LoadStoreChanged = ChangeStatus::CHANGED; } } else if (auto *LI = dyn_cast(U.getUser())) { - if (LI->getPointerOperand() == &AnchorVal) + if (LI->getPointerOperand() == &AssociatedValue) if (LI->getAlignment() < getAssumedAlign()) { LI->setAlignment(Align(getAssumedAlign())); STATS_DECLTRACK(AAAlign, Load, diff --git a/llvm/test/Transforms/Attributor/align.ll b/llvm/test/Transforms/Attributor/align.ll index 7f3abd998c3cf..ae8a3dbb1148e 100644 --- a/llvm/test/Transforms/Attributor/align.ll +++ b/llvm/test/Transforms/Attributor/align.ll @@ -527,6 +527,33 @@ define void @aligned_store(i8* %Value, i8** %Ptr) { ret void } +; UTC_ARGS: --enable +declare i8* @some_func(i8*) +define void @align_call_op_not_store(i8* align 2048 %arg) { +; ATTRIBUTOR-LABEL: define {{[^@]+}}@align_call_op_not_store +; ATTRIBUTOR-SAME: (i8* align 2048 [[ARG:%.*]]) +; ATTRIBUTOR-NEXT: [[UNKNOWN:%.*]] = call i8* @some_func(i8* align 2048 [[ARG]]) +; ATTRIBUTOR-NEXT: store i8 0, i8* [[UNKNOWN]] +; ATTRIBUTOR-NEXT: ret void +; + %unknown = call i8* @some_func(i8* %arg) + store i8 0, i8* %unknown + ret void +} +define void @align_store_after_bc(i32* align 2048 %arg) { +; +; ATTRIBUTOR-LABEL: define {{[^@]+}}@align_store_after_bc +; ATTRIBUTOR-SAME: (i32* nocapture nofree nonnull writeonly align 2048 dereferenceable(1) [[ARG:%.*]]) +; ATTRIBUTOR-NEXT: [[BC:%.*]] = bitcast i32* [[ARG]] to i8* +; ATTRIBUTOR-NEXT: store i8 0, i8* [[BC]], align 2048 +; ATTRIBUTOR-NEXT: ret void +; + %bc = bitcast i32* %arg to i8* + store i8 0, i8* %bc + ret void +} +; UTC_ARGS: --disable + attributes #0 = { nounwind uwtable noinline } attributes #1 = { uwtable noinline } attributes #2 = { "null-pointer-is-valid"="true" } diff --git a/llvm/test/Transforms/Attributor/returned.ll b/llvm/test/Transforms/Attributor/returned.ll index c18745356d64a..0fe094b10be28 100644 --- a/llvm/test/Transforms/Attributor/returned.ll +++ b/llvm/test/Transforms/Attributor/returned.ll @@ -781,7 +781,7 @@ define i32 @exact(i32* %a) { %c3 = call i32* @non_exact_3(i32* %a) ; We can use the information of the weak function non_exact_3 because it was ; given to us and not derived (the alignment of the returned argument). -; ATTRIBUTOR: %c4 = load i32, i32* %c3, align 32 +; ATTRIBUTOR: %c4 = load i32, i32* %c3 %c4 = load i32, i32* %c3 ; FIXME: %c2 and %c3 should be replaced but not %c0 or %c1! ; ATTRIBUTOR: %add1 = add i32 %c0, %c1