[llvm-branch-commits] [llvm-branch] r319952 - Merging r312509:

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Dec 6 12:45:18 PST 2017


Author: tstellar
Date: Wed Dec  6 12:45:18 2017
New Revision: 319952

URL: http://llvm.org/viewvc/llvm-project?rev=319952&view=rev
Log:
Merging r312509:

------------------------------------------------------------------------
r312509 | dannyb | 2017-09-04 19:17:42 -0700 (Mon, 04 Sep 2017) | 1 line

NewGVN: Fix PR 34452 by passing instruction all the way down when we do aggregate value simplification
------------------------------------------------------------------------

Added:
    llvm/branches/release_50/test/Transforms/NewGVN/pr34452.ll
Modified:
    llvm/branches/release_50/lib/Transforms/Scalar/NewGVN.cpp

Modified: llvm/branches/release_50/lib/Transforms/Scalar/NewGVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_50/lib/Transforms/Scalar/NewGVN.cpp?rev=319952&r1=319951&r2=319952&view=diff
==============================================================================
--- llvm/branches/release_50/lib/Transforms/Scalar/NewGVN.cpp (original)
+++ llvm/branches/release_50/lib/Transforms/Scalar/NewGVN.cpp Wed Dec  6 12:45:18 2017
@@ -586,8 +586,8 @@ public:
 private:
   // Expression handling.
   const Expression *createExpression(Instruction *) const;
-  const Expression *createBinaryExpression(unsigned, Type *, Value *,
-                                           Value *) const;
+  const Expression *createBinaryExpression(unsigned, Type *, Value *, Value *,
+                                           Instruction *) const;
   PHIExpression *createPHIExpression(Instruction *, bool &HasBackEdge,
                                      bool &OriginalOpsConstant) const;
   const DeadExpression *createDeadExpression() const;
@@ -902,8 +902,8 @@ bool NewGVN::setBasicExpressionInfo(Inst
 }
 
 const Expression *NewGVN::createBinaryExpression(unsigned Opcode, Type *T,
-                                                 Value *Arg1,
-                                                 Value *Arg2) const {
+                                                 Value *Arg1, Value *Arg2,
+                                                 Instruction *I) const {
   auto *E = new (ExpressionAllocator) BasicExpression(2);
 
   E->setType(T);
@@ -921,7 +921,7 @@ const Expression *NewGVN::createBinaryEx
   E->op_push_back(lookupOperandLeader(Arg2));
 
   Value *V = SimplifyBinOp(Opcode, E->getOperand(0), E->getOperand(1), SQ);
-  if (const Expression *SimplifiedE = checkSimplificationResults(E, nullptr, V))
+  if (const Expression *SimplifiedE = checkSimplificationResults(E, I, V))
     return SimplifiedE;
   return E;
 }
@@ -1699,8 +1699,9 @@ NewGVN::performSymbolicAggrValueEvaluati
         // expression.
         assert(II->getNumArgOperands() == 2 &&
                "Expect two args for recognised intrinsics.");
-        return createBinaryExpression(
-            Opcode, EI->getType(), II->getArgOperand(0), II->getArgOperand(1));
+        return createBinaryExpression(Opcode, EI->getType(),
+                                      II->getArgOperand(0),
+                                      II->getArgOperand(1), I);
       }
     }
   }
@@ -1933,6 +1934,7 @@ void NewGVN::touchAndErase(Map &M, const
 }
 
 void NewGVN::addAdditionalUsers(Value *To, Value *User) const {
+  assert(User && To != User);
   if (isa<Instruction>(To))
     AdditionalUsers[To].insert(User);
 }

Added: llvm/branches/release_50/test/Transforms/NewGVN/pr34452.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_50/test/Transforms/NewGVN/pr34452.ll?rev=319952&view=auto
==============================================================================
--- llvm/branches/release_50/test/Transforms/NewGVN/pr34452.ll (added)
+++ llvm/branches/release_50/test/Transforms/NewGVN/pr34452.ll Wed Dec  6 12:45:18 2017
@@ -0,0 +1,49 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -newgvn -S < %s | FileCheck %s
+;; Ensure we don't crash when simplifying aggregate value expressions
+source_filename = "bugpoint-output-09f7a24.bc"
+
+ at WHOLELINE = external local_unnamed_addr global i32, align 4
+
+; Function Attrs: nounwind uwtable
+define void @sgrep() local_unnamed_addr #0 {
+; CHECK-LABEL: @sgrep(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    [[TMP0:%.*]] = load i32, i32* @WHOLELINE, align 4, !tbaa !1
+; CHECK-NEXT:    [[TOBOOL:%.*]] = icmp eq i32 [[TMP0]], 0
+; CHECK-NEXT:    [[DOT:%.*]] = select i1 [[TOBOOL]], i32 2048, i32 2047
+; CHECK-NEXT:    br label [[WHILE_BODY_US:%.*]]
+; CHECK:       while.body.us:
+; CHECK-NEXT:    [[START_1230_US:%.*]] = phi i32 [ [[DOT]], [[ENTRY:%.*]] ], [ 0, [[WHILE_BODY_US]] ]
+; CHECK-NEXT:    [[TMP1:%.*]] = sext i32 [[START_1230_US]] to i64
+; CHECK-NEXT:    [[TMP2:%.*]] = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 0, i64 [[TMP1]])
+; CHECK-NEXT:    br label [[WHILE_BODY_US]]
+;
+entry:
+  %0 = load i32, i32* @WHOLELINE, align 4, !tbaa !1
+  %tobool = icmp eq i32 %0, 0
+  %. = select i1 %tobool, i32 2048, i32 2047
+  br label %while.body.us
+
+while.body.us:                                    ; preds = %while.body.us, %entry
+  %start.1230.us = phi i32 [ %., %entry ], [ 0, %while.body.us ]
+  %1 = sext i32 %start.1230.us to i64
+  %2 = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 0, i64 %1)
+  %.res302 = extractvalue { i64, i1 } %2, 0
+  %3 = icmp sge i64 undef, %.res302
+  br label %while.body.us
+}
+
+; Function Attrs: nounwind readnone speculatable
+declare { i64, i1 } @llvm.sadd.with.overflow.i64(i64, i64) #1
+
+attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "polly-optimized" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { nounwind readnone speculatable }
+
+!llvm.ident = !{!0}
+
+!0 = !{!"clang version 6.0.0 (trunk 311664) (llvm/trunk 311666)"}
+!1 = !{!2, !2, i64 0}
+!2 = !{!"int", !3, i64 0}
+!3 = !{!"omnipotent char", !4, i64 0}
+!4 = !{!"Simple C/C++ TBAA"}




More information about the llvm-branch-commits mailing list