IR: Add 'distinct' MDNodes to bitcode and assembly

Propagate whether `MDNode`s are 'distinct' through the other types of IR
(assembly and bitcode).  This adds the `distinct` keyword to assembly.

Currently, no one actually calls `MDNode::getDistinct()`, so these nodes
only get created for:

  - self-references, which are never uniqued, and
  - nodes whose operands are replaced that hit a uniquing collision.

The concept of distinct nodes is still not quite first-class, since
distinct-ness doesn't yet survive across `MapMetadata()`.

Part of PR22111.

llvm-svn: 225474
diff --git a/llvm/test/Transforms/Inline/noalias-cs.ll b/llvm/test/Transforms/Inline/noalias-cs.ll
index 44bce57..da5ddd6 100644
--- a/llvm/test/Transforms/Inline/noalias-cs.ll
+++ b/llvm/test/Transforms/Inline/noalias-cs.ll
@@ -47,36 +47,36 @@
 attributes #0 = { nounwind uwtable }
 
 !0 = !{!1}
-!1 = !{!1, !2, !"hello: %a"}
-!2 = !{!2, !"hello"}
+!1 = distinct !{!1, !2, !"hello: %a"}
+!2 = distinct !{!2, !"hello"}
 !3 = !{!4, !6}
-!4 = !{!4, !5, !"hello2: %a"}
-!5 = !{!5, !"hello2"}
-!6 = !{!6, !5, !"hello2: %b"}
+!4 = distinct !{!4, !5, !"hello2: %a"}
+!5 = distinct !{!5, !"hello2"}
+!6 = distinct !{!6, !5, !"hello2: %b"}
 !7 = !{!4}
 !8 = !{!6}
 
 ; CHECK: !0 = !{!1, !3}
-; CHECK: !1 = !{!1, !2, !"hello2: %a"}
-; CHECK: !2 = !{!2, !"hello2"}
-; CHECK: !3 = !{!3, !2, !"hello2: %b"}
+; CHECK: !1 = distinct !{!1, !2, !"hello2: %a"}
+; CHECK: !2 = distinct !{!2, !"hello2"}
+; CHECK: !3 = distinct !{!3, !2, !"hello2: %b"}
 ; CHECK: !4 = !{!1}
 ; CHECK: !5 = !{!3}
 ; CHECK: !6 = !{!7, !9, !10}
-; CHECK: !7 = !{!7, !8, !"hello2: %a"}
-; CHECK: !8 = !{!8, !"hello2"}
-; CHECK: !9 = !{!9, !8, !"hello2: %b"}
-; CHECK: !10 = !{!10, !11, !"hello: %a"}
-; CHECK: !11 = !{!11, !"hello"}
+; CHECK: !7 = distinct !{!7, !8, !"hello2: %a"}
+; CHECK: !8 = distinct !{!8, !"hello2"}
+; CHECK: !9 = distinct !{!9, !8, !"hello2: %b"}
+; CHECK: !10 = distinct !{!10, !11, !"hello: %a"}
+; CHECK: !11 = distinct !{!11, !"hello"}
 ; CHECK: !12 = !{!7}
 ; CHECK: !13 = !{!9, !10}
 ; CHECK: !14 = !{!9}
 ; CHECK: !15 = !{!7, !10}
 ; CHECK: !16 = !{!10}
 ; CHECK: !17 = !{!18, !20}
-; CHECK: !18 = !{!18, !19, !"hello2: %a"}
-; CHECK: !19 = !{!19, !"hello2"}
-; CHECK: !20 = !{!20, !19, !"hello2: %b"}
+; CHECK: !18 = distinct !{!18, !19, !"hello2: %a"}
+; CHECK: !19 = distinct !{!19, !"hello2"}
+; CHECK: !20 = distinct !{!20, !19, !"hello2: %b"}
 ; CHECK: !21 = !{!18, !10}
 ; CHECK: !22 = !{!20}
 ; CHECK: !23 = !{!20, !10}