[llvm] r371565 - [MemorySSA] Do not create memoryaccesses for debug info intrinsics.

Alina Sbirlea via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 10 15:35:27 PDT 2019


Author: asbirlea
Date: Tue Sep 10 15:35:27 2019
New Revision: 371565

URL: http://llvm.org/viewvc/llvm-project?rev=371565&view=rev
Log:
[MemorySSA] Do not create memoryaccesses for debug info intrinsics.

Summary:
Do not model debuginfo intrinsics in MemorySSA.
Regularly these are non-memory modifying instructions. With -disable-basicaa, they were being modelled as Defs.

Reviewers: george.burgess.iv

Subscribers: aprantl, Prazek, sanjoy.google, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D67307

Added:
    llvm/trunk/test/Analysis/MemorySSA/debugvalue2.ll
Modified:
    llvm/trunk/lib/Analysis/MemorySSA.cpp

Modified: llvm/trunk/lib/Analysis/MemorySSA.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/MemorySSA.cpp?rev=371565&r1=371564&r2=371565&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/MemorySSA.cpp (original)
+++ llvm/trunk/lib/Analysis/MemorySSA.cpp Tue Sep 10 15:35:27 2019
@@ -285,6 +285,11 @@ instructionClobbersQuery(const MemoryDef
     case Intrinsic::invariant_end:
     case Intrinsic::assume:
       return {false, NoAlias};
+    case Intrinsic::dbg_addr:
+    case Intrinsic::dbg_declare:
+    case Intrinsic::dbg_label:
+    case Intrinsic::dbg_value:
+      llvm_unreachable("debuginfo shouldn't have associated defs!");
     default:
       break;
     }
@@ -1725,11 +1730,13 @@ MemoryUseOrDef *MemorySSA::createNewAcce
                                            AliasAnalysisType *AAP,
                                            const MemoryUseOrDef *Template) {
   // The assume intrinsic has a control dependency which we model by claiming
-  // that it writes arbitrarily. Ignore that fake memory dependency here.
+  // that it writes arbitrarily. Debuginfo intrinsics may be considered
+  // clobbers when we have a nonstandard AA pipeline. Ignore these fake memory
+  // dependencies here.
   // FIXME: Replace this special casing with a more accurate modelling of
   // assume's control dependency.
   if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I))
-    if (II->getIntrinsicID() == Intrinsic::assume)
+    if (II->getIntrinsicID() == Intrinsic::assume || isa<DbgInfoIntrinsic>(II))
       return nullptr;
 
   bool Def, Use;

Added: llvm/trunk/test/Analysis/MemorySSA/debugvalue2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/MemorySSA/debugvalue2.ll?rev=371565&view=auto
==============================================================================
--- llvm/trunk/test/Analysis/MemorySSA/debugvalue2.ll (added)
+++ llvm/trunk/test/Analysis/MemorySSA/debugvalue2.ll Tue Sep 10 15:35:27 2019
@@ -0,0 +1,54 @@
+; RUN: opt -disable-basicaa -print-memoryssa -disable-output %s 2>&1 | FileCheck %s
+
+; Note that the test crashes the MemorySSA verification when doing loop-rotate,
+; if debuginfo is modelled in MemorySSA, due to the fact that MemorySSA is not
+; updated when adding/removing debuginfo intrinsics.
+
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK-LABEL: @overflow_iter_var
+; CHECK-NOT: MemoryDef
+define void @overflow_iter_var() !dbg !11 {
+entry:
+  call void @llvm.dbg.value(metadata i16 0, metadata !16, metadata !DIExpression()), !dbg !18
+  br label %for.cond
+
+for.cond:                                         ; preds = %for.body, %entry
+  call void @llvm.dbg.value(metadata i16 0, metadata !16, metadata !DIExpression()), !dbg !18
+  call void @llvm.dbg.value(metadata i16 undef, metadata !20, metadata !DIExpression()), !dbg !21
+  br i1 undef, label %for.end, label %for.body
+
+for.body:                                         ; preds = %for.cond
+  %0 = load i16, i16* undef, align 1
+  br label %for.cond
+
+for.end:                                          ; preds = %for.cond
+  ret void
+}
+
+; Function Attrs: nounwind readnone speculatable willreturn
+declare void @llvm.dbg.value(metadata, metadata, metadata) #1
+
+attributes #1 = { nounwind readnone speculatable willreturn }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!10}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, nameTableKind: None)
+!1 = !DIFile(filename: "2_loops.c", directory: "/")
+!2 = !{}
+!3 = !{}
+!6 = !DICompositeType(tag: DW_TAG_array_type, baseType: !7, size: 4096, elements: !8)
+!7 = !DIBasicType(name: "int", size: 16, encoding: DW_ATE_signed)
+!8 = !{!9}
+!9 = !DISubrange(count: 256)
+!10 = !{i32 2, !"Debug Info Version", i32 3}
+!11 = distinct !DISubprogram(name: "overflow_iter_var", scope: !1, file: !1, line: 20, type: !12, scopeLine: 21, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
+!12 = !DISubroutineType(types: !13)
+!13 = !{null, !14, !14}
+!14 = !DIBasicType(name: "unsigned int", size: 16, encoding: DW_ATE_unsigned)
+!16 = !DILocalVariable(name: "i", scope: !17, file: !1, line: 23, type: !14)
+!17 = distinct !DILexicalBlock(scope: !11, file: !1, line: 23, column: 3)
+!18 = !DILocation(line: 0, scope: !17)
+!20 = !DILocalVariable(name: "stop1", arg: 1, scope: !11, file: !1, line: 20, type: !14)
+!21 = !DILocation(line: 0, scope: !11)




More information about the llvm-commits mailing list