OSDN Git Service

[AST] Clarify printing of unknown size locations [NFC]
authorPhilip Reames <listmail@philipreames.com>
Fri, 17 Aug 2018 23:17:31 +0000 (23:17 +0000)
committerPhilip Reames <listmail@philipreames.com>
Fri, 17 Aug 2018 23:17:31 +0000 (23:17 +0000)
Printing "unknown" is much more clear than an arbitrary large integer

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340108 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/AliasSetTracker.cpp
test/Analysis/AliasSet/memtransfer.ll

index 2879dea..23c598d 100644 (file)
@@ -603,7 +603,10 @@ void AliasSet::print(raw_ostream &OS) const {
     for (iterator I = begin(), E = end(); I != E; ++I) {
       if (I != begin()) OS << ", ";
       I.getPointer()->printAsOperand(OS << "(");
-      OS << ", " << I.getSize() << ")";
+      if (I.getSize() == MemoryLocation::UnknownSize)
+        OS << ", unknown)";
+      else 
+        OS << ", " << I.getSize() << ")";
     }
   }
   if (!UnknownInsts.empty()) {
index 0d7e601..2634dd3 100644 (file)
@@ -3,6 +3,28 @@
 @s = global i8 1, align 1
 @d = global i8 2, align 1
 
+
+; CHECK: Alias sets for function 'test_known_size':
+; CHECK: Alias Set Tracker: 2 alias sets for 2 pointer values.
+; CHECK:   AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Ref       Pointers: (i8* %s, 1)
+; CHECK:   AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod       Pointers: (i8* %d, 1)
+define void @test_known_size(i8* noalias %s, i8* noalias %d) {
+entry:
+  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %d, i8* %s, i64 1, i1 false)
+  ret void
+}
+
+; CHECK: Alias sets for function 'test_unknown_size':
+; CHECK: Alias Set Tracker: 2 alias sets for 2 pointer values.
+; CHECK:   AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Ref       Pointers: (i8* %s, unknown)
+; CHECK:   AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod       Pointers: (i8* %d, unknown)
+define void @test_unknown_size(i8* noalias %s, i8* noalias %d, i64 %len) {
+entry:
+  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %d, i8* %s, i64 %len, i1 false)
+  ret void
+}
+
+
 ; CHECK: Alias sets for function 'test1':
 ; CHECK: Alias Set Tracker: 3 alias sets for 4 pointer values.
 ; CHECK:   AliasSet[0x{{[0-9a-f]+}}, 1] must alias, Mod       Pointers: (i8* %a, 1)