[llvm] r332017 - Add regression test for r331976

George Burgess IV via llvm-commits llvm-commits at lists.llvm.org
Thu May 10 11:37:54 PDT 2018


Author: gbiv
Date: Thu May 10 11:37:54 2018
New Revision: 332017

URL: http://llvm.org/viewvc/llvm-project?rev=332017&view=rev
Log:
Add regression test for r331976

In general, it's difficult to poke the ConstantExpr code in CFLAA, since
LLVM is so great at eagerly reducing ConstantExprs. :)

Sadly, this only shows a functional difference from before the patch
because CFLAA has some special logic around taking loads of non-pointers
into account. Namely, with the broken select behavior, CFLAA will
completely fail to take note of @g3. Since CFLAA doesn't have any record
about @g3 when we do an alias query for @g3 and %a, it conservatively
answers MayAlias. When we properly take @g3 into account with the new
select logic, we get NoAlias for this query.

I suspect that the aforementioned "special logic" isn't completely
correct, but this test-case should prevent future wonky aliasing results
from appearing for these flavors of ConstantExprs, so I think it's still
worth having.

Added:
    llvm/trunk/test/Analysis/CFLAliasAnalysis/Steensgaard/const-exprs.ll

Added: llvm/trunk/test/Analysis/CFLAliasAnalysis/Steensgaard/const-exprs.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CFLAliasAnalysis/Steensgaard/const-exprs.ll?rev=332017&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/CFLAliasAnalysis/Steensgaard/const-exprs.ll (added)
+++ llvm/trunk/test/Analysis/CFLAliasAnalysis/Steensgaard/const-exprs.ll Thu May 10 11:37:54 2018
@@ -0,0 +1,30 @@
+; RUN: opt %s -S -disable-basicaa -cfl-steens-aa -aa-eval -print-all-alias-modref-info 2>&1 | FileCheck %s
+;
+; Regression: we weren't properly checking constexpr selects.
+
+ at g = extern_weak dso_local global i32, align 4
+ at g2 = extern_weak dso_local global i32, align 4
+ at g3 = extern_weak dso_local global i32, align 4
+
+; CHECK-LABEL: Function: foo
+; CHECK: NoAlias: i32* select (i1 icmp ne (i32* @g, i32* null), i32* @g2, i32* @g3), i32** %a
+; CHECK: NoAlias: i32* %b, i32** %a
+; CHECK: MayAlias: i32* %b, i32* select (i1 icmp ne (i32* @g, i32* null), i32* @g2, i32* @g3)
+; CHECK: NoAlias: i32* @g2, i32** %a
+; CHECK: MayAlias: i32* @g2, i32* select (i1 icmp ne (i32* @g, i32* null), i32* @g2, i32* @g3)
+; CHECK: MayAlias: i32* %b, i32* @g2
+; CHECK: NoAlias: i32* @g3, i32** %a
+; CHECK: MayAlias: i32* @g3, i32* select (i1 icmp ne (i32* @g, i32* null), i32* @g2, i32* @g3)
+; CHECK: MayAlias: i32* %b, i32* @g3
+; CHECK: MayAlias: i32* @g2, i32* @g3
+
+define void @foo() {
+entry:
+  %a = alloca i32*, align 8
+  store i32* select (i1 icmp ne (i32* @g, i32* null), i32* @g2, i32* @g3), i32** %a
+  %b = load i32*, i32** %a
+  %c = load i32, i32* %b
+  %d = load i32, i32* @g2
+  %e = load i32, i32* @g3
+  ret void
+}




More information about the llvm-commits mailing list