[llvm] ed7ae1a - Add coverage of GlobalsModRef's indirect global case
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 10 15:54:34 PST 2022
Author: Philip Reames
Date: 2022-01-10T15:54:26-08:00
New Revision: ed7ae1af7237df965ac8452fc67eca8db60fd878
URL: https://github.com/llvm/llvm-project/commit/ed7ae1af7237df965ac8452fc67eca8db60fd878
DIFF: https://github.com/llvm/llvm-project/commit/ed7ae1af7237df965ac8452fc67eca8db60fd878.diff
LOG: Add coverage of GlobalsModRef's indirect global case
Added:
Modified:
llvm/test/Analysis/GlobalsModRef/indirect-global.ll
Removed:
################################################################################
diff --git a/llvm/test/Analysis/GlobalsModRef/indirect-global.ll b/llvm/test/Analysis/GlobalsModRef/indirect-global.ll
index de21fe79a5283..661eae091b247 100644
--- a/llvm/test/Analysis/GlobalsModRef/indirect-global.ll
+++ b/llvm/test/Analysis/GlobalsModRef/indirect-global.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -basic-aa -globals-aa -gvn -instcombine -S -enable-unsafe-globalsmodref-alias-results | FileCheck %s
; RUN: opt < %s -aa-pipeline=basic-aa,globals-aa -passes="require<globals-aa>,function(gvn,instcombine)" -S -enable-unsafe-globalsmodref-alias-results | FileCheck %s
;
@@ -7,20 +8,90 @@
@G = internal global i32* null ; <i32**> [#uses=3]
declare i8* @malloc(i32)
-define void @test() {
- %a = call i8* @malloc(i32 4)
- %A = bitcast i8* %a to i32*
- store i32* %A, i32** @G
- ret void
+define void @malloc_init() {
+; CHECK-LABEL: @malloc_init(
+; CHECK-NEXT: [[A:%.*]] = call dereferenceable_or_null(4) i8* @malloc(i32 4)
+; CHECK-NEXT: store i8* [[A]], i8** bitcast (i32** @G to i8**), align 8
+; CHECK-NEXT: ret void
+;
+ %a = call i8* @malloc(i32 4)
+ %A = bitcast i8* %a to i32*
+ store i32* %A, i32** @G
+ ret void
+}
+
+define i32 @malloc_test(i32* %P) {
+; CHECK-LABEL: @malloc_test(
+; CHECK-NEXT: store i32 123, i32* [[P:%.*]], align 4
+; CHECK-NEXT: ret i32 0
+;
+ %g1 = load i32*, i32** @G ; <i32*> [#uses=2]
+ %h1 = load i32, i32* %g1 ; <i32> [#uses=1]
+ store i32 123, i32* %P
+ %g2 = load i32*, i32** @G ; <i32*> [#uses=0]
+ %h2 = load i32, i32* %g1 ; <i32> [#uses=1]
+ %X = sub i32 %h1, %h2 ; <i32> [#uses=1]
+ ret i32 %X
+}
+
+ at G2 = internal global i32* null ; <i32**> [#uses=3]
+
+declare i8* @calloc(i32, i32)
+define void @calloc_init() {
+; CHECK-LABEL: @calloc_init(
+; CHECK-NEXT: [[A:%.*]] = call dereferenceable_or_null(4) i8* @calloc(i32 4, i32 1)
+; CHECK-NEXT: store i8* [[A]], i8** bitcast (i32** @G2 to i8**), align 8
+; CHECK-NEXT: ret void
+;
+ %a = call i8* @calloc(i32 4, i32 1)
+ %A = bitcast i8* %a to i32*
+ store i32* %A, i32** @G2
+ ret void
}
-define i32 @test1(i32* %P) {
-; CHECK: ret i32 0
- %g1 = load i32*, i32** @G ; <i32*> [#uses=2]
- %h1 = load i32, i32* %g1 ; <i32> [#uses=1]
- store i32 123, i32* %P
- %g2 = load i32*, i32** @G ; <i32*> [#uses=0]
- %h2 = load i32, i32* %g1 ; <i32> [#uses=1]
- %X = sub i32 %h1, %h2 ; <i32> [#uses=1]
- ret i32 %X
+define i32 @calloc_test(i32* %P) {
+; CHECK-LABEL: @calloc_test(
+; CHECK-NEXT: store i32 123, i32* [[P:%.*]], align 4
+; CHECK-NEXT: ret i32 0
+;
+ %g1 = load i32*, i32** @G2 ; <i32*> [#uses=2]
+ %h1 = load i32, i32* %g1 ; <i32> [#uses=1]
+ store i32 123, i32* %P
+ %g2 = load i32*, i32** @G2 ; <i32*> [#uses=0]
+ %h2 = load i32, i32* %g1 ; <i32> [#uses=1]
+ %X = sub i32 %h1, %h2 ; <i32> [#uses=1]
+ ret i32 %X
+}
+
+ at G3 = internal global i32* null ; <i32**> [#uses=3]
+
+declare noalias i8* @my_alloc(i32)
+define void @my_alloc_init() {
+; CHECK-LABEL: @my_alloc_init(
+; CHECK-NEXT: [[A:%.*]] = call i8* @my_alloc(i32 4)
+; CHECK-NEXT: store i8* [[A]], i8** bitcast (i32** @G3 to i8**), align 8
+; CHECK-NEXT: ret void
+;
+ %a = call i8* @my_alloc(i32 4)
+ %A = bitcast i8* %a to i32*
+ store i32* %A, i32** @G3
+ ret void
+}
+
+define i32 @my_alloc_test(i32* %P) {
+; CHECK-LABEL: @my_alloc_test(
+; CHECK-NEXT: [[G1:%.*]] = load i32*, i32** @G3, align 8
+; CHECK-NEXT: [[H1:%.*]] = load i32, i32* [[G1]], align 4
+; CHECK-NEXT: store i32 123, i32* [[P:%.*]], align 4
+; CHECK-NEXT: [[H2:%.*]] = load i32, i32* [[G1]], align 4
+; CHECK-NEXT: [[X:%.*]] = sub i32 [[H1]], [[H2]]
+; CHECK-NEXT: ret i32 [[X]]
+;
+ %g1 = load i32*, i32** @G3 ; <i32*> [#uses=2]
+ %h1 = load i32, i32* %g1 ; <i32> [#uses=1]
+ store i32 123, i32* %P
+ %g2 = load i32*, i32** @G3 ; <i32*> [#uses=0]
+ %h2 = load i32, i32* %g1 ; <i32> [#uses=1]
+ %X = sub i32 %h1, %h2 ; <i32> [#uses=1]
+ ret i32 %X
}
More information about the llvm-commits
mailing list