Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 Dec 2017 14:44:35 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org
Subject:   svn commit: r326899 - in vendor/llvm/dist: lib/Target/BPF lib/Transforms/Scalar test/CodeGen/BPF test/Transforms/NewGVN
Message-ID:  <201712161444.vBGEiZXM032321@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Sat Dec 16 14:44:35 2017
New Revision: 326899
URL: https://svnweb.freebsd.org/changeset/base/326899

Log:
  Vendor import of llvm 5.0.1 release r320880:
  https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_501/final@320880

Added:
  vendor/llvm/dist/test/Transforms/NewGVN/pr34452.ll
Modified:
  vendor/llvm/dist/lib/Target/BPF/BPFISelLowering.cpp
  vendor/llvm/dist/lib/Target/BPF/BPFInstrInfo.td
  vendor/llvm/dist/lib/Transforms/Scalar/NewGVN.cpp
  vendor/llvm/dist/test/CodeGen/BPF/select_ri.ll

Modified: vendor/llvm/dist/lib/Target/BPF/BPFISelLowering.cpp
==============================================================================
--- vendor/llvm/dist/lib/Target/BPF/BPFISelLowering.cpp	Sat Dec 16 14:36:21 2017	(r326898)
+++ vendor/llvm/dist/lib/Target/BPF/BPFISelLowering.cpp	Sat Dec 16 14:44:35 2017	(r326899)
@@ -578,11 +578,15 @@ BPFTargetLowering::EmitInstrWithCustomInserter(Machine
         .addReg(LHS)
         .addReg(MI.getOperand(2).getReg())
         .addMBB(Copy1MBB);
-  else
+  else {
+    int64_t imm32 = MI.getOperand(2).getImm();
+    // sanity check before we build J*_ri instruction.
+    assert (isInt<32>(imm32));
     BuildMI(BB, DL, TII.get(NewCC))
         .addReg(LHS)
-        .addImm(MI.getOperand(2).getImm())
+        .addImm(imm32)
         .addMBB(Copy1MBB);
+  }
 
   // Copy0MBB:
   //  %FalseValue = ...

Modified: vendor/llvm/dist/lib/Target/BPF/BPFInstrInfo.td
==============================================================================
--- vendor/llvm/dist/lib/Target/BPF/BPFInstrInfo.td	Sat Dec 16 14:36:21 2017	(r326898)
+++ vendor/llvm/dist/lib/Target/BPF/BPFInstrInfo.td	Sat Dec 16 14:44:35 2017	(r326899)
@@ -464,7 +464,7 @@ let usesCustomInserter = 1 in {
                       (ins GPR:$lhs, i64imm:$rhs, i64imm:$imm, GPR:$src, GPR:$src2),
                       "# Select PSEUDO $dst = $lhs $imm $rhs ? $src : $src2",
                       [(set i64:$dst,
-                       (BPFselectcc i64:$lhs, (i64 imm:$rhs), (i64 imm:$imm), i64:$src, i64:$src2))]>;
+                       (BPFselectcc i64:$lhs, (i64 i64immSExt32:$rhs), (i64 imm:$imm), i64:$src, i64:$src2))]>;
 }
 
 // load 64-bit global addr into register

Modified: vendor/llvm/dist/lib/Transforms/Scalar/NewGVN.cpp
==============================================================================
--- vendor/llvm/dist/lib/Transforms/Scalar/NewGVN.cpp	Sat Dec 16 14:36:21 2017	(r326898)
+++ vendor/llvm/dist/lib/Transforms/Scalar/NewGVN.cpp	Sat Dec 16 14:44:35 2017	(r326899)
@@ -586,8 +586,8 @@ class NewGVN { (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(Instruction *I, Ba
 }
 
 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::createBinaryExpression(unsig
   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::performSymbolicAggrValueEvaluation(Instruction
         // 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 KeyType &Key)
 }
 
 void NewGVN::addAdditionalUsers(Value *To, Value *User) const {
+  assert(User && To != User);
   if (isa<Instruction>(To))
     AdditionalUsers[To].insert(User);
 }

Modified: vendor/llvm/dist/test/CodeGen/BPF/select_ri.ll
==============================================================================
--- vendor/llvm/dist/test/CodeGen/BPF/select_ri.ll	Sat Dec 16 14:36:21 2017	(r326898)
+++ vendor/llvm/dist/test/CodeGen/BPF/select_ri.ll	Sat Dec 16 14:44:35 2017	(r326899)
@@ -25,3 +25,38 @@ entry:
 }
 
 attributes #0 = { norecurse nounwind readonly }
+
+; test immediate out of 32-bit range
+; Source file:
+
+; unsigned long long
+; load_word(void *buf, unsigned long long off)
+; asm("llvm.bpf.load.word");
+;
+; int
+; foo(void *buf)
+; {
+;  unsigned long long sum = 0;
+;
+;  sum += load_word(buf, 100);
+;  sum += load_word(buf, 104);
+;
+;  if (sum != 0x1ffffffffULL)
+;    return ~0U;
+;
+;  return 0;
+;}
+
+; Function Attrs: nounwind readonly
+define i32 @foo(i8*) local_unnamed_addr #0 {
+  %2 = tail call i64 @llvm.bpf.load.word(i8* %0, i64 100)
+  %3 = tail call i64 @llvm.bpf.load.word(i8* %0, i64 104)
+  %4 = add i64 %3, %2
+  %5 = icmp ne i64 %4, 8589934591
+; CHECK:  r{{[0-9]+}} = 8589934591ll
+  %6 = sext i1 %5 to i32
+  ret i32 %6
+}
+
+; Function Attrs: nounwind readonly
+declare i64 @llvm.bpf.load.word(i8*, i64) #1

Added: vendor/llvm/dist/test/Transforms/NewGVN/pr34452.ll
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/llvm/dist/test/Transforms/NewGVN/pr34452.ll	Sat Dec 16 14:44:35 2017	(r326899)
@@ -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"
+
+@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"}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712161444.vBGEiZXM032321>