Files
clang-p2996/llvm/test/Transforms/LICM/pr64897.ll
Nikita Popov 753c51bf88 [AST] Fix size merging for MustAlias sets (#73820)
AST checks aliasing with MustAlias sets by only checking the
representative pointer (getSomePointer). This is only correct if the
Size and AATags information of that pointer also includes the
Size/AATags of all other pointers in the set.

When we add a new pointer to the AliasSet, we do perform this update
(see the code in AliasSet::addPointer). However, if a pointer already in
the MustAlias set is used with a new size, we currently do not update
the representative pointer, resulting in miscompilations. Fix this by
adding the missing update.

This is a targeted fix using the current representation. There are a
couple of alternatives:
* For MustAlias sets, don't store per-pointer Size/AATags at all. This
would make it clear that there is only one set of common Size/AATags for
all pointers.
* Check against all pointers in the set even for MustAlias. This is what
https://github.com/llvm/llvm-project/pull/65731 proposes to do as part
of a larger change to AST representation.

Fixes https://github.com/llvm/llvm-project/issues/64897.
2023-12-07 10:45:48 +01:00

45 lines
1.5 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt -S -passes=licm < %s | FileCheck %s
define void @test(i1 %c, i8 %x) {
; CHECK-LABEL: define void @test(
; CHECK-SAME: i1 [[C:%.*]], i8 [[X:%.*]]) {
; CHECK-NEXT: start:
; CHECK-NEXT: [[A:%.*]] = alloca [16 x i8], align 8
; 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: br label [[LOOP:%.*]]
; CHECK: loop:
; 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: [[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: ret void
;
start:
%a = alloca [16 x i8], align 8
%p = getelementptr inbounds i8, ptr %a, i64 8
%p.copy = getelementptr inbounds i8, ptr %a, i64 8
%p2 = getelementptr inbounds i8, ptr %a, i64 12
br label %loop
loop:
store i32 u0x11111111, ptr %p
store i32 u0x22, ptr %p.copy
store i64 u0x3333333333333333, ptr %p.copy
%val = load i8, ptr %p2
call void @use(i8 %val)
store i8 0, ptr %p2
br i1 %c, label %loop, label %exit
exit:
ret void
}
declare void @use(i8)