[PATCH] D32654: Fix AliasSetTracker

Piotr Padlewski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 28 12:11:12 PDT 2017


Prazek created this revision.

AliasSetTracker was crashing when the UnknownInstruction
was reduced to Value (llvm.invariant.group.barrier(null) to null)


https://reviews.llvm.org/D32654

Files:
  include/llvm/Analysis/AliasSetTracker.h
  test/Transforms/LICM/2017-28-04-invariant.group.ll


Index: test/Transforms/LICM/2017-28-04-invariant.group.ll
===================================================================
--- /dev/null
+++ test/Transforms/LICM/2017-28-04-invariant.group.ll
@@ -0,0 +1,41 @@
+; RUN: opt -licm < %s
+
+; This test check if nothing explodes if invariant.group.barrier of null is
+; reduced to null.
+; Function Attrs: nounwind uwtable
+define fastcc void @_ZN12_GLOBAL__N_117GlobalISelEmitter3runERN4llvm11raw_ostreamE() unnamed_addr align 2 {
+entry:
+  switch i8 undef, label %if.end8.i.i [
+    i8 0, label %if.then.i.i3
+    i8 1, label %if.then4.i.i
+  ]
+
+if.then.i.i3:                                     ; preds = %entry
+  br label %for.body
+
+if.then4.i.i:                                     ; preds = %entry
+  unreachable
+
+if.end8.i.i:                                      ; preds = %entry
+  unreachable
+
+for.body:                                         ; preds = %for.cond66.i.i.for.end151.i.i_crit_edge, %if.then.i.i3
+  br label %for.body69.i.i
+
+for.body69.i.i:                                   ; preds = %for.body69.i.i, %for.body
+  %0 = call i8* @llvm.invariant.group.barrier(i8* null) #2, !noalias !1
+  br i1 undef, label %for.cond66.i.i.for.end151.i.i_crit_edge, label %for.body69.i.i
+
+for.cond66.i.i.for.end151.i.i_crit_edge:          ; preds = %for.body69.i.i
+  br label %for.body
+}
+
+; Function Attrs: inaccessiblememonly nounwind
+declare i8* @llvm.invariant.group.barrier(i8*) #1
+
+attributes #1 = { inaccessiblememonly nounwind }
+attributes #2 = { nounwind }
+
+!1 = !{!2}
+!2 = distinct !{!2, !3, !"_ZN4llvm5Error11takePayloadEv: %agg.result"}
+!3 = distinct !{!3, !"_ZN4llvm5Error11takePayloadEv"}
Index: include/llvm/Analysis/AliasSetTracker.h
===================================================================
--- include/llvm/Analysis/AliasSetTracker.h
+++ include/llvm/Analysis/AliasSetTracker.h
@@ -174,7 +174,7 @@
 
   Instruction *getUnknownInst(unsigned i) const {
     assert(i < UnknownInsts.size());
-    return cast_or_null<Instruction>(UnknownInsts[i]);
+    return dyn_cast_or_null<Instruction>(UnknownInsts[i]);
   }
 
 public:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32654.97138.patch
Type: text/x-patch
Size: 2127 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170428/015bbd21/attachment.bin>


More information about the llvm-commits mailing list