[llvm] d987fe6 - [Attributor] Properly repair broken unittest

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 12 02:24:13 PST 2023


Author: Johannes Doerfert
Date: 2023-01-12T02:23:59-08:00
New Revision: d987fe67adb71ac30261fe5b4fe82bdad9405b7a

URL: https://github.com/llvm/llvm-project/commit/d987fe67adb71ac30261fe5b4fe82bdad9405b7a
DIFF: https://github.com/llvm/llvm-project/commit/d987fe67adb71ac30261fe5b4fe82bdad9405b7a.diff

LOG: [Attributor] Properly repair broken unittest

Reverts 2dc7c7095153822ecd1a8f43aa4c185f9e80cc00 and instead repairs the
unittest properly. The test was broken as that it used references to
dead functions, assumed dead functions could reach code, assumed code
would not be deleted, and did not pre-query all assertion queries.
Arguably, the querry AAs don't make it easy to use them outside the
attributor pipeline, maybe we just should not (or should fix them
pessimistically). For now, the unittest is fixed.

Added: 
    

Modified: 
    llvm/unittests/Transforms/IPO/AttributorTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/unittests/Transforms/IPO/AttributorTest.cpp b/llvm/unittests/Transforms/IPO/AttributorTest.cpp
index 65173ec7d5f7..14dffc28978b 100644
--- a/llvm/unittests/Transforms/IPO/AttributorTest.cpp
+++ b/llvm/unittests/Transforms/IPO/AttributorTest.cpp
@@ -77,7 +77,7 @@ TEST_F(AttributorTestBase, TestCast) {
 TEST_F(AttributorTestBase, AAReachabilityTest) {
   const char *ModuleString = R"(
     @x = external global i32
-    define internal void @func4() {
+    define void @func4() {
       store i32 0, i32* @x
       ret void
     }
@@ -98,7 +98,7 @@ TEST_F(AttributorTestBase, AAReachabilityTest) {
       ret void
     }
 
-    define internal void @func1() {
+    define void @func1() {
     entry:
       call void @func2()
       ret void
@@ -112,13 +112,14 @@ TEST_F(AttributorTestBase, AAReachabilityTest) {
       ret void
     }
 
-    define internal void @func6() {
+    define void @func6() {
     entry:
+      store i32 0, i32* @x
       call void @func5(void ()* @func3)
       ret void
     }
 
-    define internal void @func7() {
+    define void @func7() {
     entry:
       call void @func2()
       call void @func4()
@@ -186,13 +187,12 @@ TEST_F(AttributorTestBase, AAReachabilityTest) {
   F6AA.canReach(A, F4);
   F7AA.instructionCanReach(A, F7FirstCB, F3);
   F7AA.instructionCanReach(A, F7FirstCB, F4);
+  F9AA.instructionCanReach(A, F9SecondInst, F3);
   F9AA.instructionCanReach(A, F9FirstInst, F3);
   F9AA.instructionCanReach(A, F9FirstInst, F4);
 
   A.run();
 
-  // Under investigation
-#if 0
   ASSERT_TRUE(F1AA.canReach(A, F3));
   ASSERT_FALSE(F1AA.canReach(A, F4));
 
@@ -211,7 +211,6 @@ TEST_F(AttributorTestBase, AAReachabilityTest) {
   // Because func10 calls the func4 after the call to func9 it is reachable but
   // as it requires backwards logic we would need AA::isPotentiallyReachable.
   ASSERT_FALSE(F9AA.instructionCanReach(A, F9FirstInst, F4));
-#endif
 }
 
 } // namespace llvm


        


More information about the llvm-commits mailing list