diff --git a/llvm/lib/Transforms/Utils/InlineFunction.cpp b/llvm/lib/Transforms/Utils/InlineFunction.cpp --- a/llvm/lib/Transforms/Utils/InlineFunction.cpp +++ b/llvm/lib/Transforms/Utils/InlineFunction.cpp @@ -1071,7 +1071,8 @@ SmallSetVector NAPtrArgs; for (const Value *V : PtrArgs) { SmallVector Objects; - getUnderlyingObjects(V, Objects, /* LI = */ nullptr); + getUnderlyingObjects(V, Objects, /* LI = */ nullptr, + /* MaxLookup = */ 0); for (const Value *O : Objects) ObjSet.insert(O); diff --git a/llvm/test/Transforms/Inline/inline-noalias.ll b/llvm/test/Transforms/Inline/inline-noalias.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/Inline/inline-noalias.ll @@ -0,0 +1,82 @@ +; RUN: opt < %s -passes=inline -S | FileCheck %s + +%struct.baz = type <{ double, [4 x %struct.bar], [168 x i8] }> +%struct.bar = type <{ i32 }> +%struct.quux = type <{ [8 x i8], [4 x %struct.wibble] }> +%struct.wibble = type <{ i32 }> + +define dso_local signext i32 @main() { +bb: + %tmp = alloca i32, align 4 + %tmp1 = alloca [2 x %struct.baz], align 8 + %tmp2 = getelementptr [2 x %struct.baz], [2 x %struct.baz]* %tmp1, i64 0, i64 -1 + %tmp3 = getelementptr %struct.baz, %struct.baz* %tmp2, i64 1 + %tmp4 = bitcast %struct.baz* %tmp3 to [0 x %struct.quux]* + call void @foo([0 x %struct.quux]* %tmp4, i32* nonnull %tmp), !alias.scope !0, !noalias !5 +; CHECK: %tmp5.i = load i32, i32* %tmp4.i, align 4, !alias.scope ![[ALIAS0:[0-9]+]], !noalias !{{[0-9]+}} +; CHECK: store i32 2, i32* %tmp23.i, align 4, !alias.scope !{{[0-9]+}}, !noalias ![[NOALIAS1:[0-9]+]] + unreachable +} + +; Function Attrs: alwaysinline +define dso_local void @foo([0 x %struct.quux]* noalias nocapture nonnull %arg, i32* noalias nocapture dereferenceable(4) %arg1) alwaysinline { +bb: + %tmp = getelementptr [0 x %struct.quux], [0 x %struct.quux]* %arg, i64 0, i64 0, i32 0, i64 -20 + %tmp2 = getelementptr i8, i8* %tmp, i64 1 + %tmp3 = getelementptr inbounds i8, i8* %tmp2, i64 4 + %tmp4 = bitcast i8* %tmp3 to i32* + %tmp5 = load i32, i32* %tmp4, align 4, !alias.scope !14, !noalias !17 ; load from pointer derived from %arg + %tmp6 = load i32, i32* %arg1, align 4, !alias.scope !24, !noalias !25 + %tmp7 = sdiv i32 %tmp6, 2 + %tmp8 = sext i32 %tmp7 to i64 + %tmp11 = mul nsw i64 %tmp8, 24 + %tmp12 = getelementptr [0 x %struct.quux], [0 x %struct.quux]* %arg, i64 0, i64 0, i32 0, i64 -24 + %tmp13 = getelementptr inbounds i8, i8* %tmp12, i64 %tmp11 + %tmp14 = getelementptr i8, i8* %tmp13, i64 -3 + %tmp15 = trunc i64 1 to i32 + %tmp16 = and i32 %tmp15, 3 + %tmp17 = add nuw nsw i32 %tmp16, 1 + %tmp18 = shl nuw nsw i32 %tmp17, 2 + %tmp19 = getelementptr inbounds i8, i8* %tmp14, i64 1 + %tmp20 = getelementptr inbounds i8, i8* %tmp19, i64 8 + %tmp21 = getelementptr i8, i8* %tmp20, i64 -4 + %tmp22 = getelementptr inbounds i8, i8* %tmp21, i64 1 + %tmp23 = bitcast i8* %tmp22 to i32* + store i32 %tmp17, i32* %tmp23, align 4, !alias.scope !28, !noalias !29 ; store to pointer derived from %arg + ret void +} + +; CHECK: ![[NODE_ARG:[0-9]+]] = distinct !{![[NODE_ARG]], !{{[0-9]+}}, !"foo: %arg"} +; CHECK: ![[ALIAS0]] = !{{{.*}}![[NODE_ARG]],{{.*}}}{{$}} +; CHECK-NOT: ![[NOALIAS1]] = !{{{.*}}![[NODE_ARG]],{{.*}}}{{$}} + +!0 = !{!1, !3, !4} +!1 = distinct !{!1, !2, !"foo"} +!2 = distinct !{!2, !"domain: main"} +!3 = distinct !{!3, !2, !"a1%tt"} +!4 = distinct !{!4, !2, !"T_2"} +!5 = !{!6, !7, !8, !9, !10, !11, !12, !13} +!6 = distinct !{!6, !2, !"k"} +!7 = distinct !{!7, !2, !"j"} +!8 = distinct !{!8, !2, !"#4"} +!9 = distinct !{!9, !2, !"#3"} +!10 = distinct !{!10, !2, !"i"} +!11 = distinct !{!11, !2, !"idx"} +!12 = distinct !{!12, !2, !"#1"} +!13 = distinct !{!13, !2, !"#2"} +!14 = !{!15} +!15 = distinct !{!15, !16, !"a%i"} +!16 = distinct !{!16, !"domain: foo"} +!17 = !{!18, !19, !20, !21, !22, !23} +!18 = distinct !{!18, !16, !"#2"} +!19 = distinct !{!19, !16, !"j"} +!20 = distinct !{!20, !16, !"foo"} +!21 = distinct !{!21, !16, !"#1"} +!22 = distinct !{!22, !16, !"d"} +!23 = distinct !{!23, !16, !"i"} +!24 = !{!22} +!25 = !{!18, !26, !27, !19, !20, !21, !15, !23} +!26 = distinct !{!26, !16, !"a[]"} +!27 = distinct !{!27, !16, !"a"} +!28 = !{!27} +!29 = !{!18, !19, !22, !21, !23}