Add torrent_info.rename_file() to the python bindings

--- bindings/python/src/torrent_info.cpp
+++ bindings/python/src/torrent_info.cpp
@@ -123,6 +123,7 @@
         .def("file_at", &torrent_info::file_at, return_internal_reference<>())
         .def("file_at_offset", &torrent_info::file_at_offset)
         .def("files", &files, (arg("storage")=false))
+        .def("rename_file", &torrent_info::rename_file)

         .def("priv", &torrent_info::priv)
         .def("trackers", range(begin_trackers, end_trackers))


方針が間違っている

方針が間違っている

--- 0420/0420_2_2.cpp
+++ 0420/0420_2_2.cpp
@@ -1,19 +1,50 @@
+// http://poj.org/problem?id=3532
+// 合成公式：直列で R_1 + R_2 、 並列で R_1 R_2 / (R_1 + R_2) を使おうと思っていた。
+// しかし、この方針では絶対解けないことがわかった。以下のプログラムは不正解です。
+/* たとえば
+4 6
+1 2 1
+1 3 1
+1 4 1
+2 3 1
+2 4 1
+4 3 1
+という入力では失敗する。どの区間でも合成できない。
+予備校の東大物理の講義で「合成の公式は覚えておく必要もないし、合成する必要もない」と言われた。私も、東大入試を解くときに合成公式を使ったことはない。
+その教訓が7年めぐってきて私に襲いかかった。
+これは電位の関係式と電流保存の関係式を立てて、連立1次方程式を解くしかなさそうですね……
+ */
+
 #include <iostream>
 #include <algorithm>
 #include <cmath>
 #include <iomanip>
 #include <vector>
+#include <queue>
 using namespace std;

 struct reg {
   int Y;
   double R;
+  /*
   bool operator <(const reg& right) const {
     return Y < right.Y;
   }
+  */
   reg(int y, double r) {
     Y = y;
     R = r;
+  }
+};
+
+struct pass {
+  int X;
+  double R;
+  bool used;
+  pass(int x, double r) {
+    X = x;
+    R = r;
+    used = false;
   }
 };

@@ -21,21 +52,54 @@
   int N, M;
   cin >> N >> M;
   vector<reg> V[110];
+  vector<pass> W[110];
   int x, y;
   double r;
   for (int i=0; i<M; i++) {
     cin >> x >> y >> r;
     x--; y--;
-    reg temp = reg(y, r);
-    vector<reg>::iterator itr = V[x].begin();
-    for (; itr != V[x].end(); itr++) {
-      if ((*itr).Y == y) break;
+    if (x > y) {
+      swap(x, y);
     }
-    if (itr != V[x].end()) {
-      V[x].push_back(temp);
+    W[y].push_back(pass(x, r));
+  }
+  bool visited[110];
+  fill(visited, visited+N, false);
+  queue<int> Q;
+  Q.push(N-1);
+  while (!Q.empty()) {
+    int v = Q.front();
+    Q.pop();
+    if (!visited[v]) {
+      visited[v] = true;
+      for (unsigned int i=0; i<W[v].size(); i++) {
+        int w = W[v][i].X;
+        if (!visited[w]) {
+          Q.push(w);
+        }
+      }
+    }
+  }
+  for (int i=0; i<N; i++) {
+    if (!visited[i]) {
+      W[i].clear();
     } else {
-      double rr = (*itr).R;
-      (*itr).R = r * rr / (r + rr);
+      int y = i;
+      for (unsigned int j=0; j<W[i].size(); j++) {
+        int x = W[i][j].X;
+        int r = W[i][j].R;
+        reg temp = reg(y, r);
+        vector<reg>::iterator itr = V[x].begin();
+        for (; itr != V[x].end(); itr++) {
+          if ((*itr).Y == y) break;
+        }
+        if (itr == V[x].end()) {
+          V[x].push_back(temp);
+        } else {
+          double rr = (*itr).R;
+          (*itr).R = r * rr / (r + rr);
+        }
+      }
     }
   }
   bool next = true;
@@ -44,14 +108,40 @@
     for (int i=0; i<N; i++) {
       for (unsigned int j=0; j<V[i].size(); j++) {
         int y = V[i][j].Y;
-        if (!V[y].empty()) {
+        if (V[y].size() == 1) {
           next = true;
           int ny = V[y][0].Y;
-          reg temp = reg(ny, V[i][j].R + V[y][0].R);
-
+          double nr = V[i][j].R + V[y][0].R;
+          // cerr << "nr = " << nr << ", V[y][0].R = " << V[y][0].R <<  endl;
+          cerr << i << " - " << y << " - " << ny << endl;
+          reg temp = reg(ny, nr);
+          V[i].erase(V[i].begin()+j);
+          V[y].erase(V[y].begin());
+          vector<reg>::iterator itr = V[i].begin();
+          for ( ; itr != V[i].end(); itr++) {
+              if ((*itr).Y == ny) break;
+          }
+          if (itr == V[i].end()) {
+            V[i].push_back(temp);
+            cerr << "reg = " << temp.R << endl;
+          } else {
+            cerr << "merged" << endl;
+            double rr = (*itr).R;
+            (*itr).R = nr * rr / (nr + rr);
+            cerr << "reg = " << (*itr).R << endl;
+          }
+          goto EXIT;
         }
       }
     }
+  EXIT:
+    continue;
   }
-  cout << fixed << setprecision(2) << round(S[0][N-1] * 100)/100 << endl;
+  for (unsigned i=0; i<V[0].size(); i++) {
+    if (V[0][i].Y == N-1) {
+      cout << fixed << setprecision(2) << round(V[0][i].R * 100)/100 << endl;
+      return 0;
+    }
+  }
+  return 1;
 }


Fix stupid old bug because of fucking bitwise operator precedence

--- src/Interrupts/Pic.cpp
+++ src/Interrupts/Pic.cpp
@@ -55,7 +55,7 @@
 void Pic::setMask(u16 mask) {
     _mask = mask;
     outb(PIC1_DATA, _mask&0x00FF);
-    outb(PIC2_DATA, _mask&0xFF00 >> 8);
+    outb(PIC2_DATA, (_mask&0xFF00) >> 8);
 }

 void Pic::activate(u8 irq) {


Accepted. I found the problem: missing new line, and not resetting registers.

--- 1/Interpreter.cpp
+++ 1/Interpreter.cpp
@@ -65,7 +65,7 @@
 	for (int testcase = 0; testcase < testcases; testcase++)
 	{
 		int addr = 0;
-		while ((cin.getline(line, 9)) && line[0] != '\0')
+		while (addr < 1000 && (cin.getline(line, 9)) && line[0] != '\0')
 		{
 			ram[addr++] = (line[0] - '0') * 100 + (line[1] - '0') * 10 + (line[2] - '0');
 		}
@@ -73,11 +73,16 @@
 		while (addr < 1000)
 			ram[addr++] = 0;

+		for (int i = 0; i < 10; i++)
+			registers[i] = 0;
+
 		ip = 0;
 		int numInstructions = 1;
 		while (runNextInstruction())
 			numInstructions++;

+		if (testcase > 0)
+			cout << endl;
 		cout << numInstructions << endl;
 	}
 	return 0;


Don't give up completely, maybe other AA can say something about this.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@20873 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Analysis/DataStructure/DataStructureAA.cpp
+++ lib/Analysis/DataStructure/DataStructureAA.cpp
@@ -138,7 +138,8 @@
   DSNode  *N1 = I->second.getNode(),  *N2 = J->second.getNode();
   unsigned O1 = I->second.getOffset(), O2 = J->second.getOffset();
   if (N1 == 0 || N2 == 0)
-    return MayAlias;  // Can't tell whether anything aliases null.
+    // Can't tell whether anything aliases null.
+    return AliasAnalysis::alias(V1, V1Size, V2, V2Size);

   // We can only make a judgment of one of the nodes is complete...
   if (N1->isComplete() || N2->isComplete()) {


Use mnenomics for process states on Darwin

Process states in `processes` table now use mnemonics instead of the
integer code. They follow closely to the states defined sys/proc.h,
which means processes with state as:

  state    value   meaning                           mnemonic
 -------- ------- --------------------------------- ----------
  SIDL     1       process being created by fork     'I'
  SRUN     2       currently runnable                'R'
  SSLEEP   3       sleeping on an address            'S'
  SSTOP    4       process debugging or suspension   'T'
  SZOMB    5       awaiting collection by parent     'Z'

Note: The mnemonics here will not match up with what `ps` or `top`
reports.

`ps` and `top` queries run state of all Mach Threads (by grabbing a Mach Task)
of a process, and then coalesces it to represent the process state.

This is no longer possible to do by non-Apple signed binaries,
as the only way to a Mach Task (and therefore list of Mach Threads)
is by calling `task_for_pid()`, which no longer works under
System Integrity Protection (SIP) introduced in OS X 10.11

--- osquery/tables/system/darwin/processes.cpp
+++ osquery/tables/system/darwin/processes.cpp
@@ -19,7 +19,6 @@
 #include <mach-o/dyld_images.h>

 #include <boost/algorithm/string.hpp>
-#include <boost/algorithm/string/trim.hpp>

 #include <osquery/core.h>
 #include <osquery/filesystem.h>
@@ -36,6 +35,14 @@

 #define CPU_TIME_RATIO 1000000
 #define START_TIME_RATIO 1000000000
+
+// Process states are as defined in sys/proc.h
+// SIDL   (1) Process being created by fork
+// SRUN   (2) Currently runnable
+// SSLEEP (3) Sleeping on an address
+// SSTOP  (4) Process debugging or suspension
+// SZOMB  (5) Awaiting collection by parent
+const char kProcessStateMapping[] = {' ', 'I', 'R', 'S', 'T', 'Z'};

 std::set<int> getProcList(const QueryContext &context) {
   std::set<int> pidlist;
@@ -68,8 +75,8 @@
     return pidlist;
   }

-  int num_pids = bufsize / sizeof(pid_t);
-  for (int i = 0; i < num_pids; ++i) {
+  size_t num_pids = bufsize / sizeof(pid_t);
+  for (size_t i = 0; i < num_pids; ++i) {
     // if the pid is negative or 0, it doesn't represent a real process so
     // continue the iterations so that we don't add it to the results set
     if (pids[i] <= 0) {
@@ -95,7 +102,7 @@
   uint32_t parent{0};
   uint32_t group{0};
   uint32_t status{0};
-  uint32_t nice{0};
+  int32_t nice{0};
   struct {
     uid_t uid{0};
     gid_t gid{0};
@@ -257,8 +264,10 @@
     if (getProcCred(pid, cred)) {
       r["parent"] = BIGINT(cred.parent);
       r["group"] = BIGINT(cred.group);
-      // Use Linux diction for process status/state.
-      r["state"] = INTEGER(cred.status);
+      // check if process state is one of the expected ones
+      r["state"] = (1 <= cred.status && cred.status <= 5)
+                       ? TEXT(kProcessStateMapping[cred.status])
+                       : TEXT('?');
       r["nice"] = INTEGER(cred.nice);
       r["uid"] = BIGINT(cred.real.uid);
       r["gid"] = BIGINT(cred.real.gid);
@@ -545,7 +554,7 @@
   }
 }

-QueryData genProcessMemoryMap(QueryContext& context) {
+QueryData genProcessMemoryMap(QueryContext &context) {
   QueryData results;

   auto pidlist = getProcList(context);


increase message level to ERR for max mappings (#3426)

--- lib/ApplicationFeatures/MaxMapCountFeature.cpp
+++ lib/ApplicationFeatures/MaxMapCountFeature.cpp
@@ -207,8 +207,8 @@
     if (lastLogStamp + logFrequency < now) {
       // do not log too often to avoid log spamming
       lastLogStamp = now;
-      LOG_TOPIC(WARN, Logger::MEMORY) << "process is near the maximum number of memory mappings. current: " << nmaps << ", maximum: " << maxMappings
-                                      << ". it may be sensible to increase the maximum number of mappings per process";
+      LOG_TOPIC(ERR, Logger::MEMORY) << "process is near the maximum number of memory mappings. current: " << nmaps << ", maximum: " << maxMappings
+                                     << ". it may be sensible to increase the maximum number of mappings per process";
     }
     return true;
   } catch (...) {


Increased maximum quality value from 5 to 6, and changed function to output the current quality value if no arguments are passed.  Also finished the quit command.

--- console_commands.cpp
+++ console_commands.cpp
@@ -545,30 +545,45 @@

 void quality(vectStr const& argv)
 {
-    if (argv.size() == 1)
-    {
-        std::stringstream strQual(argv[0]);
-        unsigned int newQuality;
-        if (!(strQual >> newQuality) || newQuality < 1 || newQuality > 5)
-        {
-            WriteOutput(TC_Console_Error::INVALID_ARG_VALUE);
-        }
-        else
-        {
-            sphSlices = newQuality * 3;
-            sphStacks = newQuality * 3;
-            InitDisplayLists();
-        }
-    }
-    else
-    {
-        TC_Console_Error::WrongArgCount(argv.size(), 1);
+    static unsigned int lastQuality = 4;    // Default quality is 4.
+    switch (argv.size())
+    {
+        case 0:
+        {
+            std::stringstream ssOutput;
+            ssOutput << "The current quality value is " << lastQuality << ".";
+            WriteOutput(ssOutput.str());
+            break;
+        }
+
+        case 1:
+        {
+            std::stringstream strQual(argv[0]);
+            unsigned int newQuality;
+            if (!(strQual >> newQuality) || newQuality < 1 || newQuality > 6)
+            {
+                WriteOutput(TC_Console_Error::INVALID_ARG_VALUE);
+            }
+            else
+            {
+                sphSlices = newQuality * 3;
+                sphStacks = newQuality * 3;
+                InitDisplayLists();
+                lastQuality = newQuality;
+            }
+            break;
+        }
+
+        default:
+            WriteOutput(TC_Console_Error::INVALID_NUM_ARGS_MORE);
+            break;
     }
 }

 void quit(vectStr const& argv)
 {
-
+    runProgram = false;
+    runAnim    = false;
 }

 void runanim(vectStr const& argv)
@@ -714,10 +729,11 @@
         "Changes the polygon count of the individual LED spheres making up the cube. "
         "Lowering the quality may result in higher performance at the cost of visual "
         "appearance. Usage:\n \n"
-        "    quality q    Where q is an integer from 1 (lowest quality) to 5 (highest)."));
+        "    quality q    Where q is an integer from 1 (lowest quality) to 6 (highest)."
+        "\n \nThe default quality is 4."));

     cmdList.push_back(new ConsoleCommand("quit", quit,
-        "Quits the program.  Any passed arguments are ignored."));
+        "Quits/closes Triclysm immediately.  Any passed arguments are ignored."));

     cmdList.push_back(new ConsoleCommand("runanim", runanim,
         "Toggles or sets the animation from updating.  Usage:\n \n"


[SelectionDAG] Get rid of recursion in CalcNodeSethiUllmanNumber

The recursive implementation of CalcNodeSethiUllmanNumber may
overflow stack on extremely long pred chains. This patch replaces it
with an equivalent iterative implementation.

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

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@305775 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
+++ lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
@@ -1861,28 +1861,68 @@
 /// Smaller number is the higher priority.
 static unsigned
 CalcNodeSethiUllmanNumber(const SUnit *SU, std::vector<unsigned> &SUNumbers) {
-  unsigned &SethiUllmanNumber = SUNumbers[SU->NodeNum];
-  if (SethiUllmanNumber != 0)
-    return SethiUllmanNumber;
-
-  unsigned Extra = 0;
-  for (const SDep &Pred : SU->Preds) {
-    if (Pred.isCtrl()) continue;  // ignore chain preds
-    SUnit *PredSU = Pred.getSUnit();
-    unsigned PredSethiUllman = CalcNodeSethiUllmanNumber(PredSU, SUNumbers);
-    if (PredSethiUllman > SethiUllmanNumber) {
-      SethiUllmanNumber = PredSethiUllman;
-      Extra = 0;
-    } else if (PredSethiUllman == SethiUllmanNumber)
-      ++Extra;
-  }
-
-  SethiUllmanNumber += Extra;
-
-  if (SethiUllmanNumber == 0)
-    SethiUllmanNumber = 1;
-
-  return SethiUllmanNumber;
+  if (SUNumbers[SU->NodeNum] != 0)
+    return SUNumbers[SU->NodeNum];
+
+  // Use WorkList to avoid stack overflow on excessively large IRs.
+  struct WorkState {
+    WorkState(const SUnit *SU) : SU(SU) {}
+    const SUnit *SU;
+    unsigned PredsProcessed = 0;
+  };
+
+  SmallVector<WorkState, 16> WorkList;
+  WorkList.push_back(SU);
+  while (!WorkList.empty()) {
+    auto &Temp = WorkList.back();
+    auto *TempSU = Temp.SU;
+    bool AllPredsKnown = true;
+    // Try to find a non-evaluated pred and push it into the processing stack.
+    for (unsigned P = Temp.PredsProcessed; P < TempSU->Preds.size(); ++P) {
+      auto &Pred = TempSU->Preds[P];
+      if (Pred.isCtrl()) continue;  // ignore chain preds
+      SUnit *PredSU = Pred.getSUnit();
+      if (SUNumbers[PredSU->NodeNum] == 0) {
+#ifndef NDEBUG
+        // In debug mode, check that we don't have such element in the stack.
+        for (auto It : WorkList)
+          assert(It.SU != PredSU && "Trying to push an element twice?");
+#endif
+        WorkList.push_back(PredSU);
+        AllPredsKnown = false;
+        // Next time start processing this one starting from the next pred.
+        Temp.PredsProcessed = P + 1;
+        break;
+      }
+    }
+
+    if (!AllPredsKnown)
+      continue;
+
+    // Once all preds are known, we can calculate the answer for this one.
+    unsigned SethiUllmanNumber = 0;
+    unsigned Extra = 0;
+    for (const SDep &Pred : TempSU->Preds) {
+      if (Pred.isCtrl()) continue;  // ignore chain preds
+      SUnit *PredSU = Pred.getSUnit();
+      unsigned PredSethiUllman = SUNumbers[PredSU->NodeNum];
+      assert(PredSethiUllman > 0 && "We should have evaluated this pred!");
+      if (PredSethiUllman > SethiUllmanNumber) {
+        SethiUllmanNumber = PredSethiUllman;
+        Extra = 0;
+      } else if (PredSethiUllman == SethiUllmanNumber)
+        ++Extra;
+    }
+
+    SethiUllmanNumber += Extra;
+    if (SethiUllmanNumber == 0)
+      SethiUllmanNumber = 1;
+    SUNumbers[TempSU->NodeNum] = SethiUllmanNumber;
+    WorkList.pop_back();
+  }
+
+  assert(SUNumbers[SU->NodeNum] > 0 && "SethiUllman should never be zero!");
+  return SUNumbers[SU->NodeNum];
 }

 /// CalculateSethiUllmanNumbers - Calculate Sethi-Ullman numbers of all


* Started FindPattern 'rewrite'.

* Started FindPattern 'rewrite'.

--- Hades-Memory/Hades-Memory/FindPattern.cpp
+++ Hades-Memory/Hades-Memory/FindPattern.cpp
@@ -24,6 +24,9 @@
 // Boost
 #pragma warning(push, 1)
 #include <boost/lexical_cast.hpp>
+#include <boost/spirit/include/qi.hpp>
+#include <boost/spirit/include/phoenix.hpp>
+#include <boost/spirit/include/support.hpp>
 #pragma warning(pop)

 // RapidXML
@@ -97,41 +100,48 @@
           ErrorString("Empty pattern or mask data."));
       }

-      // Ensure data is valid
-      if (Data.size() % 2)
+      // Convert data to byte buffer
+      // Todo: Ensure each 'byte' is two characters long
+      std::vector<BYTE> Bytes;
+      auto DataBeg = Data.cbegin();
+      auto DataEnd = Data.cend();
+      if (!boost::spirit::qi::phrase_parse(DataBeg, DataEnd,
+        *boost::spirit::qi::hex, boost::spirit::qi::space, Bytes)
+        || DataBeg != DataEnd)
       {
         BOOST_THROW_EXCEPTION(Error() <<
           ErrorFunction("FindPattern::Find") <<
-          ErrorString("Data size invalid."));
-      }
-
-      // Ensure mask is valid
-      if (Mask.size() * 2 != Data.size())
+          ErrorString("Failed to parse bytes."));
+      }
+
+      // Convert mask to bit flag
+      std::vector<bool> MaskFlags;
+      auto MaskBeg = Mask.cbegin();
+      auto MaskEnd = Mask.cend();
+      if (!boost::spirit::qi::parse(MaskBeg, MaskEnd,
+        *((boost::spirit::qi::lit("x") >> boost::spirit::qi::attr(true)) |
+        (boost::spirit::qi::lit("?") >> boost::spirit::qi::attr(false))),
+        MaskFlags) || MaskBeg != MaskEnd)
       {
         BOOST_THROW_EXCEPTION(Error() <<
           ErrorFunction("FindPattern::Find") <<
-          ErrorString("Mask size invalid."));
-      }
-
-      // Convert data to byte buffer
+          ErrorString("Failed to parse mask."));
+      }
+
+      // Sanity check
+      if (Bytes.size() != MaskFlags.size())
+      {
+        BOOST_THROW_EXCEPTION(Error() <<
+          ErrorFunction("FindPattern::Find") <<
+          ErrorString("Parsed data differs in size to parsed mask."));
+      }
+
+      // Convert to required format
+      // Todo: Do this as part of the parsing process
       std::vector<std::pair<BYTE, bool>> DataBuf;
-      for (auto i = Data.cbegin(), j = Mask.cbegin(); i != Data.cend();
-        i += 2, ++j)
-      {
-        std::basic_string<TCHAR> const CurrentStr(i, i + 2);
-        std::basic_stringstream<TCHAR> Converter(CurrentStr);
-        int Current(0);
-        if (!(Converter >> std::hex >> Current >> std::dec))
-        {
-          BOOST_THROW_EXCEPTION(Error() <<
-            ErrorFunction("FindPattern::Find") <<
-            ErrorString("Invalid data conversion."));
-        }
-
-        BYTE CurrentReal = static_cast<BYTE>(Current);
-        bool MaskFlag = *j == _T('x');
-
-        DataBuf.push_back(std::make_pair(CurrentReal, MaskFlag));
+      for (std::size_t i = 0; i != Bytes.size(); ++i)
+      {
+        DataBuf.push_back(std::make_pair(Bytes[i], MaskFlags[i]));
       }

       // Search memory for pattern


meta: prop key is returned by const reference rather than by copy

--- src/entt/meta/factory.hpp
+++ src/entt/meta/factory.hpp
@@ -80,7 +80,7 @@
         static internal::meta_prop_node node{
             nullptr,
             []() -> meta_any {
-                return std::get<0>(property);
+                return meta_any{std::in_place_type<const Key &>, std::get<0>(property)};
             },
             []() -> meta_any {
                 if constexpr(sizeof...(Value) == 0) {


Add helper function to get a 32-bit floating point constant. No functionality change.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@56418 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
+++ lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
@@ -2738,12 +2738,12 @@

 }

-// GetSignificand - Get the significand and build it into a floating-point
-// number with exponent of 1:
-//
-//   Op = (Op & 0x007fffff) | 0x3f800000;
-//
-// where Op is the hexidecimal representation of floating point value.
+/// GetSignificand - Get the significand and build it into a floating-point
+/// number with exponent of 1:
+///
+///   Op = (Op & 0x007fffff) | 0x3f800000;
+///
+/// where Op is the hexidecimal representation of floating point value.
 static SDValue
 GetSignificand(SelectionDAG &DAG, SDValue Op) {
     SDValue t1 = DAG.getNode(ISD::AND, MVT::i32, Op,
@@ -2753,11 +2753,11 @@
     return DAG.getNode(ISD::BIT_CONVERT, MVT::f32, t2);
 }

-// GetExponent - Get the exponent:
-//
-//   (float)((Op1 >> 23) - 127);
-//
-// where Op is the hexidecimal representation of floating point value.
+/// GetExponent - Get the exponent:
+///
+///   (float)((Op1 >> 23) - 127);
+///
+/// where Op is the hexidecimal representation of floating point value.
 static SDValue
 GetExponent(SelectionDAG &DAG, SDValue Op) {
     SDValue t1 = DAG.getNode(ISD::SRL, MVT::i32, Op,
@@ -2765,6 +2765,12 @@
     SDValue t2 = DAG.getNode(ISD::SUB, MVT::i32, t1,
                              DAG.getConstant(127, MVT::i32));
     return DAG.getNode(ISD::UINT_TO_FP, MVT::f32, t2);
+}
+
+/// getF32Constant - Get 32-bit floating point constant.
+static SDValue
+getF32Constant(SelectionDAG &DAG, unsigned Flt) {
+  return DAG.getConstantFP(APFloat(APInt(32, Flt)), MVT::f32);
 }

 /// Inlined utility function to implement binary input atomic intrinsics for
@@ -2798,8 +2804,7 @@
     //   #define LOG2OFe 1.4426950f
     //   IntegerPartOfX = ((int32_t)(X * LOG2OFe));
     SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, Op,
-                             DAG.getConstantFP(APFloat(
-                               APInt(32, 0x3fb8aa3b)), MVT::f32));
+                             getF32Constant(DAG, 0x3fb8aa3b));
     SDValue IntegerPartOfX = DAG.getNode(ISD::FP_TO_SINT, MVT::i32, t0);

     //   FractionalPartOfX = (X * LOG2OFe) - (float)IntegerPartOfX;
@@ -2819,15 +2824,12 @@
       //
       // error 0.0144103317, which is 6 bits
       SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, X,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3e814304)), MVT::f32));
+                               getF32Constant(DAG, 0x3e814304));
       SDValue t3 = DAG.getNode(ISD::FADD, MVT::f32, t2,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3f3c50c8)), MVT::f32));
+                               getF32Constant(DAG, 0x3f3c50c8));
       SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
       SDValue t5 = DAG.getNode(ISD::FADD, MVT::f32, t4,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3f7f5e7e)), MVT::f32));
+                               getF32Constant(DAG, 0x3f7f5e7e));
       SDValue TwoToFracPartOfX = DAG.getNode(ISD::BIT_CONVERT, MVT::i32, t5);

       // Add the exponent into the result in integer domain.
@@ -2845,19 +2847,15 @@
       //
       // 0.000107046256 error, which is 13 to 14 bits
       SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, X,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3da235e3)), MVT::f32));
+                               getF32Constant(DAG, 0x3da235e3));
       SDValue t3 = DAG.getNode(ISD::FADD, MVT::f32, t2,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3e65b8f3)), MVT::f32));
+                               getF32Constant(DAG, 0x3e65b8f3));
       SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
       SDValue t5 = DAG.getNode(ISD::FADD, MVT::f32, t4,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3f324b07)), MVT::f32));
+                               getF32Constant(DAG, 0x3f324b07));
       SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, t5, X);
       SDValue t7 = DAG.getNode(ISD::FADD, MVT::f32, t6,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3f7ff8fd)), MVT::f32));
+                               getF32Constant(DAG, 0x3f7ff8fd));
       SDValue TwoToFracPartOfX = DAG.getNode(ISD::BIT_CONVERT, MVT::i32, t7);

       // Add the exponent into the result in integer domain.
@@ -2878,31 +2876,24 @@
       //
       // error 2.47208000*10^(-7), which is better than 18 bits
       SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, X,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3924b03e)), MVT::f32));
+                               getF32Constant(DAG, 0x3924b03e));
       SDValue t3 = DAG.getNode(ISD::FADD, MVT::f32, t2,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3ab24b87)), MVT::f32));
+                               getF32Constant(DAG, 0x3ab24b87));
       SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
       SDValue t5 = DAG.getNode(ISD::FADD, MVT::f32, t4,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3c1d8c17)), MVT::f32));
+                               getF32Constant(DAG, 0x3c1d8c17));
       SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, t5, X);
       SDValue t7 = DAG.getNode(ISD::FADD, MVT::f32, t6,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3d634a1d)), MVT::f32));
+                               getF32Constant(DAG, 0x3d634a1d));
       SDValue t8 = DAG.getNode(ISD::FMUL, MVT::f32, t7, X);
       SDValue t9 = DAG.getNode(ISD::FADD, MVT::f32, t8,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3e75fe14)), MVT::f32));
+                               getF32Constant(DAG, 0x3e75fe14));
       SDValue t10 = DAG.getNode(ISD::FMUL, MVT::f32, t9, X);
       SDValue t11 = DAG.getNode(ISD::FADD, MVT::f32, t10,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3f317234)), MVT::f32));
+                                getF32Constant(DAG, 0x3f317234));
       SDValue t12 = DAG.getNode(ISD::FMUL, MVT::f32, t11, X);
       SDValue t13 = DAG.getNode(ISD::FADD, MVT::f32, t12,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3f800000)), MVT::f32));
+                                getF32Constant(DAG, 0x3f800000));
       SDValue TwoToFracPartOfX = DAG.getNode(ISD::BIT_CONVERT, MVT::i32, t13);

       // Add the exponent into the result in integer domain.
@@ -2935,8 +2926,7 @@
     // Scale the exponent by log(2) [0.69314718f].
     SDValue Exp = GetExponent(DAG, Op1);
     SDValue LogOfExponent = DAG.getNode(ISD::FMUL, MVT::f32, Exp,
-                              DAG.getConstantFP(APFloat(
-                                APInt(32, 0x3f317218)), MVT::f32));
+                                        getF32Constant(DAG, 0x3f317218));

     // Get the significand and build it into a floating-point number with
     // exponent of 1.
@@ -2951,15 +2941,12 @@
       //
       // error 0.0034276066, which is better than 8 bits
       SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, X,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0xbe74c456)), MVT::f32));
+                               getF32Constant(DAG, 0xbe74c456));
       SDValue t1 = DAG.getNode(ISD::FADD, MVT::f32, t0,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3fb3a2b1)), MVT::f32));
+                               getF32Constant(DAG, 0x3fb3a2b1));
       SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, t1, X);
       SDValue LogOfMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t2,
-                                  DAG.getConstantFP(APFloat(
-                                    APInt(32, 0x3f949a29)), MVT::f32));
+                                          getF32Constant(DAG, 0x3f949a29));

       result = DAG.getNode(ISD::FADD, MVT::f32, LogOfExponent, LogOfMantissa);
     } else if (LimitFloatPrecision > 6 && LimitFloatPrecision <= 12) {
@@ -2973,23 +2960,18 @@
       //
       // error 0.000061011436, which is 14 bits
       SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, X,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0xbd67b6d6)), MVT::f32));
+                               getF32Constant(DAG, 0xbd67b6d6));
       SDValue t1 = DAG.getNode(ISD::FADD, MVT::f32, t0,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3ee4f4b8)), MVT::f32));
+                               getF32Constant(DAG, 0x3ee4f4b8));
       SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, t1, X);
       SDValue t3 = DAG.getNode(ISD::FSUB, MVT::f32, t2,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3fbc278b)), MVT::f32));
+                               getF32Constant(DAG, 0x3fbc278b));
       SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
       SDValue t5 = DAG.getNode(ISD::FADD, MVT::f32, t4,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x40348e95)), MVT::f32));
+                               getF32Constant(DAG, 0x40348e95));
       SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, t5, X);
       SDValue LogOfMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t6,
-                                DAG.getConstantFP(APFloat(
-                                  APInt(32, 0x3fdef31a)), MVT::f32));
+                                          getF32Constant(DAG, 0x3fdef31a));

       result = DAG.getNode(ISD::FADD, MVT::f32, LogOfExponent, LogOfMantissa);
     } else { // LimitFloatPrecision > 12 && LimitFloatPrecision <= 18
@@ -3005,31 +2987,24 @@
       //
       // error 0.0000023660568, which is better than 18 bits
       SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, X,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0xbc91e5ac)), MVT::f32));
+                               getF32Constant(DAG, 0xbc91e5ac));
       SDValue t1 = DAG.getNode(ISD::FADD, MVT::f32, t0,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3e4350aa)), MVT::f32));
+                               getF32Constant(DAG, 0x3e4350aa));
       SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, t1, X);
       SDValue t3 = DAG.getNode(ISD::FSUB, MVT::f32, t2,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3f60d3e3)), MVT::f32));
+                               getF32Constant(DAG, 0x3f60d3e3));
       SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
       SDValue t5 = DAG.getNode(ISD::FADD, MVT::f32, t4,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x4011cdf0)), MVT::f32));
+                               getF32Constant(DAG, 0x4011cdf0));
       SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, t5, X);
       SDValue t7 = DAG.getNode(ISD::FSUB, MVT::f32, t6,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x406cfd1c)), MVT::f32));
+                               getF32Constant(DAG, 0x406cfd1c));
       SDValue t8 = DAG.getNode(ISD::FMUL, MVT::f32, t7, X);
       SDValue t9 = DAG.getNode(ISD::FADD, MVT::f32, t8,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x408797cb)), MVT::f32));
+                               getF32Constant(DAG, 0x408797cb));
       SDValue t10 = DAG.getNode(ISD::FMUL, MVT::f32, t9, X);
       SDValue LogOfMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t10,
-                                DAG.getConstantFP(APFloat(
-                                  APInt(32, 0x4006dcab)), MVT::f32));
+                                          getF32Constant(DAG, 0x4006dcab));

       result = DAG.getNode(ISD::FADD, MVT::f32, LogOfExponent, LogOfMantissa);
     }
@@ -3070,15 +3045,12 @@
       //
       // error 0.0049451742, which is more than 7 bits
       SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, X,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0xbeb08fe0)), MVT::f32));
+                               getF32Constant(DAG, 0xbeb08fe0));
       SDValue t1 = DAG.getNode(ISD::FADD, MVT::f32, t0,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x40019463)), MVT::f32));
+                               getF32Constant(DAG, 0x40019463));
       SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, t1, X);
       SDValue Log2ofMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t2,
-                                  DAG.getConstantFP(APFloat(
-                                    APInt(32, 0x3fd6633d)), MVT::f32));
+                                           getF32Constant(DAG, 0x3fd6633d));

       result = DAG.getNode(ISD::FADD, MVT::f32, LogOfExponent, Log2ofMantissa);
     } else if (LimitFloatPrecision > 6 && LimitFloatPrecision <= 12) {
@@ -3092,23 +3064,18 @@
       //
       // error 0.0000876136000, which is better than 13 bits
       SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, X,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0xbda7262e)), MVT::f32));
+                               getF32Constant(DAG, 0xbda7262e));
       SDValue t1 = DAG.getNode(ISD::FADD, MVT::f32, t0,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3f25280b)), MVT::f32));
+                               getF32Constant(DAG, 0x3f25280b));
       SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, t1, X);
       SDValue t3 = DAG.getNode(ISD::FSUB, MVT::f32, t2,
-                                DAG.getConstantFP(APFloat(
-                                  APInt(32, 0x4007b923)), MVT::f32));
+                               getF32Constant(DAG, 0x4007b923));
       SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
       SDValue t5 = DAG.getNode(ISD::FADD, MVT::f32, t4,
-                                DAG.getConstantFP(APFloat(
-                                  APInt(32, 0x40823e2f)), MVT::f32));
+                               getF32Constant(DAG, 0x40823e2f));
       SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, t5, X);
       SDValue Log2ofMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t6,
-                                 DAG.getConstantFP(APFloat(
-                                   APInt(32, 0x4020d29c)), MVT::f32));
+                                           getF32Constant(DAG, 0x4020d29c));

       result = DAG.getNode(ISD::FADD, MVT::f32, LogOfExponent, Log2ofMantissa);
     } else { // LimitFloatPrecision > 12 && LimitFloatPrecision <= 18
@@ -3125,31 +3092,24 @@
       //
       // error 0.0000018516, which is better than 18 bits
       SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, X,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0xbcd2769e)), MVT::f32));
+                               getF32Constant(DAG, 0xbcd2769e));
       SDValue t1 = DAG.getNode(ISD::FADD, MVT::f32, t0,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3e8ce0b9)), MVT::f32));
+                               getF32Constant(DAG, 0x3e8ce0b9));
       SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, t1, X);
       SDValue t3 = DAG.getNode(ISD::FSUB, MVT::f32, t2,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3fa22ae7)), MVT::f32));
+                               getF32Constant(DAG, 0x3fa22ae7));
       SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
       SDValue t5 = DAG.getNode(ISD::FADD, MVT::f32, t4,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x40525723)), MVT::f32));
+                               getF32Constant(DAG, 0x40525723));
       SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, t5, X);
       SDValue t7 = DAG.getNode(ISD::FSUB, MVT::f32, t6,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x40aaf200)), MVT::f32));
+                               getF32Constant(DAG, 0x40aaf200));
       SDValue t8 = DAG.getNode(ISD::FMUL, MVT::f32, t7, X);
       SDValue t9 = DAG.getNode(ISD::FADD, MVT::f32, t8,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x40c39dad)), MVT::f32));
+                               getF32Constant(DAG, 0x40c39dad));
       SDValue t10 = DAG.getNode(ISD::FMUL, MVT::f32, t9, X);
       SDValue Log2ofMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t10,
-                                 DAG.getConstantFP(APFloat(
-                                   APInt(32, 0x4042902c)), MVT::f32));
+                                           getF32Constant(DAG, 0x4042902c));

       result = DAG.getNode(ISD::FADD, MVT::f32, LogOfExponent, Log2ofMantissa);
     }
@@ -3176,8 +3136,7 @@
     // Scale the exponent by log10(2) [0.30102999f].
     SDValue Exp = GetExponent(DAG, Op1);
     SDValue LogOfExponent = DAG.getNode(ISD::FMUL, MVT::f32, Exp,
-                             DAG.getConstantFP(APFloat(
-                               APInt(32, 0x3e9a209a)), MVT::f32));
+                                        getF32Constant(DAG, 0x3e9a209a));

     // Get the significand and build it into a floating-point number with
     // exponent of 1.
@@ -3192,15 +3151,12 @@
       //
       // error 0.0014886165, which is 6 bits
       SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, X,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0xbdd49a13)), MVT::f32));
+                               getF32Constant(DAG, 0xbdd49a13));
       SDValue t1 = DAG.getNode(ISD::FADD, MVT::f32, t0,
-                                DAG.getConstantFP(APFloat(
-                                  APInt(32, 0x3f1c0789)), MVT::f32));
+                               getF32Constant(DAG, 0x3f1c0789));
       SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, t1, X);
       SDValue Log10ofMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t2,
-                                  DAG.getConstantFP(APFloat(
-                                    APInt(32, 0x3f011300)), MVT::f32));
+                                            getF32Constant(DAG, 0x3f011300));

       result = DAG.getNode(ISD::FADD, MVT::f32, LogOfExponent, Log10ofMantissa);
     } else if (LimitFloatPrecision > 6 && LimitFloatPrecision <= 12) {
@@ -3213,19 +3169,15 @@
       //
       // error 0.00019228036, which is better than 12 bits
       SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, X,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3d431f31)), MVT::f32));
+                               getF32Constant(DAG, 0x3d431f31));
       SDValue t1 = DAG.getNode(ISD::FSUB, MVT::f32, t0,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3ea21fb2)), MVT::f32));
+                               getF32Constant(DAG, 0x3ea21fb2));
       SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, t1, X);
       SDValue t3 = DAG.getNode(ISD::FADD, MVT::f32, t2,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3f6ae232)), MVT::f32));
+                               getF32Constant(DAG, 0x3f6ae232));
       SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
       SDValue Log10ofMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t4,
-                                  DAG.getConstantFP(APFloat(
-                                    APInt(32, 0x3f25f7c3)), MVT::f32));
+                                            getF32Constant(DAG, 0x3f25f7c3));

       result = DAG.getNode(ISD::FADD, MVT::f32, LogOfExponent, Log10ofMantissa);
     } else { // LimitFloatPrecision > 12 && LimitFloatPrecision <= 18
@@ -3240,27 +3192,21 @@
       //
       // error 0.0000037995730, which is better than 18 bits
       SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, X,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3c5d51ce)), MVT::f32));
+                               getF32Constant(DAG, 0x3c5d51ce));
       SDValue t1 = DAG.getNode(ISD::FSUB, MVT::f32, t0,
-                                DAG.getConstantFP(APFloat(
-                                  APInt(32, 0x3e00685a)), MVT::f32));
+                               getF32Constant(DAG, 0x3e00685a));
       SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, t1, X);
       SDValue t3 = DAG.getNode(ISD::FADD, MVT::f32, t2,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3efb6798)), MVT::f32));
+                               getF32Constant(DAG, 0x3efb6798));
       SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
       SDValue t5 = DAG.getNode(ISD::FSUB, MVT::f32, t4,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3f88d192)), MVT::f32));
+                               getF32Constant(DAG, 0x3f88d192));
       SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, t5, X);
       SDValue t7 = DAG.getNode(ISD::FADD, MVT::f32, t6,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3fc4316c)), MVT::f32));
+                               getF32Constant(DAG, 0x3fc4316c));
       SDValue t8 = DAG.getNode(ISD::FMUL, MVT::f32, t7, X);
       SDValue Log10ofMantissa = DAG.getNode(ISD::FSUB, MVT::f32, t8,
-                                  DAG.getConstantFP(APFloat(
-                                    APInt(32, 0x3f57ce70)), MVT::f32));
+                                            getF32Constant(DAG, 0x3f57ce70));

       result = DAG.getNode(ISD::FADD, MVT::f32, LogOfExponent, Log10ofMantissa);
     }
@@ -3303,15 +3249,12 @@
       //
       // error 0.0144103317, which is 6 bits
       SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, X,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3e814304)), MVT::f32));
+                               getF32Constant(DAG, 0x3e814304));
       SDValue t3 = DAG.getNode(ISD::FADD, MVT::f32, t2,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3f3c50c8)), MVT::f32));
+                               getF32Constant(DAG, 0x3f3c50c8));
       SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
       SDValue t5 = DAG.getNode(ISD::FADD, MVT::f32, t4,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3f7f5e7e)), MVT::f32));
+                               getF32Constant(DAG, 0x3f7f5e7e));
       SDValue t6 = DAG.getNode(ISD::BIT_CONVERT, MVT::i32, t5);
       SDValue TwoToFractionalPartOfX =
         DAG.getNode(ISD::ADD, MVT::i32, t6, IntegerPartOfX);
@@ -3327,19 +3270,15 @@
       //
       // error 0.000107046256, which is 13 to 14 bits
       SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, X,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3da235e3)), MVT::f32));
+                               getF32Constant(DAG, 0x3da235e3));
       SDValue t3 = DAG.getNode(ISD::FADD, MVT::f32, t2,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3e65b8f3)), MVT::f32));
+                               getF32Constant(DAG, 0x3e65b8f3));
       SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
       SDValue t5 = DAG.getNode(ISD::FADD, MVT::f32, t4,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3f324b07)), MVT::f32));
+                               getF32Constant(DAG, 0x3f324b07));
       SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, t5, X);
       SDValue t7 = DAG.getNode(ISD::FADD, MVT::f32, t6,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3f7ff8fd)), MVT::f32));
+                               getF32Constant(DAG, 0x3f7ff8fd));
       SDValue t8 = DAG.getNode(ISD::BIT_CONVERT, MVT::i32, t7);
       SDValue TwoToFractionalPartOfX =
         DAG.getNode(ISD::ADD, MVT::i32, t8, IntegerPartOfX);
@@ -3357,31 +3296,24 @@
       //               (0.136028312e-2f + 0.157059148e-3f *x)*x)*x)*x)*x)*x;
       // error 2.47208000*10^(-7), which is better than 18 bits
       SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, X,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3924b03e)), MVT::f32));
+                               getF32Constant(DAG, 0x3924b03e));
       SDValue t3 = DAG.getNode(ISD::FADD, MVT::f32, t2,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3ab24b87)), MVT::f32));
+                               getF32Constant(DAG, 0x3ab24b87));
       SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
       SDValue t5 = DAG.getNode(ISD::FADD, MVT::f32, t4,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3c1d8c17)), MVT::f32));
+                               getF32Constant(DAG, 0x3c1d8c17));
       SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, t5, X);
       SDValue t7 = DAG.getNode(ISD::FADD, MVT::f32, t6,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3d634a1d)), MVT::f32));
+                               getF32Constant(DAG, 0x3d634a1d));
       SDValue t8 = DAG.getNode(ISD::FMUL, MVT::f32, t7, X);
       SDValue t9 = DAG.getNode(ISD::FADD, MVT::f32, t8,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3e75fe14)), MVT::f32));
+                               getF32Constant(DAG, 0x3e75fe14));
       SDValue t10 = DAG.getNode(ISD::FMUL, MVT::f32, t9, X);
       SDValue t11 = DAG.getNode(ISD::FADD, MVT::f32, t10,
-                                DAG.getConstantFP(APFloat(
-                                  APInt(32, 0x3f317234)), MVT::f32));
+                                getF32Constant(DAG, 0x3f317234));
       SDValue t12 = DAG.getNode(ISD::FMUL, MVT::f32, t11, X);
       SDValue t13 = DAG.getNode(ISD::FADD, MVT::f32, t12,
-                                DAG.getConstantFP(APFloat(
-                                  APInt(32, 0x3f800000)), MVT::f32));
+                                getF32Constant(DAG, 0x3f800000));
       SDValue t14 = DAG.getNode(ISD::BIT_CONVERT, MVT::i32, t13);
       SDValue TwoToFractionalPartOfX =
         DAG.getNode(ISD::ADD, MVT::i32, t14, IntegerPartOfX);
@@ -3426,8 +3358,7 @@
     //   #define LOG2OF10 3.3219281f
     //   IntegerPartOfX = (int32_t)(x * LOG2OF10);
     SDValue t0 = DAG.getNode(ISD::FMUL, MVT::f32, Op,
-                             DAG.getConstantFP(APFloat(
-                               APInt(32, 0x40549a78)), MVT::f32));
+                             getF32Constant(DAG, 0x40549a78));
     SDValue IntegerPartOfX = DAG.getNode(ISD::FP_TO_SINT, MVT::i32, t0);

     //   FractionalPartOfX = x - (float)IntegerPartOfX;
@@ -3447,15 +3378,12 @@
       //
       // error 0.0144103317, which is 6 bits
       SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, X,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3e814304)), MVT::f32));
+                               getF32Constant(DAG, 0x3e814304));
       SDValue t3 = DAG.getNode(ISD::FADD, MVT::f32, t2,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3f3c50c8)), MVT::f32));
+                               getF32Constant(DAG, 0x3f3c50c8));
       SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
       SDValue t5 = DAG.getNode(ISD::FADD, MVT::f32, t4,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3f7f5e7e)), MVT::f32));
+                               getF32Constant(DAG, 0x3f7f5e7e));
       SDValue t6 = DAG.getNode(ISD::BIT_CONVERT, MVT::i32, t5);
       SDValue TwoToFractionalPartOfX =
         DAG.getNode(ISD::ADD, MVT::i32, t6, IntegerPartOfX);
@@ -3471,19 +3399,15 @@
       //
       // error 0.000107046256, which is 13 to 14 bits
       SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, X,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3da235e3)), MVT::f32));
+                               getF32Constant(DAG, 0x3da235e3));
       SDValue t3 = DAG.getNode(ISD::FADD, MVT::f32, t2,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3e65b8f3)), MVT::f32));
+                               getF32Constant(DAG, 0x3e65b8f3));
       SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
       SDValue t5 = DAG.getNode(ISD::FADD, MVT::f32, t4,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3f324b07)), MVT::f32));
+                               getF32Constant(DAG, 0x3f324b07));
       SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, t5, X);
       SDValue t7 = DAG.getNode(ISD::FADD, MVT::f32, t6,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3f7ff8fd)), MVT::f32));
+                               getF32Constant(DAG, 0x3f7ff8fd));
       SDValue t8 = DAG.getNode(ISD::BIT_CONVERT, MVT::i32, t7);
       SDValue TwoToFractionalPartOfX =
         DAG.getNode(ISD::ADD, MVT::i32, t8, IntegerPartOfX);
@@ -3501,31 +3425,24 @@
       //               (0.136028312e-2f + 0.157059148e-3f *x)*x)*x)*x)*x)*x;
       // error 2.47208000*10^(-7), which is better than 18 bits
       SDValue t2 = DAG.getNode(ISD::FMUL, MVT::f32, X,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3924b03e)), MVT::f32));
+                               getF32Constant(DAG, 0x3924b03e));
       SDValue t3 = DAG.getNode(ISD::FADD, MVT::f32, t2,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3ab24b87)), MVT::f32));
+                               getF32Constant(DAG, 0x3ab24b87));
       SDValue t4 = DAG.getNode(ISD::FMUL, MVT::f32, t3, X);
       SDValue t5 = DAG.getNode(ISD::FADD, MVT::f32, t4,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3c1d8c17)), MVT::f32));
+                               getF32Constant(DAG, 0x3c1d8c17));
       SDValue t6 = DAG.getNode(ISD::FMUL, MVT::f32, t5, X);
       SDValue t7 = DAG.getNode(ISD::FADD, MVT::f32, t6,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3d634a1d)), MVT::f32));
+                               getF32Constant(DAG, 0x3d634a1d));
       SDValue t8 = DAG.getNode(ISD::FMUL, MVT::f32, t7, X);
       SDValue t9 = DAG.getNode(ISD::FADD, MVT::f32, t8,
-                               DAG.getConstantFP(APFloat(
-                                 APInt(32, 0x3e75fe14)), MVT::f32));
+                               getF32Constant(DAG, 0x3e75fe14));
       SDValue t10 = DAG.getNode(ISD::FMUL, MVT::f32, t9, X);
       SDValue t11 = DAG.getNode(ISD::FADD, MVT::f32, t10,
-                                DAG.getConstantFP(APFloat(
-                                  APInt(32, 0x3f317234)), MVT::f32));
+                                getF32Constant(DAG, 0x3f317234));
       SDValue t12 = DAG.getNode(ISD::FMUL, MVT::f32, t11, X);
       SDValue t13 = DAG.getNode(ISD::FADD, MVT::f32, t12,
-                                DAG.getConstantFP(APFloat(
-                                  APInt(32, 0x3f800000)), MVT::f32));
+                                getF32Constant(DAG, 0x3f800000));
       SDValue t14 = DAG.getNode(ISD::BIT_CONVERT, MVT::i32, t13);
       SDValue TwoToFractionalPartOfX =
         DAG.getNode(ISD::ADD, MVT::i32, t14, IntegerPartOfX);


handle empty id value in dispatcher callbacks

--- src/api/dispatcher.cc
+++ src/api/dispatcher.cc
@@ -145,6 +145,8 @@

   v8::Handle<v8::Value> val = GetWindowId(web_view->mainFrame());

+  if (id_val.IsEmpty())
+    return;
   if (val->IsNull() || val->IsUndefined())
     return;

@@ -177,6 +179,8 @@
   v8::Context::Scope cscope (web_view->mainFrame()->mainWorldScriptContext());

   v8::Handle<v8::Value> val = GetWindowId(web_view->mainFrame());
+  if (id_val.IsEmpty())
+    return;
   if (val->IsNull() || val->IsUndefined())
     return;

@@ -212,7 +216,9 @@
   v8::Isolate* isolate = v8::Isolate::GetCurrent();

   v8::Handle<v8::Value> id_val = nwapi::Dispatcher::GetWindowId(web_view->mainFrame());
-  if (id_val->IsNull() || id_val->IsUndefined())
+  if (id_val.IsEmpty())
+    return;
+  if (id_val->IsUndefined() || id_val->IsNull())
     return;

   v8::Handle<v8::Object> objects_registry = nwapi::Dispatcher::GetObjectRegistry();


test: firmware updateStarted: getBlobIds()

Signed-off-by: Patrick Venture <36c53fa43f47f3fd67cb2fc38031827244d18a1f@google.com>
Change-Id: I4f712e28d0bcbfcc1515ee704d3bd3e64b9d03b4

--- test/firmware_state_updatestarted_unittest.cpp
+++ test/firmware_state_updatestarted_unittest.cpp
@@ -19,6 +19,7 @@
 {

 using ::testing::Return;
+using ::testing::UnorderedElementsAreArray;

 /*
  * There are the following calls (parameters may vary):
@@ -57,6 +58,14 @@
 /* canHandleBlob(blob)
  * getBlobIds
  */
+TEST_F(FirmwareHandlerUpdateStartedTest, VerifyListOfBlobs)
+{
+    getToUpdateStarted();
+
+    std::vector<std::string> expected = {updateBlobId, hashBlobId,
+                                         activeImageBlobId, staticLayoutBlobId};
+    EXPECT_THAT(handler->getBlobIds(), UnorderedElementsAreArray(expected));
+}

 /*
  * TODO: deleteBlob(blob)


[AddressLowering] Rewrite partial_apply uses.

Use the CallArgRewriter to rewrite uses by partial_apply insts just as
uses by apply insts, etc., are rewritten.

--- lib/SILOptimizer/Mandatory/AddressLowering.cpp
+++ lib/SILOptimizer/Mandatory/AddressLowering.cpp
@@ -2599,6 +2599,10 @@
     CallArgRewriter(applyInst, pass).rewriteIndirectArgument(use);
   }

+  void visitPartialApplyInst(PartialApplyInst *pai) {
+    CallArgRewriter(pai, pass).rewriteIndirectArgument(use);
+  }
+
   void visitBeginApplyInst(BeginApplyInst *bai) {
     CallArgRewriter(bai, pass).rewriteIndirectArgument(use);
   }


Fix typo: contant → constant

Fix typo: contant → constant

--- lib/SILOptimizer/Transforms/StackPromotion.cpp
+++ lib/SILOptimizer/Transforms/StackPromotion.cpp
@@ -37,7 +37,7 @@
 ///    size and alignment for the final stack promotion decision. The arguments
 ///    to swift_bufferAllocate in SIL are not constant because they depend on
 ///    the not-yet-evaluatable sizeof and alignof builtins. Therefore we need
-///    LLVM's contant propagation prior to deciding on stack promotion.
+///    LLVM's constant propagation prior to deciding on stack promotion.
 ///    The solution to this problem is that we need native support for tail-
 ///    allocated arrays in SIL so that we can do the array buffer allocations
 ///    with alloc_ref instructions.


Convert instcombine from using using getAnalysis<TargetData> to
getAnalysisIfAvailable<TargetData>.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@76676 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Transforms/Scalar/InstructionCombining.cpp
+++ lib/Transforms/Scalar/InstructionCombining.cpp
@@ -157,12 +157,11 @@
     bool DoOneIteration(Function &F, unsigned ItNum);

     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
-      AU.addRequired<TargetData>();
       AU.addPreservedID(LCSSAID);
       AU.setPreservesCFG();
     }

-    TargetData &getTargetData() const { return *TD; }
+    TargetData *getTargetData() const { return TD; }

     // Visitation implementation - Implement instruction combining for different
     // instruction types.  The semantics are as follows:
@@ -460,7 +459,7 @@
   const Type *DstTy,     ///< The target type for the second cast instruction
   TargetData *TD         ///< The target data for pointer size
 ) {
-
+
   const Type *SrcTy = CI->getOperand(0)->getType();   // A from above
   const Type *MidTy = CI->getType();                  // B from above

@@ -469,7 +468,8 @@
   Instruction::CastOps secondOp = Instruction::CastOps(opcode);

   unsigned Res = CastInst::isEliminableCastPair(firstOp, secondOp, SrcTy, MidTy,
-                                                DstTy, TD->getIntPtrType());
+                                                DstTy,
+                                                TD ? TD->getIntPtrType() : 0);

   // We don't want to form an inttoptr or ptrtoint that converts to an integer
   // type that differs from the pointer size.
@@ -489,7 +489,7 @@

   // If this is another cast that can be eliminated, it isn't codegen either.
   if (const CastInst *CI = dyn_cast<CastInst>(V))
-    if (isEliminableCastPair(CI, opcode, Ty, TD))
+    if (isEliminableCastPair(CI, opcode, Ty, TD))
       return false;
   return true;
 }
@@ -5350,7 +5350,7 @@
 /// code necessary to compute the offset from the base pointer (without adding
 /// in the base pointer).  Return the result as a signed integer of intptr size.
 static Value *EmitGEPOffset(User *GEP, Instruction &I, InstCombiner &IC) {
-  TargetData &TD = IC.getTargetData();
+  TargetData &TD = *IC.getTargetData();
   gep_type_iterator GTI = gep_type_begin(GEP);
   const Type *IntPtrTy = TD.getIntPtrType();
   LLVMContext *Context = IC.getContext();
@@ -5438,7 +5438,7 @@
 ///
 static Value *EvaluateGEPOffsetExpression(User *GEP, Instruction &I,
                                           InstCombiner &IC) {
-  TargetData &TD = IC.getTargetData();
+  TargetData &TD = *IC.getTargetData();
   gep_type_iterator GTI = gep_type_begin(GEP);

   // Check to see if this gep only has a single variable index.  If so, and if
@@ -5544,7 +5544,7 @@
     RHS = BCI->getOperand(0);

   Value *PtrBase = GEPLHS->getOperand(0);
-  if (PtrBase == RHS) {
+  if (TD && PtrBase == RHS) {
     // ((gep Ptr, OFFSET) cmp Ptr)   ---> (OFFSET cmp 0).
     // This transformation (ignoring the base and scales) is valid because we
     // know pointers can't overflow.  See if we can output an optimized form.
@@ -5635,7 +5635,8 @@

     // Only lower this if the icmp is the only user of the GEP or if we expect
     // the result to fold to a constant!
-    if ((isa<ConstantExpr>(GEPLHS) || GEPLHS->hasOneUse()) &&
+    if (TD &&
+        (isa<ConstantExpr>(GEPLHS) || GEPLHS->hasOneUse()) &&
         (isa<ConstantExpr>(GEPRHS) || GEPRHS->hasOneUse())) {
       // ((gep Ptr, OFFSET1) cmp (gep Ptr, OFFSET2)  --->  (OFFSET1 cmp OFFSET2)
       Value *L = EmitGEPOffset(GEPLHS, I, *this);
@@ -7168,8 +7169,8 @@

   // Turn icmp (ptrtoint x), (ptrtoint/c) into a compare of the input if the
   // integer type is the same size as the pointer type.
-  if (LHSCI->getOpcode() == Instruction::PtrToInt &&
-      getTargetData().getPointerSizeInBits() ==
+  if (TD && LHSCI->getOpcode() == Instruction::PtrToInt &&
+      TD->getPointerSizeInBits() ==
          cast<IntegerType>(DestTy)->getBitWidth()) {
     Value *RHSOp = 0;
     if (Constant *RHSC = dyn_cast<Constant>(ICI.getOperand(1))) {
@@ -7792,7 +7793,10 @@
       EraseInstFromFunction(*User);
     }
   }
-
+
+  // This requires TargetData to get the alloca alignment and size information.
+  if (!TD) return 0;
+
   // Get the type really allocated and the type casted to.
   const Type *AllocElTy = AI.getAllocatedType();
   const Type *CastElTy = PTy->getElementType();
@@ -8124,6 +8128,7 @@
                                        SmallVectorImpl<Value*> &NewIndices,
                                        const TargetData *TD,
                                        LLVMContext *Context) {
+  if (!TD) return 0;
   if (!Ty->isSized()) return 0;

   // Start with the index over the outer type.  Note that the type size
@@ -8197,7 +8202,7 @@
     // GEP computes a constant offset, see if we can convert these three
     // instructions into fewer.  This typically happens with unions and other
     // non-type-safe code.
-    if (GEP->hasOneUse() && isa<BitCastInst>(GEP->getOperand(0))) {
+    if (TD && GEP->hasOneUse() && isa<BitCastInst>(GEP->getOperand(0))) {
       if (GEP->hasAllConstantIndices()) {
         // We are guaranteed to get a constant from EmitGEPOffset.
         ConstantInt *OffsetV =
@@ -8863,7 +8868,8 @@
   // trunc to be exposed to other transforms.  Don't do this for extending
   // ptrtoint's, because we don't know if the target sign or zero extends its
   // pointers.
-  if (CI.getType()->getScalarSizeInBits() < TD->getPointerSizeInBits()) {
+  if (TD &&
+      CI.getType()->getScalarSizeInBits() < TD->getPointerSizeInBits()) {
     Value *P = InsertNewInstBefore(new PtrToIntInst(CI.getOperand(0),
                                                     TD->getIntPtrType(),
                                                     "tmp"), CI);
@@ -8879,7 +8885,8 @@
   // allows the trunc to be exposed to other transforms.  Don't do this for
   // extending inttoptr's, because we don't know if the target sign or zero
   // extends to pointers.
-  if (CI.getOperand(0)->getType()->getScalarSizeInBits() >
+  if (TD &&
+      CI.getOperand(0)->getType()->getScalarSizeInBits() >
       TD->getPointerSizeInBits()) {
     Value *P = InsertNewInstBefore(new TruncInst(CI.getOperand(0),
                                                  TD->getIntPtrType(),
@@ -9667,7 +9674,7 @@
   // integer datatype.
   if (Value *Op = getBitCastOperand(MI->getOperand(1))) {
     const Type *SrcETy = cast<PointerType>(Op->getType())->getElementType();
-    if (SrcETy->isSized() && TD->getTypeStoreSize(SrcETy) == Size) {
+    if (TD && SrcETy->isSized() && TD->getTypeStoreSize(SrcETy) == Size) {
       // The SrcETy might be something like {{{double}}} or [1 x double].  Rip
       // down through these levels if so.
       while (!SrcETy->isSingleValueType()) {
@@ -10000,7 +10007,7 @@
   const Type* DstTy = cast<PointerType>(CI->getType())->getElementType();
   if (!SrcTy->isSized() || !DstTy->isSized())
     return false;
-  if (TD->getTypeAllocSize(SrcTy) != TD->getTypeAllocSize(DstTy))
+  if (!TD || TD->getTypeAllocSize(SrcTy) != TD->getTypeAllocSize(DstTy))
     return false;
   return true;
 }
@@ -10110,8 +10117,10 @@
     if (Callee->isDeclaration() &&
         // Conversion is ok if changing from one pointer type to another or from
         // a pointer to an integer of the same size.
-        !((isa<PointerType>(OldRetTy) || OldRetTy == TD->getIntPtrType()) &&
-          (isa<PointerType>(NewRetTy) || NewRetTy == TD->getIntPtrType())))
+        !((isa<PointerType>(OldRetTy) || !TD ||
+           OldRetTy == TD->getIntPtrType()) &&
+          (isa<PointerType>(NewRetTy) || !TD ||
+           NewRetTy == TD->getIntPtrType())))
       return false;   // Cannot transform this return value.

     if (!Caller->use_empty() &&
@@ -10157,8 +10166,8 @@
     // Converting from one pointer type to another or between a pointer and an
     // integer of the same size is safe even if we do not have a body.
     bool isConvertible = ActTy == ParamTy ||
-      ((isa<PointerType>(ParamTy) || ParamTy == TD->getIntPtrType()) &&
-       (isa<PointerType>(ActTy) || ActTy == TD->getIntPtrType()));
+      (TD && ((isa<PointerType>(ParamTy) || ParamTy == TD->getIntPtrType()) &&
+              (isa<PointerType>(ActTy) || ActTy == TD->getIntPtrType())));
     if (Callee->isDeclaration() && !isConvertible) return false;
   }

@@ -10965,7 +10974,7 @@
   gep_type_iterator GTI = gep_type_begin(GEP);
   for (User::op_iterator i = GEP.op_begin() + 1, e = GEP.op_end();
        i != e; ++i, ++GTI) {
-    if (isa<SequentialType>(*GTI)) {
+    if (TD && isa<SequentialType>(*GTI)) {
       if (CastInst *CI = dyn_cast<CastInst>(*i)) {
         if (CI->getOpcode() == Instruction::ZExt ||
             CI->getOpcode() == Instruction::SExt) {
@@ -11054,7 +11063,7 @@
           } else if (Constant *GO1C = dyn_cast<Constant>(GO1)) {
             GO1 =
                 Context->getConstantExprIntegerCast(GO1C, SO1->getType(), true);
-          } else {
+          } else if (TD) {
             unsigned PS = TD->getPointerSizeInBits();
             if (TD->getTypeSizeInBits(SO1->getType()) == PS) {
               // Convert GO1 to SO1's type.
@@ -11161,7 +11170,7 @@
       // into:  %t1 = getelementptr [2 x i32]* %str, i32 0, i32 %V; bitcast
       const Type *SrcElTy = cast<PointerType>(X->getType())->getElementType();
       const Type *ResElTy=cast<PointerType>(PtrOp->getType())->getElementType();
-      if (isa<ArrayType>(SrcElTy) &&
+      if (TD && isa<ArrayType>(SrcElTy) &&
           TD->getTypeAllocSize(cast<ArrayType>(SrcElTy)->getElementType()) ==
           TD->getTypeAllocSize(ResElTy)) {
         Value *Idx[2];
@@ -11178,7 +11187,7 @@
       //   (where tmp = 8*tmp2) into:
       // getelementptr [100 x double]* %arr, i32 0, i32 %tmp2; bitcast

-      if (isa<ArrayType>(SrcElTy) && ResElTy == Type::Int8Ty) {
+      if (TD && isa<ArrayType>(SrcElTy) && ResElTy == Type::Int8Ty) {
         uint64_t ArrayEltSize =
             TD->getTypeAllocSize(cast<ArrayType>(SrcElTy)->getElementType());

@@ -11244,7 +11253,8 @@
   /// into a gep of the original struct.  This is important for SROA and alias
   /// analysis of unions.  If "A" is also a bitcast, wait for A/X to be merged.
   if (BitCastInst *BCI = dyn_cast<BitCastInst>(PtrOp)) {
-    if (!isa<BitCastInst>(BCI->getOperand(0)) && GEP.hasAllConstantIndices()) {
+    if (TD &&
+        !isa<BitCastInst>(BCI->getOperand(0)) && GEP.hasAllConstantIndices()) {
       // Determine how much the GEP moves the pointer.  We are guaranteed to get
       // a constant back from EmitGEPOffset.
       ConstantInt *OffsetV =
@@ -11333,7 +11343,7 @@
     }
   }

-  if (isa<AllocaInst>(AI) && AI.getAllocatedType()->isSized()) {
+  if (TD && isa<AllocaInst>(AI) && AI.getAllocatedType()->isSized()) {
     // If alloca'ing a zero byte object, replace the alloca with a null pointer.
     // Note that we only do this for alloca's, because malloc should allocate
     // and return a unique pointer, even for a zero byte allocation.
@@ -11456,13 +11466,14 @@
             SrcPTy = SrcTy->getElementType();
           }

-      if ((SrcPTy->isInteger() || isa<PointerType>(SrcPTy) ||
+      if (IC.getTargetData() &&
+          (SrcPTy->isInteger() || isa<PointerType>(SrcPTy) ||
             isa<VectorType>(SrcPTy)) &&
           // Do not allow turning this into a load of an integer, which is then
           // casted to a pointer, this pessimizes pointer analysis a lot.
           (isa<PointerType>(SrcPTy) == isa<PointerType>(LI.getType())) &&
-          IC.getTargetData().getTypeSizeInBits(SrcPTy) ==
-               IC.getTargetData().getTypeSizeInBits(DestPTy)) {
+          IC.getTargetData()->getTypeSizeInBits(SrcPTy) ==
+               IC.getTargetData()->getTypeSizeInBits(DestPTy)) {

         // Okay, we are casting from one integer or pointer type to another of
         // the same size.  Instead of casting the pointer before the load, cast
@@ -11482,12 +11493,14 @@
   Value *Op = LI.getOperand(0);

   // Attempt to improve the alignment.
-  unsigned KnownAlign =
-    GetOrEnforceKnownAlignment(Op, TD->getPrefTypeAlignment(LI.getType()));
-  if (KnownAlign >
-      (LI.getAlignment() == 0 ? TD->getABITypeAlignment(LI.getType()) :
-                                LI.getAlignment()))
-    LI.setAlignment(KnownAlign);
+  if (TD) {
+    unsigned KnownAlign =
+      GetOrEnforceKnownAlignment(Op, TD->getPrefTypeAlignment(LI.getType()));
+    if (KnownAlign >
+        (LI.getAlignment() == 0 ? TD->getABITypeAlignment(LI.getType()) :
+                                  LI.getAlignment()))
+      LI.setAlignment(KnownAlign);
+  }

   // load (cast X) --> cast (load X) iff safe
   if (isa<CastInst>(Op))
@@ -11667,10 +11680,11 @@

   // If the pointers point into different address spaces or if they point to
   // values with different sizes, we can't do the transformation.
-  if (SrcTy->getAddressSpace() !=
+  if (!IC.getTargetData() ||
+      SrcTy->getAddressSpace() !=
         cast<PointerType>(CI->getType())->getAddressSpace() ||
-      IC.getTargetData().getTypeSizeInBits(SrcPTy) !=
-      IC.getTargetData().getTypeSizeInBits(DestPTy))
+      IC.getTargetData()->getTypeSizeInBits(SrcPTy) !=
+      IC.getTargetData()->getTypeSizeInBits(DestPTy))
     return 0;

   // Okay, we are casting from one integer or pointer type to another of
@@ -11800,12 +11814,14 @@
   }

   // Attempt to improve the alignment.
-  unsigned KnownAlign =
-    GetOrEnforceKnownAlignment(Ptr, TD->getPrefTypeAlignment(Val->getType()));
-  if (KnownAlign >
-      (SI.getAlignment() == 0 ? TD->getABITypeAlignment(Val->getType()) :
-                                SI.getAlignment()))
-    SI.setAlignment(KnownAlign);
+  if (TD) {
+    unsigned KnownAlign =
+      GetOrEnforceKnownAlignment(Ptr, TD->getPrefTypeAlignment(Val->getType()));
+    if (KnownAlign >
+        (SI.getAlignment() == 0 ? TD->getABITypeAlignment(Val->getType()) :
+                                  SI.getAlignment()))
+      SI.setAlignment(KnownAlign);
+  }

   // Do really simple DSE, to catch cases where there are several consecutive
   // stores to the same location, separated by a few arithmetic operations. This
@@ -12884,7 +12900,7 @@

 bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) {
   bool Changed = false;
-  TD = &getAnalysis<TargetData>();
+  TD = getAnalysisIfAvailable<TargetData>();

   DEBUG(DOUT << "\n\nINSTCOMBINE ITERATION #" << Iteration << " on "
              << F.getNameStr() << "\n");


Don't lose the URL just because it is an error. (properties should be orthogonal)

--- src/declarative/graphicsitems/qmlgraphicswebview.cpp
+++ src/declarative/graphicsitems/qmlgraphicswebview.cpp
@@ -362,7 +362,7 @@
     expandToWebPage();

     if ((d->url.isEmpty() && page()->mainFrame()->url() != QUrl(QLatin1String("about:blank")))
-        || d->url != page()->mainFrame()->url())
+        || d->url != page()->mainFrame()->url() && !page()->mainFrame()->url().isEmpty())
     {
         d->url = page()->mainFrame()->url();
         if (d->url == QUrl(QLatin1String("about:blank")))


It is illegal for PHI nodes to have zero values, delete the code to handle them

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@4071 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Transforms/Scalar/InstructionCombining.cpp
+++ lib/Transforms/Scalar/InstructionCombining.cpp
@@ -630,8 +630,6 @@
 //
 Instruction *InstCombiner::visitPHINode(PHINode &PN) {
   // If the PHI node only has one incoming value, eliminate the PHI node...
-  if (PN.getNumIncomingValues() == 0)
-    return ReplaceInstUsesWith(PN, Constant::getNullValue(PN.getType()));
   if (PN.getNumIncomingValues() == 1)
     return ReplaceInstUsesWith(PN, PN.getIncomingValue(0));


Added code that checks to see if a global variable is external before replacing
a load of the global variable with the variable's constant value.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@7216 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Transforms/Scalar/InstructionCombining.cpp
+++ lib/Transforms/Scalar/InstructionCombining.cpp
@@ -1294,7 +1294,7 @@

   // Instcombine load (constant global) into the value loaded...
   if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Op))
-    if (GV->isConstant())
+    if ((GV->isConstant()) && (!(GV->isExternal())))
       return ReplaceInstUsesWith(LI, GV->getInitializer());

   // Instcombine load (constantexpr_GEP global, 0, ...) into the value loaded...


Fix bug: ScalarRepl/2003-05-29-ArrayFail.ll

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@6425 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -23,6 +23,10 @@
     bool runOnFunction(Function &F);

   private:
+    bool isSafeArrayElementUse(Value *Ptr);
+    bool isSafeUseOfAllocation(Instruction *User);
+    bool isSafeStructAllocaToPromote(AllocationInst *AI);
+    bool isSafeArrayAllocaToPromote(AllocationInst *AI);
     AllocaInst *AddNewAlloca(Function &F, const Type *Ty, AllocationInst *Base);
   };

@@ -59,48 +63,13 @@
         (!isa<StructType>(AI->getAllocatedType()) &&
          !isa<ArrayType>(AI->getAllocatedType()))) continue;

-    const ArrayType *AT = dyn_cast<ArrayType>(AI->getAllocatedType());
-
-    // Loop over the use list of the alloca.  We can only transform it if there
-    // are only getelementptr instructions (with a zero first index) and free
-    // instructions.
-    //
-    bool CannotTransform = false;
-    for (Value::use_iterator I = AI->use_begin(), E = AI->use_end();
-         I != E; ++I) {
-      Instruction *User = cast<Instruction>(*I);
-      if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(User)) {
-        // The GEP is safe to transform if it is of the form GEP <ptr>, 0, <cst>
-        if (GEPI->getNumOperands() <= 2 ||
-            GEPI->getOperand(1) != Constant::getNullValue(Type::LongTy) ||
-            !isa<Constant>(GEPI->getOperand(2)) ||
-            isa<ConstantExpr>(GEPI->getOperand(2))) {
-          DEBUG(std::cerr << "Cannot transform: " << *AI << "  due to user: "
-                          << User);
-          CannotTransform = true;
-          break;
-        }
-
-        // If this is an array access, check to make sure that index falls
-        // within the array.  If not, something funny is going on, so we won't
-        // do the optimization.
-        if (AT && cast<ConstantSInt>(GEPI->getOperand(2))->getValue() >=
-            AT->getNumElements()) {
-          DEBUG(std::cerr << "Cannot transform: " << *AI << "  due to user: "
-                          << User);
-          CannotTransform = true;
-          break;
-        }
-
-      } else {
-        DEBUG(std::cerr << "Cannot transform: " << *AI << "  due to user: "
-                        << User);
-        CannotTransform = true;
-        break;
-      }
-    }
-
-    if (CannotTransform) continue;
+    // Check that all of the users of the allocation are capable of being
+    // transformed.
+    if (isa<StructType>(AI->getAllocatedType())) {
+      if (!isSafeStructAllocaToPromote(AI))
+        continue;
+    } else if (!isSafeArrayAllocaToPromote(AI))
+      continue;

     DEBUG(std::cerr << "Found inst to xform: " << *AI);
     Changed = true;
@@ -115,6 +84,7 @@
         WorkList.push_back(NA);  // Add to worklist for recursive processing
       }
     } else {
+      const ArrayType *AT = cast<ArrayType>(AI->getAllocatedType());
       ElementAllocas.reserve(AT->getNumElements());
       const Type *ElTy = AT->getElementType();
       for (unsigned i = 0, e = AT->getNumElements(); i != e; ++i) {
@@ -177,3 +147,119 @@

   return Changed;
 }
+
+
+/// isSafeUseOfAllocation - Check to see if this user is an allowed use for an
+/// aggregate allocation.
+///
+bool SROA::isSafeUseOfAllocation(Instruction *User) {
+  if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(User)) {
+    // The GEP is safe to transform if it is of the form GEP <ptr>, 0, <cst>
+    if (GEPI->getNumOperands() <= 2 ||
+        GEPI->getOperand(1) != Constant::getNullValue(Type::LongTy) ||
+        !isa<Constant>(GEPI->getOperand(2)) ||
+        isa<ConstantExpr>(GEPI->getOperand(2)))
+      return false;
+  } else {
+    return false;
+  }
+  return true;
+}
+
+
+/// isSafeArrayElementUse - Check to see if this use is an allowed use for a
+/// getelementptr instruction of an array aggregate allocation.
+///
+bool SROA::isSafeArrayElementUse(Value *Ptr) {
+  for (Value::use_iterator I = Ptr->use_begin(), E = Ptr->use_end();
+       I != E; ++I) {
+    Instruction *User = cast<Instruction>(*I);
+    switch (User->getOpcode()) {
+    case Instruction::Load:  return true;
+    case Instruction::Store: return User->getOperand(0) != Ptr;
+    case Instruction::GetElementPtr: {
+      GetElementPtrInst *GEP = cast<GetElementPtrInst>(User);
+      if (GEP->getNumOperands() > 1) {
+        if (!isa<Constant>(GEP->getOperand(1)) ||
+            !cast<Constant>(GEP->getOperand(1))->isNullValue())
+          return false;  // Using pointer arithmetic to navigate the array...
+
+        // Check to see if there are any structure indexes involved in this GEP.
+        // If so, then we can safely break the array up until at least the
+        // structure.
+        for (unsigned i = 2, e = GEP->getNumOperands(); i != e; ++i)
+          if (GEP->getOperand(i)->getType()->isUnsigned())
+            break;
+      }
+      return isSafeArrayElementUse(GEP);
+    }
+    default:
+      DEBUG(std::cerr << "  Transformation preventing inst: " << *User);
+      return false;
+    }
+  }
+  return true;  // All users look ok :)
+}
+
+
+/// isSafeStructAllocaToPromote - Check to see if the specified allocation of a
+/// structure can be broken down into elements.
+///
+bool SROA::isSafeStructAllocaToPromote(AllocationInst *AI) {
+  // Loop over the use list of the alloca.  We can only transform it if all of
+  // the users are safe to transform.
+  //
+  for (Value::use_iterator I = AI->use_begin(), E = AI->use_end();
+       I != E; ++I)
+    if (!isSafeUseOfAllocation(cast<Instruction>(*I))) {
+      DEBUG(std::cerr << "Cannot transform: " << *AI << "  due to user: "
+                      << *I);
+      return false;
+    }
+  return true;
+}
+
+
+/// isSafeArrayAllocaToPromote - Check to see if the specified allocation of a
+/// structure can be broken down into elements.
+///
+bool SROA::isSafeArrayAllocaToPromote(AllocationInst *AI) {
+  const ArrayType *AT = cast<ArrayType>(AI->getAllocatedType());
+  int64_t NumElements = AT->getNumElements();
+
+  // Loop over the use list of the alloca.  We can only transform it if all of
+  // the users are safe to transform.  Array allocas have extra constraints to
+  // meet though.
+  //
+  for (Value::use_iterator I = AI->use_begin(), E = AI->use_end();
+       I != E; ++I) {
+    Instruction *User = cast<Instruction>(*I);
+    if (!isSafeUseOfAllocation(User)) {
+      DEBUG(std::cerr << "Cannot transform: " << *AI << "  due to user: "
+                      << User);
+      return false;
+    }
+
+    // Check to make sure that getelementptr follow the extra rules for arrays:
+    if (GetElementPtrInst *GEPI = dyn_cast<GetElementPtrInst>(User)) {
+      // Check to make sure that index falls within the array.  If not,
+      // something funny is going on, so we won't do the optimization.
+      //
+      if (cast<ConstantSInt>(GEPI->getOperand(2))->getValue() >= NumElements)
+        return false;
+
+      // Check to make sure that the only thing that uses the resultant pointer
+      // is safe for an array access.  For example, code that looks like:
+      //   P = &A[0];  P = P + 1
+      // is legal, and should prevent promotion.
+      //
+      if (!isSafeArrayElementUse(GEPI)) {
+        DEBUG(std::cerr << "Cannot transform: " << *AI
+                        << "  due to uses of user: " << *GEPI);
+        return false;
+      }
+    }
+  }
+  return true;
+}
+


Add type for id of Applications'

Add type for id of Applications'

--- src/extra/Application.hpp
+++ src/extra/Application.hpp
@@ -28,9 +28,13 @@

 class Application : public Shareable<Application>
 {
+public:
+	typedef std::string Type;
+	typedef std::string Id;
+
 protected:
-	std::string _type;
-	std::string _appId;
+	Type _type;
+	Id _appId;
 	bool _isProduction;

 public:
@@ -43,12 +47,12 @@
 	explicit Application(const Setting& setting);
 	~Application() override = default;

-	const std::string& type() const
+	const Type& type() const
 	{
 		return _type;
 	}

-	const std::string& appId() const
+	const Id& appId() const
 	{
 		return _appId;
 	}


[fuseCut] start with more points and augment pixSize to fuse points

As nanoflann is much faster than geogram kdtree, it allows us to iterate
on the kdtree filtering to ensure a good repartition in the scene.

--- src/aliceVision/fuseCut/DelaunayGraphCut.cpp
+++ src/aliceVision/fuseCut/DelaunayGraphCut.cpp
@@ -478,7 +478,7 @@
     {
         nbPixels += imgParams.size;
     }
-    int step = std::floor(std::sqrt(((double)nbPixels / (1.0*maxVertices))));
+    int step = std::floor(std::sqrt(((double)nbPixels / (10.0*maxVertices))));
     step = std::max(step, 1);
     std::size_t realMaxVertices = 0;
     std::vector<int> startIndex(mp->getNbCameras(), 0);
@@ -614,7 +614,8 @@
         }

         ALICEVISION_LOG_INFO("Filter initial 3D points by pixel size to limit the number of points.");
-        // while(true)
+        double pixSizeMarginCoef = 2.0;
+        while(true)
         {
             // Filter by pixSize
             {
@@ -627,14 +628,14 @@
                 KdTree kdTree(3 /*dim*/, pointCloudRef, nanoflann::KDTreeSingleIndexAdaptorParams(MAX_LEAF_ELEMENTS));
                 kdTree.buildIndex();
 #endif
-                std::cout << "KdTree created for " << verticesCoordsPrepare.size() << " points." << std::endl;
+                ALICEVISION_LOG_INFO("KdTree created for " << verticesCoordsPrepare.size() << " points.");
                 #pragma omp parallel for
                 for(int i = 0; i < verticesCoordsPrepare.size(); ++i)
                 {
                     if(pixSizePrepare[i] == -1.0)
                         continue;

-                    const double pixSizeScore = 2.0 * simScorePrepare[i] * pixSizePrepare[i] * pixSizePrepare[i];
+                    const double pixSizeScore = pixSizeMarginCoef * simScorePrepare[i] * pixSizePrepare[i] * pixSizePrepare[i];
 #ifdef USE_GEOGRAM_KDTREE
                     static const std::size_t nbNeighbors = 20;
                     static const double nbNeighborsInv = 1.0 / (double)nbNeighbors;
@@ -702,8 +703,6 @@
                     }
                 }
                 ALICEVISION_LOG_INFO((verticesCoordsPrepare.size() - verticesCoordsTmp.size()) << " points with overlap removed.");
-                // if(verticesCoordsPrepare.size() == verticesCoordsTmp.size())
-                //     break;
                 verticesCoordsPrepare.swap(verticesCoordsTmp);
                 pixSizePrepare.swap(pixSizeTmp);
                 simScorePrepare.swap(simScoreTmp);
@@ -711,17 +710,17 @@

             if(verticesCoordsPrepare.size() < maxVertices)
             {
-                std::cout << "The number of points is below the max number of vertices." << std::endl;
-                // break;
+                ALICEVISION_LOG_INFO("The number of points is below the max number of vertices.");
+                break;
             }
             else
             {
-                // pixSizeMarginCoef *= 2.0;
+                pixSizeMarginCoef *= 1.5;
                 // ALICEVISION_LOG_INFO("Increase pixel size margin coef to " << pixSizeMarginCoef << ", nb points: " << verticesCoordsPrepare.size() << ", maxVertices: " << maxVertices);
                 ALICEVISION_LOG_INFO("Nb points: " << verticesCoordsPrepare.size() << ", maxVertices: " << maxVertices);
             }
         }
-        ALICEVISION_LOG_INFO("3D points loaded and filtered to " << verticesCoordsPrepare.size() << " points (maxVertices was " << maxVertices << ").");
+        ALICEVISION_LOG_INFO("3D points loaded and filtered to " << verticesCoordsPrepare.size() << " points (maxVertices is " << maxVertices << ").");
     }

     ALICEVISION_LOG_INFO("Create visibilities");
@@ -743,7 +742,7 @@
         #pragma omp parallel for num_threads(5)
         for(int c = 0; c < cams.size(); ++c)
         {
-            std::cout << "Create visibilities (" << c << "/" << cams.size() << ")" << std::endl;
+            ALICEVISION_LOG_INFO("Create visibilities (" << c << "/" << cams.size() << ")");
             std::vector<float> depthMap;
             std::vector<float> simMap;
             int width, height;


*** empty log message ***

*** empty log message ***

--- copasi/test/test.cpp
+++ copasi/test/test.cpp
@@ -51,7 +51,7 @@
 C_INT32  TestEigen(void);
 //C_INT32  TestOptimization(void);     //yohe: new

-C_INT32  CovertFunctionDB(void);
+C_INT32  ConvertFunctionDB(void);
 C_INT32  MakeFunctionDB(void);
 C_INT32  MakeFunctionEntry(const string &name,
                            const string &description,
@@ -88,32 +88,30 @@
 //      TestException();
 //      TestMessage();

-//       TestWriteConfig();
-//       TestReadConfig();
-
+//      TestWriteConfig();
+//      TestReadConfig();
 //      TestCompartment();
 //      TestDatum();
 //      TestMetab();
 //      TestReadSample();
 //      TestNewton();
-//      TestSSSolution();
+      TestSSSolution();
 //YOHE: new test
 //      TestOptimization();
-      TestEigen();
-
-//       TestTrajectory();
-//       TestMoiety();
-//       TestKinFunction();
-//       TestMassAction();
-//       TestFunctionDB();
-//       TestBaseFunction();
-//       TestModel();
-//       TestLU();
-//       TestMCA();
-//       TestOutputEvent();
-
-//       MakeFunctionDB();
-//       CovertFunctionDB();
+//      TestEigen();
+
+//      TestTrajectory();
+//      TestMoiety();
+//      TestKinFunction();
+//      TestMassAction();
+//      TestFunctionDB();
+//      TestBaseFunction();
+//      TestModel();
+//      TestLU();
+//      TestMCA();
+//      TestOutputEvent();
+//      MakeFunctionDB();
+//      ConvertFunctionDB();

 //      TestRandom(10000, 100);
 //      TestDependencyGraph();
@@ -688,6 +686,7 @@
   f.getParameters().add("b", CFunctionParameter::FLOAT64, "UNKNOWN");

   f.compile();
+  cout << "f(a,b) = (a-b)*(a+b)/5" << endl;

   //  f.setIdentifierType("a", N_SUBSTRATE);
   //  f.setIdentifierType("b", N_PRODUCT);
@@ -703,7 +702,9 @@
   CallParameters[1] = &b;

   C_FLOAT64 r = f.calcValue(CallParameters);
-  cout << "Value obtained = " << r << " Should be = " << (a-b)*(a+b)/5 << endl;
+
+  cout << "f(a,b) = " << f.getDescription() << endl;
+  cout << "f(" << a << "," << b << ") = " << r << endl;

   CWriteConfig out("TestKinFunction.gps");
   f.save(out);
@@ -718,6 +719,7 @@

   a = 5;
   r = g.calcValue(CallParameters);
+  cout << "f(" << a << "," << b << ") = " << r << endl;

   return 0;
 }
@@ -1475,7 +1477,7 @@
   return 0;
 }

-C_INT32 CovertFunctionDB(void)
+C_INT32 ConvertFunctionDB(void)
 {
   CFunctionDB FunctionDB;


Add "Rate Matching" field to MyPropertyPage

--- src/MyPropertyPage.cpp
+++ src/MyPropertyPage.cpp
@@ -134,7 +134,7 @@
         std::wstring bitstreamingField = (inputFormat ? (DspFormatFromWaveFormat(*inputFormat) ==
                                                          DspFormat::Unknown ? L"Yes" : L"No") : L"-");

-        std::wstring externalClockField = L"N/A";
+        std::wstring rateMatchingField = (pDevice && pDevice->IsLive()) ? L"Yes" : L"No";

         std::wstring channelsInputField = (inputFormat ? std::to_wstring(inputFormat->nChannels) +
                                               L" (" + GetHexString(DspMatrix::GetChannelMask(*inputFormat)) + L")" : L"-");
@@ -176,8 +176,8 @@
         WriteDialogItem(m_dialogData, BS_TEXT | SS_LEFT,  0x0082FFFF, 73, 56,  120, 8, bufferField);
         WriteDialogItem(m_dialogData, BS_TEXT | SS_RIGHT, 0x0082FFFF, 10, 68,  60,  8, L"Bitstreaming:");
         WriteDialogItem(m_dialogData, BS_TEXT | SS_LEFT,  0x0082FFFF, 73, 68,  120, 8, bitstreamingField);
-        WriteDialogItem(m_dialogData, BS_TEXT | SS_RIGHT, 0x0082FFFF, 10, 80,  60,  8, L"External Clock:");
-        WriteDialogItem(m_dialogData, BS_TEXT | SS_LEFT,  0x0082FFFF, 73, 80,  120, 8, externalClockField);
+        WriteDialogItem(m_dialogData, BS_TEXT | SS_RIGHT, 0x0082FFFF, 10, 80,  60,  8, L"Rate Matching:");
+        WriteDialogItem(m_dialogData, BS_TEXT | SS_LEFT,  0x0082FFFF, 73, 80,  120, 8, rateMatchingField);
         WriteDialogItem(m_dialogData, BS_TEXT | SS_RIGHT, 0x0082FFFF, 10, 92,  60,  8, L"Format:");
         WriteDialogItem(m_dialogData, BS_TEXT | SS_LEFT,  0x0082FFFF, 73, 92,  120, 8, formatField);
         WriteDialogItem(m_dialogData, BS_TEXT | SS_RIGHT, 0x0082FFFF, 10, 104, 60,  8, L"Channels:");


Delete task21.cpp

Delete task21.cpp

--- module1/part2/task21.cpp
+++ module1/part2/task21.cpp
@@ -1,12 +0,0 @@
-#include <iostream>
-
-using namespace std;
-
-int main() {
-    int x, y;
-    cin >> x;
-    if (x >= y) {cout << x;}
-    else {cout << y;
-    }
-    return 0;
-}


Add encoding to controlpanel's help

Add encoding to controlpanel's help

--- modules/controlpanel.cpp
+++ modules/controlpanel.cpp
@@ -75,7 +75,10 @@
 			{"PrependTimestamp",    boolean},
 			{"TimestampFormat",     str},
 			{"DCCBindHost",         str},
-			{"StatusPrefix",        str}
+			{"StatusPrefix",        str},
+#ifdef HAVE_ICU
+			{"ClientEncoding",      str},
+#endif
 		};
 		for (unsigned int i = 0; i != ARRAY_SIZE(vars); ++i) {
 			VarTable.AddRow();
@@ -97,6 +100,9 @@
 			{"BindHost",            str},
 			{"FloodRate",           doublenum},
 			{"FloodBurst",          integer},
+#ifdef HAVE_ICU
+			{"Encoding",            str},
+#endif
 		};
 		for (unsigned int i = 0; i != ARRAY_SIZE(nvars); ++i) {
 			NVarTable.AddRow();


Ensure that def-side physreg copies are scheduled above any other uses
so the scheduler can't create new interferences on the copies
themselves. Prior to this fix the scheduler could get stuck in a loop
creating copies.
Fixes PR9509.

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@128164 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
+++ lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
@@ -934,6 +934,15 @@
       D.setSUnit(CopyToSU);
       AddPred(SuccSU, D);
       DelDeps.push_back(std::make_pair(SuccSU, *I));
+    }
+    else {
+      // Avoid scheduling the def-side copy before other successors. Otherwise
+      // we could introduce another physreg interference on the copy and
+      // continue inserting copies indefinitely.
+      SDep D(CopyFromSU, SDep::Order, /*Latency=*/0,
+             /*Reg=*/0, /*isNormalMemory=*/false,
+             /*isMustAlias=*/false, /*isArtificial=*/true);
+      AddPred(SuccSU, D);
     }
   }
   for (unsigned i = 0, e = DelDeps.size(); i != e; ++i)


fix reporting of solutions in //

fix reporting of solutions in //

--- src/flatzinc/fz_search.cc
+++ src/flatzinc/fz_search.cc
@@ -887,7 +887,7 @@
                      solver_->failures()));
     final_output.append(StringPrintf("%%%%  memory:               %s\n",
                                      FlatZincMemoryUsage().c_str()));
-    const int64 best = objective_ != NULL ? objective_->best() : 0;
+    const int64 best = parallel_support->BestSolution();
     if (objective_ != NULL) {
       if (method_ == MIN && solver_->solutions() > 0) {
         final_output.append(


Avoid dyn_cast to ShapedType

    Avoid dyn_cast to ShapedType

    ShapedType just indicates shape/rank/element semantics. It's generally not useful for other type checking. This check already checks for vector or tensor type, so we can use a direct cast if we check those first.

    Related to making MemRefType a subclass of ShapedType

--

PiperOrigin-RevId: 250583231

--- lib/Quantizer/Configurations/FxpMathConfig.cpp
+++ lib/Quantizer/Configurations/FxpMathConfig.cpp
@@ -96,9 +96,8 @@
   bool isHandledType(Type t) const final {
     if (t.isa<FloatType>())
       return true;
-    auto shapedType = t.dyn_cast<ShapedType>();
-    return (shapedType && shapedType.getElementType().isa<FloatType>() &&
-            (t.isa<VectorType>() || t.isa<TensorType>()));
+    return (t.isa<VectorType>() || t.isa<TensorType>()) &&
+           t.cast<ShapedType>().getElementType().isa<FloatType>();
   }

   void finalizeAnchors(CAGSlice &cag) const override {


ARM64 doesn't set the low bit of return addresses.

--- lib/Runtime/Language/JavascriptStackWalker.cpp
+++ lib/Runtime/Language/JavascriptStackWalker.cpp
@@ -353,7 +353,7 @@

         if (pCodeAddr)
         {
-#if defined(_M_ARM32_OR_ARM64)
+#if defined(_M_ARM)
             // Note that DWORD_PTR is not actually a pointer type (!) but is simple unsigned long/__int64 (see BaseTsd.h).
             // Thus, decrement would be by 1 byte and not 4 bytes as in pointer arithmetic. That's exactly what we need.
             // For ARM the 'return address' is always odd and is 'next instr addr' + 1 byte, so to get to the BLX instr, we need to subtract 2 bytes from it.


vcl: Use glScissor for rectangular clip regions

Change-Id: I62bf28d854d889242a49146cfe87c3dd6be89c32


Generalize the setcc -> PHI and Select  folding optimizations to work with
any constant RHS, not just a constant integer RHS.  This implements
select.ll:test17

git-svn-id: 0ff597fd157e6f4fc38580e8d64ab130330d2411@21470 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Transforms/Scalar/InstructionCombining.cpp
+++ lib/Transforms/Scalar/InstructionCombining.cpp
@@ -2450,10 +2450,6 @@

     if (Instruction *LHSI = dyn_cast<Instruction>(Op0))
       switch (LHSI->getOpcode()) {
-      case Instruction::PHI:
-        if (Instruction *NV = FoldOpIntoPhi(I))
-          return NV;
-        break;
       case Instruction::And:
         if (LHSI->hasOneUse() && isa<ConstantInt>(LHSI->getOperand(1)) &&
             LHSI->getOperand(0)->hasOneUse()) {
@@ -2705,32 +2701,6 @@
           }
         }
         break;
-      case Instruction::Select:
-        // If either operand of the select is a constant, we can fold the
-        // comparison into the select arms, which will cause one to be
-        // constant folded and the select turned into a bitwise or.
-        Value *Op1 = 0, *Op2 = 0;
-        if (LHSI->hasOneUse()) {
-          if (Constant *C = dyn_cast<Constant>(LHSI->getOperand(1))) {
-            // Fold the known value into the constant operand.
-            Op1 = ConstantExpr::get(I.getOpcode(), C, CI);
-            // Insert a new SetCC of the other select operand.
-            Op2 = InsertNewInstBefore(new SetCondInst(I.getOpcode(),
-                                                      LHSI->getOperand(2), CI,
-                                                      I.getName()), I);
-          } else if (Constant *C = dyn_cast<Constant>(LHSI->getOperand(2))) {
-            // Fold the known value into the constant operand.
-            Op2 = ConstantExpr::get(I.getOpcode(), C, CI);
-            // Insert a new SetCC of the other select operand.
-            Op1 = InsertNewInstBefore(new SetCondInst(I.getOpcode(),
-                                                      LHSI->getOperand(1), CI,
-                                                      I.getName()), I);
-          }
-        }
-
-        if (Op1)
-          return new SelectInst(LHSI->getOperand(0), Op1, Op2);
-        break;
       }

     // Simplify seteq and setne instructions...
@@ -2894,6 +2864,43 @@
         }
       }
     }
+  }
+
+  // Handle setcc with constant RHS's that can be integer, FP or pointer.
+  if (Constant *RHSC = dyn_cast<Constant>(Op1)) {
+    if (Instruction *LHSI = dyn_cast<Instruction>(Op0))
+      switch (LHSI->getOpcode()) {
+      case Instruction::PHI:
+        if (Instruction *NV = FoldOpIntoPhi(I))
+          return NV;
+        break;
+      case Instruction::Select:
+        // If either operand of the select is a constant, we can fold the
+        // comparison into the select arms, which will cause one to be
+        // constant folded and the select turned into a bitwise or.
+        Value *Op1 = 0, *Op2 = 0;
+        if (LHSI->hasOneUse()) {
+          if (Constant *C = dyn_cast<Constant>(LHSI->getOperand(1))) {
+            // Fold the known value into the constant operand.
+            Op1 = ConstantExpr::get(I.getOpcode(), C, RHSC);
+            // Insert a new SetCC of the other select operand.
+            Op2 = InsertNewInstBefore(new SetCondInst(I.getOpcode(),
+                                                      LHSI->getOperand(2), RHSC,
+                                                      I.getName()), I);
+          } else if (Constant *C = dyn_cast<Constant>(LHSI->getOperand(2))) {
+            // Fold the known value into the constant operand.
+            Op2 = ConstantExpr::get(I.getOpcode(), C, RHSC);
+            // Insert a new SetCC of the other select operand.
+            Op1 = InsertNewInstBefore(new SetCondInst(I.getOpcode(),
+                                                      LHSI->getOperand(1), RHSC,
+                                                      I.getName()), I);
+          }
+        }
+
+        if (Op1)
+          return new SelectInst(LHSI->getOperand(0), Op1, Op2);
+        break;
+      }
   }

   // If we can optimize a 'setcc GEP, P' or 'setcc P, GEP', do so now.


INTEGRATION: CWS wmicons (1.2.772); FILE MERGED 2005/02/24 14:14:01 obr 1.2.772.1: #i37167# window manager icons now loaded from resource

--- vcl/unx/inc/soicon.hxx
+++ vcl/unx/inc/soicon.hxx
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: soicon.hxx,v $
  *
- *  $Revision: 1.2 $
+ *  $Revision: 1.3 $
  *
- *  last change: $Author: ssa $ $Date: 2001-04-27 15:29:20 $
+ *  last change: $Author: kz $ $Date: 2005-03-03 19:57:48 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -61,21 +61,10 @@
 #ifndef _SV_SOICON_HXX
 #define _SV_SOICON_HXX

-// base name of a custom icon function (must be declared extern "C")
-// the iconid must be directly appended, eg: vcl_customIcon100
-#define VCL_CUSTOM_ICON_BASE  "vcl_customIcon"
-
-// type of the custom icon function
-typedef void VCL_CUSTOM_ICON_FN( char **&, char **&, char **&, char **&);
-
 class SalDisplay;
 class SalBitmap;
 class Bitmap;

 BOOL SelectAppIconPixmap( SalDisplay *pDisplay, USHORT nIcon, USHORT iconSize,
                           Pixmap& icon_pixmap, Pixmap& icon_mask );
-
-BOOL ReadXPMFile( Display*, const String&, SalBitmap*&, SalBitmap*& );
-BOOL ReadXBMFile( Display*, const String&, SalBitmap*& );
-
 #endif