Skip to content

[AST] Fix size merging for MustAlias sets #73820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion llvm/lib/Analysis/AliasSetTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,16 @@ AliasSet &AliasSetTracker::getAliasSetFor(const MemoryLocation &MemLoc) {
// due to a quirk of alias analysis behavior. Since alias(undef, undef)
// is NoAlias, mergeAliasSetsForPointer(undef, ...) will not find the
// the right set for undef, even if it exists.
if (Entry.updateSizeAndAAInfo(Size, AAInfo))
if (Entry.updateSizeAndAAInfo(Size, AAInfo)) {
mergeAliasSetsForPointer(Pointer, Size, AAInfo, MustAliasAll);

// For MustAlias sets, also update Size/AAInfo of the representative
// pointer.
AliasSet &AS = *Entry.getAliasSet(*this);
if (AS.isMustAlias())
if (AliasSet::PointerRec *P = AS.getSomePointer())
P->updateSizeAndAAInfo(Size, AAInfo);
}
// Return the set!
return *Entry.getAliasSet(*this)->getForwardedTarget(*this);
}
Expand Down
8 changes: 3 additions & 5 deletions llvm/test/Transforms/LICM/pr64897.ll
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt -S -passes=licm < %s | FileCheck %s

; FIXME: This is a miscompile.
define void @test(i1 %c, i8 %x) {
; CHECK-LABEL: define void @test(
; CHECK-SAME: i1 [[C:%.*]], i8 [[X:%.*]]) {
Expand All @@ -10,17 +9,16 @@ define void @test(i1 %c, i8 %x) {
; CHECK-NEXT: [[P:%.*]] = getelementptr inbounds i8, ptr [[A]], i64 8
; CHECK-NEXT: [[P_COPY:%.*]] = getelementptr inbounds i8, ptr [[A]], i64 8
; CHECK-NEXT: [[P2:%.*]] = getelementptr inbounds i8, ptr [[A]], i64 12
; CHECK-NEXT: [[P2_PROMOTED:%.*]] = load i8, ptr [[P2]], align 1
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
; CHECK-NEXT: [[TMP0:%.*]] = phi i8 [ 0, [[LOOP]] ], [ [[P2_PROMOTED]], [[START:%.*]] ]
; CHECK-NEXT: store i32 286331153, ptr [[P]], align 4
; CHECK-NEXT: store i32 34, ptr [[P_COPY]], align 4
; CHECK-NEXT: store i64 3689348814741910323, ptr [[P_COPY]], align 4
; CHECK-NEXT: call void @use(i8 [[TMP0]])
; CHECK-NEXT: [[VAL:%.*]] = load i8, ptr [[P2]], align 1
; CHECK-NEXT: call void @use(i8 [[VAL]])
; CHECK-NEXT: store i8 0, ptr [[P2]], align 1
; CHECK-NEXT: br i1 [[C]], label [[LOOP]], label [[EXIT:%.*]]
; CHECK: exit:
; CHECK-NEXT: store i8 0, ptr [[P2]], align 1
; CHECK-NEXT: ret void
;
start:
Expand Down