Adding the secant method routine. Still need to add tests.

--- fixed_point.hpp
+++ fixed_point.hpp
@@ -257,6 +257,83 @@
             std::vector<Float>>
     secant_method(const Func& f, Float x0, Float x1, Float abstol)
     {
-
+        // vector to store intermediate x_i values
+        std::vector<Float> xvec;
+        std::vector<Float> rvec; // vector of rate approximations
+
+        // do the first iteration outside the while loop
+        xvec.push_back(x1);
+        auto x2 = x1 - f(x1) * ((x1 - x0) / (f(x1) - f(x0)));
+        xvec.push_back(x2);
+        Float currtol = static_cast<Float>(std::abs(xvec[0] - x1));
+
+        // number of iterations : we have already performed one
+        auto i = 2;
+        Float rate = NAN;
+        rvec.push_back(rate);
+
+        Float x_iminus2;
+        Float x_iminus1;
+        Float x_i;
+        Float x_iplus1;
+        Float deltaxp1;
+        while (currtol > abstol)
+        {
+            x_iminus2 = xvec[i - 2];
+            x_iminus1 = xvec[i - 1];
+            x_i = x_iminus1 - f(x_iminus1) * ((x_iminus1 - x_iminus2) / (f(x_iminus1) - f(x_iminus2)));
+            xvec.push_back(x_i);
+            x_iplus1 = x_i - f(x_i) * ((x_i - x_iminus1) / (f(x_i) - f(x_iminus1)));
+            currtol = std::abs(x_i - x_iminus1);
+            deltaxp1 = std::abs(x_iplus1 - x_i);
+
+            if ((i - 2) > 0) {
+                rate = std::log(deltaxp1 / currtol) / std::log(currtol / std::abs(x_iminus1 - xvec[i - 2]));
+                rvec.push_back(rate);
+            } else {
+                rvec.push_back(NAN);
+            }
+
+            ++i;
+        }
+
+        return std::make_tuple(xvec, i, rvec);
+    }
+
+    template<typename Float, typename = std::enable_if<std::is_arithmetic<Float>::value>::type>
+    Float midpoint(Float a, Float b)
+    {
+        return a + (b - a) / 2;
+    }
+
+    template<typename Float, typename = std::enable_if<std::is_arithmetic<Float>::value>::type>
+    int sign(Float a)
+    {
+        return a > 0 ? 1 : -1;
+    }
+
+    template<typename Func, typename Float>
+    Float
+    bisection_method(const Func& f, Float a, Float b, Float abstol, int numiters)
+    {
+        auto n = 1;
+        Float c;
+        Float l = a;
+        Float u = b;
+        while (n <= numiters)
+        {
+            c = midpoint(l, u);
+            if ((u - l) < abstol) {
+                break;
+            }
+            if (sign(f(c)) = sign(f(l))) {
+                l = c;
+            } else {
+                b = c;
+            }
+            n++;
+        }
+
+        return c;
     }
 }


layers: Fix usage flags validation of CreateImageView

We need to validate the flags before calling down into the ICD. At least
one ICD (Anvil) asserts if it sees bad flags.

Signed-off-by: Chris Forbes <5dcac483e7a6e31a5cbe89f38cc69dff8ee93dac@ijw.co.nz>

--- layers/core_validation.cpp
+++ layers/core_validation.cpp
@@ -5586,21 +5586,30 @@

 VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
                                                                  const VkAllocationCallbacks *pAllocator, VkImageView *pView) {
+    bool skipCall = false;
+    VkResult result = VK_ERROR_VALIDATION_FAILED_EXT;
+
     layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
-    VkResult result = dev_data->device_dispatch_table->CreateImageView(device, pCreateInfo, pAllocator, pView);
+    {
+        // Validate that img has correct usage flags set
+        std::lock_guard<std::mutex> lock(global_lock);
+        skipCall |= validate_image_usage_flags(dev_data, pCreateInfo->image,
+                VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT |
+                VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
+                false, "vkCreateImageView()", "VK_IMAGE_USAGE_[SAMPLED|STORAGE|COLOR_ATTACHMENT]_BIT");
+    }
+
+    if (!skipCall) {
+        result = dev_data->device_dispatch_table->CreateImageView(device, pCreateInfo, pAllocator, pView);
+    }
+
     if (VK_SUCCESS == result) {
         std::lock_guard<std::mutex> lock(global_lock);
         VkImageViewCreateInfo localCI = VkImageViewCreateInfo(*pCreateInfo);
         ResolveRemainingLevelsLayers(dev_data, &localCI.subresourceRange, pCreateInfo->image);
         dev_data->imageViewMap[*pView] = localCI;
-#if MTMERGESOURCE
-        // Validate that img has correct usage flags set
-        validate_image_usage_flags(dev_data, pCreateInfo->image,
-                                   VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT |
-                                       VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
-                                   false, "vkCreateImageView()", "VK_IMAGE_USAGE_[SAMPLED|STORAGE|COLOR_ATTACHMENT]_BIT");
-#endif
-    }
+    }
+
     return result;
 }


Don't write error message to result file if we're computing checksum (-sum)

--- DirHash.cpp
+++ DirHash.cpp
@@ -1299,7 +1299,7 @@
 	else
 	{
 		if (!bQuiet) ShowError(_T("Failed to open file \"%s\" for reading\n"), szFilePath);
-		if (outputFile) _ftprintf(outputFile, _T("Failed to open file \"%s\" for reading\n"), szFilePath);
+		if (outputFile && (!bSumMode || bSumVerificationMode)) _ftprintf(outputFile, _T("Failed to open file \"%s\" for reading\n"), szFilePath);
 		if (g_bSkipError)
 		{
 			if (bSumMode) g_bMismatchFound = true;
@@ -1324,6 +1324,7 @@
 	DWORD dwError = 0;
 	list<CDirContent> dirContent;
 	int pathLen = lstrlen(szDirPath);
+	bool bSumVerificationMode = (bSumMode && !digestList.empty());

 	if (pathLen <= MAX_PATH && !excludeSpecList.empty() && IsExcludedName(szDirPath, excludeSpecList))
 		return 0;
@@ -1340,7 +1341,7 @@
 	{
 		dwError = GetLastError();
 		if (!bQuiet) ShowError(_T("FindFirstFile failed on \"%s\" with error 0x%.8X.\n"), szDirPath, dwError);
-		if (outputFile) _ftprintf(outputFile, _T("FindFirstFile failed on \"%s\" with error 0x%.8X.\n"), szDirPath, dwError);
+		if (outputFile && (!bSumMode || bSumVerificationMode)) _ftprintf(outputFile, _T("FindFirstFile failed on \"%s\" with error 0x%.8X.\n"), szDirPath, dwError);
 		if (g_bSkipError)
 		{
 			return 0;
@@ -1373,7 +1374,7 @@
 	{
 		FindClose(hFind);
 		if (!bQuiet) ShowError(TEXT("FindNextFile failed while listing \"%s\". \n Error 0x%.8X.\n"), szDirPath, dwError);
-		if (outputFile) _ftprintf(outputFile, TEXT("FindNextFile failed while listing \"%s\". \n Error 0x%.8X.\n"), szDirPath, dwError);
+		if (outputFile && (!bSumMode || bSumVerificationMode)) _ftprintf(outputFile, TEXT("FindNextFile failed while listing \"%s\". \n Error 0x%.8X.\n"), szDirPath, dwError);
 		if (g_bSkipError)
 		{
 			return 0;


[operators] fix on template match for operators *= and /=

--- fixed_point.hpp
+++ fixed_point.hpp
@@ -252,18 +252,24 @@
 	return extended_res.template convert<INT_BITS, FRAC_BITS>();
 }

-template <uint16_t INT_BITS2, uint16_t FRAC_BITS2>
-this_t& operator*=(const fixed_point_t<INT_BITS2, FRAC_BITS2>& value)
-{
+template <typename other_t>
+this_t operator*(const other_t& value) const
+{
+	return *this * this_t(value);
+}
+
+this_t& operator*=(const this_t& value) {
 	const auto tmp = *this * value;
 	raw = tmp.template convert<INT_BITS, FRAC_BITS>().getRaw();
 	return *this;
 }

-template <typename other_t>
-this_t operator*(const other_t& value) const
-{
-	return *this * this_t(value);
+template <uint16_t INT_BITS2, uint16_t FRAC_BITS2>
+this_t& operator*=(const fixed_point_t<INT_BITS2, FRAC_BITS2>& value)
+{
+	const auto tmp = *this * value;
+	raw = tmp.template convert<INT_BITS, FRAC_BITS>().getRaw();
+	return *this;
 }

 template <typename other_t>
@@ -297,8 +303,13 @@
 	return *this / this_t(value);
 }

-template <uint16_t INT_BITS2, uint16_t FRAC_BITS2>
-this_t operator/=(const fixed_point_t<INT_BITS2, FRAC_BITS2>& value) const
+this_t& operator/=(const this_t& value) {
+	const auto tmp = *this / value;
+	raw = tmp.getRaw();
+}
+
+template <uint16_t INT_BITS2, uint16_t FRAC_BITS2>
+this_t& operator/=(const fixed_point_t<INT_BITS2, FRAC_BITS2>& value)
 {
 	const auto tmp = *this / value;
 	raw = tmp.template convert<INT_BITS, FRAC_BITS>().getRaw();


Debugging...

Debugging...

--- JMain.cpp
+++ JMain.cpp
@@ -76,12 +76,11 @@
       JL_SET_STACK_BASE;

       done = false;
-      shared_ptr<nj::Expr> expr;

       while(!done)
       {
 printf("entering de_queue\n");
-         expr = de_queue(eval_queue);
+         shared_ptr<nj::Expr> expr = de_queue(eval_queue);

 printf("got an expr\n");

@@ -105,7 +104,7 @@
               else done = true;
             }
          }
-         else done = true;
+         else printf("Expr was null\n");
       }
    }
 }


Fix camera view on PC

Fix camera view on PC

--- selfdrive/ui/ui.cc
+++ selfdrive/ui/ui.cc
@@ -85,7 +85,7 @@

 void handle_message(UIState *s, SubMaster &sm) {
   UIScene &scene = s->scene;
-  if (sm.updated("controlsState")) {
+  if (s->started && sm.updated("controlsState")) {
     auto event = sm["controlsState"];
     scene.controls_state = event.getControlsState();
     s->controls_seen = true;
@@ -196,12 +196,6 @@
       s->vision_seen = false;
       s->controls_seen = false;
       s->active_app = cereal::UiLayoutState::App::HOME;
-
-      #ifndef QCOM
-      // disconnect from visionipc on PC
-      close(s->ipc_fd);
-      s->ipc_fd = -1;
-      #endif
     }
   } else if (s->status == STATUS_STOPPED) {
     update_status(s, STATUS_DISENGAGED);


(CSSVerticalAlignValueImp::getOffset) : Support 'text-top' and 'text-bottom'; cf. vertical-align-boxes-001.

--- www/css/CSSPropertyValueImp.cpp
+++ www/css/CSSPropertyValueImp.cpp
@@ -1741,10 +1741,28 @@
         return line->getBaseline() - (leading + font->getAscender(point)) + font->getSub(point);
     case Super:
         return line->getBaseline() - (leading + font->getAscender(point)) - font->getSuper(point);
-    case TextTop:
-        return 0.0f;
-    case TextBottom:
-        return line->getHeight() - font->getLineHeight(point);
+    case TextTop: {
+        float offset = 0.0f;
+        if (CSSStyleDeclarationImp* parent = self->getParentStyle()) {
+            FontTexture* font = parent->getFontTexture();
+            if (!font)
+                font = view->selectFont(parent);
+            if (font)
+                offset = line->getBaseline() - font->getAscender(point);
+        }
+        return offset;
+    }
+    case TextBottom: {
+        float offset = line->getHeight();
+        if (CSSStyleDeclarationImp* parent = self->getParentStyle()) {
+            FontTexture* font = parent->getFontTexture();
+            if (!font)
+                font = view->selectFont(parent);
+            if (font)
+                offset = line->getBaseline() - font->getDescender(point);
+        }
+        return offset - font->getLineHeight(point);
+    }
     default:
         assert(value.unit == css::CSSPrimitiveValue::CSS_PX);
         return line->getBaseline() - (leading + font->getAscender(point)) - value.getPx();
@@ -1777,10 +1795,29 @@
         return line->getBaseline() - (leading + text->getBaseline()) + text->getSub();
     case Super:
         return line->getBaseline() - (leading + text->getBaseline()) - text->getSuper();
-    case TextTop:
-        return 0.0f;
-    case TextBottom:
-        return line->getHeight() - text->getHeight();
+    case TextTop: {
+        float offset = 0.0f;
+        if (CSSStyleDeclarationImp* parent = self->getParentStyle()) {
+            FontTexture* font = parent->getFontTexture();
+            if (!font)
+                font = view->selectFont(parent);
+            if (font)
+                offset = line->getBaseline() - font->getAscender(view->getPointFromPx(self->fontSize.getPx()));
+        }
+        return offset;
+    }
+    case TextBottom: {
+        float offset = line->getHeight();
+        if (CSSStyleDeclarationImp* parent = self->getParentStyle()) {
+            FontTexture* font = parent->getFontTexture();
+            if (!font)
+                font = view->selectFont(parent);
+            if (font)
+                offset = line->getBaseline() - font->getDescender(view->getPointFromPx(self->fontSize.getPx()));
+        }
+        offset -= text->getTotalHeight();
+        return offset;
+    }
     default:
         assert(value.unit == css::CSSPrimitiveValue::CSS_PX);
         return line->getBaseline() - (leading + text->getBaseline()) - value.getPx();


Note about compiler optimization.

Note about compiler optimization.

--- python/fixfmt/functions.cc
+++ python/fixfmt/functions.cc
@@ -44,6 +44,9 @@
   int precision = 0;
   TYPE precision_scale = 1;
   TYPE tolerance = fixfmt::pow10(-max_precision) / 2;
+
+  // Note: Weird.  LLVM 6.1.0 on OSX vectorizes this loop only if the precision
+  // logic is _present_, with the result that it runs _faster_ than without.

   for (size_t i = 0; i < length; ++i) {
     TYPE const val = array[i];


Define problem

Define problem


layers: Get rid of remaining use of single physical_device_state in
instance

Signed-off-by: Chris Forbes <c3279c50043e18e9442c1ae071cafa0e7a4ca967@google.com>

--- layers/core_validation.cpp
+++ layers/core_validation.cpp
@@ -146,7 +146,6 @@
     // Device specific data
     PHYS_DEV_PROPERTIES_NODE phys_dev_properties = {};
     VkPhysicalDeviceMemoryProperties phys_dev_mem_props = {};
-    unique_ptr<PHYSICAL_DEVICE_STATE> physical_device_state = nullptr;

     unordered_map<VkPhysicalDevice, PHYSICAL_DEVICE_STATE> physical_device_map;
 };
@@ -4365,36 +4364,37 @@
 }

 // Verify that queue family has been properly requested
-bool ValidateRequestedQueueFamilyProperties(layer_data *dev_data, const VkDeviceCreateInfo *create_info) {
-    bool skip_call = false;
+bool ValidateRequestedQueueFamilyProperties(layer_data *instance_data, VkPhysicalDevice gpu, const VkDeviceCreateInfo *create_info) {
+    bool skip_call = false;
+    auto physical_device_state = getPhysicalDeviceState(instance_data, gpu);
     // First check is app has actually requested queueFamilyProperties
-    if (!dev_data->physical_device_state) {
-        skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT,
+    if (!physical_device_state) {
+        skip_call |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT,
                              0, __LINE__, DEVLIMITS_MUST_QUERY_COUNT, "DL",
                              "Invalid call to vkCreateDevice() w/o first calling vkEnumeratePhysicalDevices().");
-    } else if (QUERY_DETAILS != dev_data->physical_device_state->vkGetPhysicalDeviceQueueFamilyPropertiesState) {
+    } else if (QUERY_DETAILS != physical_device_state->vkGetPhysicalDeviceQueueFamilyPropertiesState) {
         // TODO: This is not called out as an invalid use in the spec so make more informative recommendation.
-        skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT,
+        skip_call |= log_msg(instance_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT,
                              VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST,
                              "DL", "Call to vkCreateDevice() w/o first calling vkGetPhysicalDeviceQueueFamilyProperties().");
     } else {
         // Check that the requested queue properties are valid
         for (uint32_t i = 0; i < create_info->queueCreateInfoCount; i++) {
             uint32_t requestedIndex = create_info->pQueueCreateInfos[i].queueFamilyIndex;
-            if (dev_data->queue_family_properties.size() <=
+            if (instance_data->queue_family_properties.size() <=
                 requestedIndex) { // requested index is out of bounds for this physical device
                 skip_call |= log_msg(
-                    dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0,
+                    instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0,
                     __LINE__, DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, "DL",
                     "Invalid queue create request in vkCreateDevice(). Invalid queueFamilyIndex %u requested.", requestedIndex);
             } else if (create_info->pQueueCreateInfos[i].queueCount >
-                       dev_data->queue_family_properties[requestedIndex]->queueCount) {
+                       instance_data->queue_family_properties[requestedIndex]->queueCount) {
                 skip_call |=
-                    log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT,
+                    log_msg(instance_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT,
                             0, __LINE__, DEVLIMITS_INVALID_QUEUE_CREATE_REQUEST, "DL",
                             "Invalid queue create request in vkCreateDevice(). QueueFamilyIndex %u only has %u queues, but "
                             "requested queueCount is %u.",
-                            requestedIndex, dev_data->queue_family_properties[requestedIndex]->queueCount,
+                            requestedIndex, instance_data->queue_family_properties[requestedIndex]->queueCount,
                             create_info->pQueueCreateInfos[i].queueCount);
             }
         }
@@ -4445,7 +4445,7 @@
     if (pCreateInfo->pEnabledFeatures) {
         skip_call |= ValidateRequestedFeatures(my_instance_data, gpu, pCreateInfo->pEnabledFeatures);
     }
-    skip_call |= ValidateRequestedQueueFamilyProperties(my_instance_data, pCreateInfo);
+    skip_call |= ValidateRequestedQueueFamilyProperties(my_instance_data, gpu, pCreateInfo);

     if (skip_call) {
         return VK_ERROR_VALIDATION_FAILED_EXT;
@@ -11422,14 +11422,15 @@
     VkQueueFamilyProperties *pQueueFamilyProperties) {
     bool skip_call = false;
     layer_data *phy_dev_data = get_my_data_ptr(get_dispatch_key(physicalDevice), layer_data_map);
-    if (phy_dev_data->physical_device_state) {
-        if (NULL == pQueueFamilyProperties) {
-            phy_dev_data->physical_device_state->vkGetPhysicalDeviceQueueFamilyPropertiesState = QUERY_COUNT;
+    auto physical_device_state = getPhysicalDeviceState(phy_dev_data, physicalDevice);
+    if (physical_device_state) {
+        if (!pQueueFamilyProperties) {
+            physical_device_state->vkGetPhysicalDeviceQueueFamilyPropertiesState = QUERY_COUNT;
         }
         else {
             // Verify that for each physical device, this function is called first with NULL pQueueFamilyProperties ptr in order to
             // get count
-            if (UNCALLED == phy_dev_data->physical_device_state->vkGetPhysicalDeviceQueueFamilyPropertiesState) {
+            if (UNCALLED == physical_device_state->vkGetPhysicalDeviceQueueFamilyPropertiesState) {
                 skip_call |= log_msg(phy_dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT,
                     VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_MISSING_QUERY_COUNT, "DL",
                     "Call sequence has vkGetPhysicalDeviceQueueFamilyProperties() w/ non-NULL "
@@ -11437,7 +11438,7 @@
                     "NULL pQueueFamilyProperties to query pCount.");
             }
             // Then verify that pCount that is passed in on second call matches what was returned
-            if (phy_dev_data->physical_device_state->queueFamilyPropertiesCount != *pCount) {
+            if (physical_device_state->queueFamilyPropertiesCount != *pCount) {

                 // TODO: this is not a requirement of the Valid Usage section for vkGetPhysicalDeviceQueueFamilyProperties, so
                 // provide as warning
@@ -11445,17 +11446,17 @@
                     VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT, 0, __LINE__, DEVLIMITS_COUNT_MISMATCH, "DL",
                     "Call to vkGetPhysicalDeviceQueueFamilyProperties() w/ pCount value %u, but actual count "
                     "supported by this physicalDevice is %u.",
-                    *pCount, phy_dev_data->physical_device_state->queueFamilyPropertiesCount);
-            }
-            phy_dev_data->physical_device_state->vkGetPhysicalDeviceQueueFamilyPropertiesState = QUERY_DETAILS;
+                    *pCount, physical_device_state->queueFamilyPropertiesCount);
+            }
+            physical_device_state->vkGetPhysicalDeviceQueueFamilyPropertiesState = QUERY_DETAILS;
         }
         if (skip_call) {
             return;
         }
         phy_dev_data->instance_dispatch_table->GetPhysicalDeviceQueueFamilyProperties(physicalDevice, pCount,
             pQueueFamilyProperties);
-        if (NULL == pQueueFamilyProperties) {
-            phy_dev_data->physical_device_state->queueFamilyPropertiesCount = *pCount;
+        if (!pQueueFamilyProperties) {
+            physical_device_state->queueFamilyPropertiesCount = *pCount;
         }
         else { // Save queue family properties
             phy_dev_data->queue_family_properties.reserve(*pCount);


Performance Issue. Convert triangles Strip to triangles.

--- io/glc_3dxmltoworld.cpp
+++ io/glc_3dxmltoworld.cpp
@@ -801,7 +801,22 @@
 				stripsStream >> buff;
 				stripsIndex.append(buff.toUInt());
 			}
-			pMesh->addTrianglesStrip(pCurrentMaterial, stripsIndex, lod);
+			// Convert strip to triangles
+			IndexList newList;
+			newList.append(stripsIndex.at(0));
+			newList.append(stripsIndex.at(1));
+			newList.append(stripsIndex.at(2));
+			const int size= stripsIndex.size();
+			int delta= -1;
+			for (int i= 2; i < size - 1; ++i)
+			{
+				newList.append(stripsIndex.at(i));
+				newList.append(stripsIndex.at(i + delta));
+				newList.append(stripsIndex.at(i - delta));
+				delta = -delta;
+			}
+
+			pMesh->addTriangles(pCurrentMaterial, newList, lod);
 		}
 	}
 	// Trying to find fans


MAINT: clean up code.

MAINT: clean up code.

--- cpp/src/DO/Sara/ImageProcessing/GemmBasedConvolution.hpp
+++ cpp/src/DO/Sara/ImageProcessing/GemmBasedConvolution.hpp
@@ -20,7 +20,7 @@
 #include <DO/Sara/Core/Tensor.hpp>

-namespace DO { namespace Sara {
+namespace DO::Sara {

   //! @{
   //! @brief Reimplement the `im2row` function.
@@ -93,17 +93,6 @@
                         std::multiplies<int>());

     auto phi_x = Tensor_<T, 2>{num_rows, num_cols};
-#ifdef DEBUG_IM2COL
-    std::cout << "kernel_sizes  = " << kernel_sizes.transpose() << std::endl;
-    std::cout << "start         = " << begin.transpose() << std::endl;
-    std::cout << "end           = " << end.transpose() << std::endl;
-    std::cout << "strides       = " << strides.transpose() << std::endl;
-    std::cout << "shift         = " << shift.transpose() << std::endl;
-
-    std::cout << "x sz          = " << x.sizes().transpose() << std::endl;
-    std::cout << "sampled x sz  = " << sizes.transpose() << std::endl;
-    std::cout << "phi_x.sizes() = " << phi_x.sizes().transpose() << std::endl;
-#endif

     for (int c = 0; !xi.end(); ++xi, ++c)
     {
@@ -112,14 +101,6 @@

       auto p = Tensor_<T, N>{e - s};
       crop(p, infx, s, e);
-#ifdef DEBUG_IM2COL
-      std::cout << "p = " << xi.position().transpose() << std::endl;
-      std::cout << "s = " << s.transpose() << "    ";
-      std::cout << "e = " << e.transpose() << std::endl;
-      std::cout << "p.size() = " << p.size()
-                << " and col size = " << phi_x.matrix().col(c).size()
-                << std::endl;
-#endif
       phi_x.matrix().col(c) = p.vector();
     }

@@ -149,13 +130,13 @@
     k_sizes << kt_.sizes()[N - 1], kt_.sizes().head(N - 1);

     // Determine the sizes of the kernel.
-    const auto krows = std::accumulate(k_sizes.data() + 1, k_sizes.data() + N, 1,
-                                       std::multiplies<int>());
+    const auto krows = std::accumulate(k_sizes.data() + 1, k_sizes.data() + N,
+                                       1, std::multiplies<int>());
     const auto kcols = k_sizes[0];
     const auto kt = k_transposed.reshape(Vector2i{krows, kcols});

     // Calculate the feature maps for each nd-pixel.
-    k_sizes[0] = 1; // Rectify
+    k_sizes[0] = 1;  // Rectify
     const auto phi_x = im2row(x, k_sizes, padding, strides, offset);

     y.colmajor_view()                                                  //
@@ -174,8 +155,8 @@
   {
     // Determine the sizes of the kernel.
     const auto krows = k.sizes()(0);
-    const auto kcols = std::accumulate(k.sizes().data() + 1, k.sizes().data() + N, 1,
-                                       std::multiplies<int>());
+    const auto kcols = std::accumulate(
+        k.sizes().data() + 1, k.sizes().data() + N, 1, std::multiplies<int>());
     const auto k_ = k.reshape(Vector2i{krows, kcols});

     // Rectify the proper kernel sizes for im2col as we did for im2row.
@@ -187,9 +168,6 @@

     y.reshape(Vector2i{k_.matrix().rows(), phi_x.matrix().cols()}).matrix() =
         k_.matrix() * phi_x.matrix();
-
-    // SARA_CHECK(k_.sizes().transpose());
-    // SARA_CHECK(phi_x.sizes().transpose());
   }

   template <typename T, int N, typename Padding>
@@ -215,12 +193,11 @@
   }
   //! @}

-} /* namespace Sara */
-} /* namespace DO */
+}  // namespace DO::Sara

 // Useful examples and applications.
-namespace DO { namespace Sara {
+namespace DO::Sara {

   //!@ {
   //! Compute the size of the Gaussian kernel.
@@ -392,7 +369,8 @@
   //! A bit more generalized transposed convolution implementation.
   //! This implementation is simplified (centered, no strides, no offset).
   inline auto transposed_convolution(const Image<Rgb32f>& image,
-                                     const TensorView_<float, 4>& k) -> Image<Rgb32f>
+                                     const TensorView_<float, 4>& k)
+      -> Image<Rgb32f>
   {
     const auto h = image.height();
     const auto w = image.width();
@@ -464,5 +442,4 @@
     return out;
   }

-} /* namespace Sara */
-} /* namespace DO */
+}  // namespace DO::Sara


Add sanity check that direct-heap access has a heap bound

--- renderdoc/driver/d3d12/d3d12_replay.cpp
+++ renderdoc/driver/d3d12/d3d12_replay.cpp
@@ -1395,41 +1395,62 @@
       }
       if(curUsage->bindType == BindType::Sampler)
       {
-        D3D12Descriptor *desc =
-            (D3D12Descriptor *)samplerHeap->GetCPUDescriptorHandleForHeapStart().ptr;
-        desc += curUsage->descIndex;
-        element->samplers.push_back(D3D12Pipe::Sampler());
-        D3D12Pipe::Sampler &samp = element->samplers.back();
-        const D3D12_SAMPLER_DESC &sampDesc = desc->GetSampler();
-        FillSampler(samp, sampDesc);
-        samp.tableIndex = curUsage->descIndex;
-        element->dynamicallyUsedCount++;
+        if(samplerHeap)
+        {
+          D3D12Descriptor *desc =
+              (D3D12Descriptor *)samplerHeap->GetCPUDescriptorHandleForHeapStart().ptr;
+          desc += curUsage->descIndex;
+          element->samplers.push_back(D3D12Pipe::Sampler());
+          D3D12Pipe::Sampler &samp = element->samplers.back();
+          const D3D12_SAMPLER_DESC &sampDesc = desc->GetSampler();
+          FillSampler(samp, sampDesc);
+          samp.tableIndex = curUsage->descIndex;
+          element->dynamicallyUsedCount++;
+        }
+        else
+        {
+          RDCERR("Access to sampler heap detected with no sampler heap bound");
+        }
       }
       else if(curUsage->bindType == BindType::ConstantBuffer)
       {
-        D3D12Descriptor *desc =
-            (D3D12Descriptor *)resourceHeap->GetCPUDescriptorHandleForHeapStart().ptr;
-        desc += curUsage->descIndex;
-        element->constantBuffers.push_back(D3D12Pipe::ConstantBuffer());
-        D3D12Pipe::ConstantBuffer &cb = element->constantBuffers.back();
-
-        const D3D12_CONSTANT_BUFFER_VIEW_DESC &cbv = desc->GetCBV();
-        WrappedID3D12Resource::GetResIDFromAddr(cbv.BufferLocation, cb.resourceId, cb.byteOffset);
-        cb.resourceId = rm->GetOriginalID(cb.resourceId);
-        cb.byteSize = cbv.SizeInBytes;
-        cb.tableIndex = curUsage->descIndex;
-        element->dynamicallyUsedCount++;
+        if(resourceHeap)
+        {
+          D3D12Descriptor *desc =
+              (D3D12Descriptor *)resourceHeap->GetCPUDescriptorHandleForHeapStart().ptr;
+          desc += curUsage->descIndex;
+          element->constantBuffers.push_back(D3D12Pipe::ConstantBuffer());
+          D3D12Pipe::ConstantBuffer &cb = element->constantBuffers.back();
+
+          const D3D12_CONSTANT_BUFFER_VIEW_DESC &cbv = desc->GetCBV();
+          WrappedID3D12Resource::GetResIDFromAddr(cbv.BufferLocation, cb.resourceId, cb.byteOffset);
+          cb.resourceId = rm->GetOriginalID(cb.resourceId);
+          cb.byteSize = cbv.SizeInBytes;
+          cb.tableIndex = curUsage->descIndex;
+          element->dynamicallyUsedCount++;
+        }
+        else
+        {
+          RDCERR("Access to resource heap detected with no resource heap bound");
+        }
       }
       else
       {
-        D3D12Descriptor *desc =
-            (D3D12Descriptor *)resourceHeap->GetCPUDescriptorHandleForHeapStart().ptr;
-        desc += curUsage->descIndex;
-        D3D12Pipe::View view;
-        FillResourceView(view, desc);
-        view.tableIndex = curUsage->descIndex;
-        element->views.push_back(view);
-        element->dynamicallyUsedCount++;
+        if(resourceHeap)
+        {
+          D3D12Descriptor *desc =
+              (D3D12Descriptor *)resourceHeap->GetCPUDescriptorHandleForHeapStart().ptr;
+          desc += curUsage->descIndex;
+          D3D12Pipe::View view;
+          FillResourceView(view, desc);
+          view.tableIndex = curUsage->descIndex;
+          element->views.push_back(view);
+          element->dynamicallyUsedCount++;
+        }
+        else
+        {
+          RDCERR("Access to resource heap detected with no resource heap bound");
+        }
       }
       curUsage++;
     }


INTEGRATION: CWS oasis2 (1.39.4); FILE MERGED 2004/07/29 12:03:10 cl 1.39.4.1: #i31283# fixed settings import

--- xmloff/source/draw/sdxmlimp.cxx
+++ xmloff/source/draw/sdxmlimp.cxx
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: sdxmlimp.cxx,v $
  *
- *  $Revision: 1.39 $
- *
- *  last change: $Author: rt $ $Date: 2004-07-13 08:09:19 $
+ *  $Revision: 1.40 $
+ *
+ *  last change: $Author: rt $ $Date: 2004-08-20 08:14:15 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -429,8 +429,8 @@
 SERVICE( XMLImpressMetaImportOasis, "com.sun.star.comp.Impress.XMLOasisMetaImporter", "XMLImpressMetaImportOasis", sal_False, IMPORT_META )
 SERVICE( XMLDrawMetaImportOasis, "com.sun.star.comp.Draw.XMLOasisMetaImporter", "XMLImpressMetaImportOasis", sal_True, IMPORT_META )

-SERVICE( XMLImpressSettingsImportOasis, "com.sun.star.comp.Impress.XMLOasisSettingsImporter", "XMLImpressSettingsImportOasis", sal_False, IMPORT_META )
-SERVICE( XMLDrawSettingsImportOasis, "com.sun.star.comp.Draw.XMLOasisSettingsImporter", "XMLImpressSettingsImportOasis", sal_True, IMPORT_META )
+SERVICE( XMLImpressSettingsImportOasis, "com.sun.star.comp.Impress.XMLOasisSettingsImporter", "XMLImpressSettingsImportOasis", sal_False, IMPORT_SETTINGS )
+SERVICE( XMLDrawSettingsImportOasis, "com.sun.star.comp.Draw.XMLOasisSettingsImporter", "XMLImpressSettingsImportOasis", sal_True, IMPORT_SETTINGS )

 //////////////////////////////////////////////////////////////////////////////


Updated survey information for ladder 2 of SDD layer 3 (M. Poghosyan)

--- ITS/AliITSSurveyToAlign.cxx
+++ ITS/AliITSSurveyToAlign.cxx
@@ -269,12 +269,13 @@

   for(Int_t iMod=0; iMod<260; iMod++)
     {
+      //           printf("%d s=%s  x= %f  y= %f  z= %f\n",240+36+iMod, fsymnameSDDm[iMod].Data(),fxSDDm[iMod], fySDDm[iMod], fzSDDm[iMod] );
+
       new((*fAlignObjArray)[240+36+iMod]) AliAlignObjParams(fsymnameSDDm[iMod].Data(), fuidSDDm[iMod],
-					     fxSDDm[iMod], fySDDm[iMod], fzSDDm[iMod],
+					     fxSDDm[iMod]  , fySDDm[iMod]  , fzSDDm[iMod],
 					     fpsiSDDm[iMod], ftetSDDm[iMod], fphiSDDm[iMod], kFALSE);

-      //           printf("%d %s  %f  %f  %f\n",240+36+iMod, fsymnameSDDm[iMod].Data(),fxSDDm[iMod], fySDDm[iMod], fzSDDm[iMod] );
-
+
           if(!fsymnameSDDm[iMod].Contains("SDD") || !fsymnameSDDm[iMod].Contains("Sensor"))
 	    {
 	  AliError("SDD Module array is not initialized correctly\n");
@@ -316,14 +317,34 @@
     Int_t iLayer, iLadder, iModule, iPoint;
     ReadPointNameSDD(pt->GetName(),iLayer, iLadder, iModule, iPoint);

-    if(iModule==iModule0)
-    {
-      fSDDmeP[iPoint][0]=pt->GetX();
-      fSDDmeP[iPoint][1]=pt->GetY();
-      fSDDmeP[iPoint][2]=pt->GetZ();
-      fSDDmeP[iPoint][3]=pt->GetPrecisionX();
-      fSDDmeP[iPoint][4]=pt->GetPrecisionY();
-      fSDDmeP[iPoint][5]=pt->GetPrecisionZ();
+      Double_t x =pt->GetX();
+      Double_t y =pt->GetY();
+      Double_t z =pt->GetZ();
+      Double_t xE=pt->GetPrecisionX();
+      Double_t yE=pt->GetPrecisionY();
+      //      Double_t zE=pt->GetPrecisionZ();
+
+         if(iLayer==3 && iLadder==2)
+      	{
+      	  if(iPoint<3) iPoint+=3;
+      	  else if(iPoint>2) iPoint-=3;
+      	  iModule=TMath::Abs(iModule - 5);
+      	  x=500-x;
+      	  y*=-1;
+      	}
+
+
+      iModuleIndex = AliITSgeomTGeo::GetModuleIndex(iLayer0,iLadder0+1,iModule0+1);
+      Int_t iModuleIndex1 = AliITSgeomTGeo::GetModuleIndex(iLayer,iLadder+1,iModule+1);
+
+    if(iModuleIndex==iModuleIndex1)
+    {
+      fSDDmeP[iPoint][0]=x;
+      fSDDmeP[iPoint][1]=y;
+      fSDDmeP[iPoint][2]=z;
+      fSDDmeP[iPoint][3]=xE;
+      fSDDmeP[iPoint][4]=yE;
+      fSDDmeP[iPoint][5]=xE;
       fSDDisMe[iPoint]=kTRUE;

       if(iLayer==3) uid = AliGeomManager::LayerToVolUID(iLayer0,iModuleIndex-240);
@@ -331,30 +352,35 @@
       symname = AliGeomManager::SymName(uid);
       GetIdPosSDD(uid,iLayer0, iModule0, iPoint);
       nModules++;
+
+
+      //      printf("%s\n",pt->GetName());
+      //      printf("Me: %7.4f  %7.4f  %7.4f\n", fSDDmeP[iPoint][0], fSDDmeP[iPoint][1], fSDDmeP[iPoint][2]);
+      //      printf("Id: %7.4f  %7.4f  %7.4f\n", fSDDidP[iPoint][0], fSDDidP[iPoint][1], fSDDidP[iPoint][2]);
     }
+
     //    cout << "Points red module " << imod << endl;
-    if((iModule!=iModule0)||(imod==(fSurveyPoints->GetEntries()-1)))
+    if((iModuleIndex!=iModuleIndex1)||(imod==(fSurveyPoints->GetEntries()-1)))
     {
       ConvertToRSofModulesAndRotSDD(iLayer0, iModule0);

       Double_t tet = 0.;
-      Double_t psi =0.;
+      Double_t psi = 0.;
       Double_t phi = 0.;
       Double_t x0  = 0.;
-      Double_t y0  =0.;
+      Double_t y0  = 0.;
       Double_t z0  = 0.;

       if(nModules==2) CalcShiftSDD(x0,y0,z0);
       if(nModules>2)   CalcShiftRotSDD(tet, psi, phi, x0, y0, z0);
+      //          printf("%s  %d  %f  %f  %f  %f  %f  %f\n",symname, uid, x0/10., y0/10., z0/10., psi, tet, phi);
       tet*=kRadToDeg;
       psi*=kRadToDeg;
       phi*=kRadToDeg;
-
-//    printf("%s  %d  %f  %f  %f  %f  %f  %f\n",symname, uid, x0/10., y0/10., z0/10., psi, tet, phi);
 //      cout << "Allocate alignobjparams " << imod << endl;
-
 //      new((*fAlignObjArray)[iModuleIndex]) AliAlignObjParams(symname, uid, x0/10., y0/10., z0/10., psi, tet, phi, kFALSE);
 //       printf("INDEX:   Module: %d\n",iModuleIndex);
+

       fsymnameSDDm[iModuleIndex-240]=TString(symname);
       fuidSDDm[iModuleIndex-240]=uid;
@@ -364,20 +390,19 @@
       fpsiSDDm[iModuleIndex-240]=psi;
       ftetSDDm[iModuleIndex-240]=tet;
       fphiSDDm[iModuleIndex-240]=phi;
-
       //      new((*fAlignObjArray)[36+iModuleIndex]) AliAlignObjParams(fsymnameSDDm[iModuleIndex-240].Data(), fuidSDDm[iModuleIndex-240],
       //					     fxSDDm[iModuleIndex-240], fySDDm[iModuleIndex-240], fzSDDm[iModuleIndex-240],
       //					     fpsiSDDm[iModuleIndex-240], ftetSDDm[iModuleIndex-240], fphiSDDm[iModuleIndex-240], kFALSE);
-
       iModule0=iModule;
       iLayer0=iLayer;
       iLadder0=iLadder;
       nModules=0;
-      iModuleIndex = AliITSgeomTGeo::GetModuleIndex(iLayer,iLadder+1,iModule+1);
+      //      iModuleIndex = AliITSgeomTGeo::GetModuleIndex(iLayer,iLadder+1,iModule+1);
       for(Int_t i=0; i<6;i++) fSDDisMe[i]=kFALSE;
       if(imod!=(fSurveyPoints->GetEntries()-1)) imod--;
     }
   }//module loop
+  printf("done\n");
 }

 //______________________________________________________________________
@@ -543,7 +568,7 @@
       fsymnameSDDl[iLadd]=TString(ladName);
       fuidSDDl[iLadd]=0;
       fxSDDl[iLadd]=0;
-      fySDDl[iLadd]=10;
+      fySDDl[iLadd]=0;
       fzSDDl[iLadd]=0;
       fpsiSDDl[iLadd]=0;
       ftetSDDl[iLadd]=0;
@@ -595,52 +620,6 @@
 a->CreateAlignObjs();
 */

-//  Int_t type =0;
-  ////////////////////////////////////////////////////////////
-  // pRB2X[layer][ladder][dx,dy,dz]
-  Double_t pRB24[2][22][3]; //(mm)
-  Double_t pRB26[2][22][3]; //(mm)
-
-
-pRB24[0][0][2] = 0.0228; pRB26[0][0][2] = 0.0284; pRB24[0][0][0] =-0.0377; pRB26[0][0][0] =-0.0008; pRB24[0][0][1] =-0.0336; pRB26[0][0][1] = 0.0540;
-pRB24[0][1][2] =-0.0175; pRB26[0][1][2] =-0.0186; pRB24[0][1][0] =-0.0143; pRB26[0][1][0] = 0.0348; pRB24[0][1][1] =-0.0123; pRB26[0][1][1] = 0.0407;
-pRB24[0][2][2] = 0.1313; pRB26[0][2][2] = 0.0302; pRB24[0][2][0] = 0.2408; pRB26[0][2][0] = 0.1113; pRB24[0][2][1] =-0.0150; pRB26[0][2][1] =-0.0194;
-pRB24[0][3][2] = 0.0307; pRB26[0][3][2] = 0.0350; pRB24[0][3][0] = 0.1140; pRB26[0][3][0] = 0.0952; pRB24[0][3][1] =-0.0423; pRB26[0][3][1] =-0.0375;
-pRB24[0][4][2] =-0.0159; pRB26[0][4][2] = 0.0185; pRB24[0][4][0] = 0.0713; pRB26[0][4][0] = 0.0803; pRB24[0][4][1] =-0.1311; pRB26[0][4][1] =-0.1201;
-pRB24[0][5][2] =-0.0128; pRB26[0][5][2] =-0.0209; pRB24[0][5][0] = 0.0436; pRB26[0][5][0] = 0.0606; pRB24[0][5][1] =-0.1551; pRB26[0][5][1] =-0.0587;
-pRB24[0][6][2] =-0.0257; pRB26[0][6][2] =-0.0044; pRB24[0][6][0] = 0.0380; pRB26[0][6][0] = 0.0264; pRB24[0][6][1] =-0.1913; pRB26[0][6][1] =-0.1851;
-pRB24[0][7][2] = 0.0185; pRB26[0][7][2] = 0.1450; pRB24[0][7][0] =-0.0406; pRB26[0][7][0] =-0.0426; pRB24[0][7][1] = 0.1564; pRB26[0][7][1] = 0.2998;
-pRB24[0][8][2] = 0.0048; pRB26[0][8][2] = 0.0077; pRB24[0][8][0] = 0.0290; pRB26[0][8][0] = 0.0361; pRB24[0][8][1] = 0.1321; pRB26[0][8][1] = 0.1679;
-pRB24[0][9][2] = 0.0049; pRB26[0][9][2] = 0.0115; pRB24[0][9][0] = 0.0405; pRB26[0][9][0] = 0.1058; pRB24[0][9][1] = 0.0319; pRB26[0][9][1] = 0.2464;
-pRB24[0][10][2]=-0.0017; pRB26[0][10][2]= 0.0100; pRB24[0][10][0]= 0.0724; pRB26[0][10][0]= 0.1035; pRB24[0][10][1]= 0.0561; pRB26[0][10][1]= 0.0713;
-pRB24[0][11][2]=-0.0021; pRB26[0][11][2]= 0.0202; pRB24[0][11][0]= 0.0590; pRB26[0][11][0]= 0.0596; pRB24[0][11][1]=-0.0875; pRB26[0][11][1]=-0.0591;
-pRB24[0][12][2]=-0.0200; pRB26[0][12][2]= 0.0242; pRB24[0][12][0]= 0.0664; pRB26[0][12][0]= 0.0780; pRB24[0][12][1]=-0.0197; pRB26[0][12][1]=-0.0227;
-pRB24[0][13][2]=-0.0382; pRB26[0][13][2]=-0.0139; pRB24[0][13][0]=-0.0320; pRB26[0][13][0]=-0.0136; pRB24[0][13][1]=-0.0798; pRB26[0][13][1]=-0.0843;
-pRB24[1][0][2] = 0.0191; pRB26[1][0][2] = 0.0295; pRB24[1][0][0] =-0.0776; pRB26[1][0][0] =-0.0585; pRB24[1][0][1] =-0.0148; pRB26[1][0][1] = 0.0123;
-pRB24[1][1][2] = 0.0135; pRB26[1][1][2] = 0.0074; pRB24[1][1][0] =-0.0289; pRB26[1][1][0] =-0.0213; pRB24[1][1][1] = 0.0064; pRB26[1][1][1] = 0.0289;
-pRB24[1][2][2] = 0.0096; pRB26[1][2][2] = 0.0011; pRB24[1][2][0] = 0.0123; pRB26[1][2][0] = 0.0404; pRB24[1][2][1] =-0.0246; pRB26[1][2][1] =-0.0064;
-pRB24[1][3][2] = 0.0209; pRB26[1][3][2] =-0.0049; pRB24[1][3][0] = 0.0322; pRB26[1][3][0] = 0.0447; pRB24[1][3][1] = 0.0066; pRB26[1][3][1] = 0.0284;
-pRB24[1][4][2] = 0.0149; pRB26[1][4][2] =-0.0033; pRB24[1][4][0] = 0.0530; pRB26[1][4][0] = 0.0822; pRB24[1][4][1] =-0.0455; pRB26[1][4][1] =-0.0365;
-pRB24[1][5][2] = 0.0395; pRB26[1][5][2] = 0.0094; pRB24[1][5][0] = 0.0633; pRB26[1][5][0] = 0.0933; pRB24[1][5][1] =-0.1133; pRB26[1][5][1] =-0.1070;
-pRB24[1][6][2] = 0.0288; pRB26[1][6][2] =-0.0002; pRB24[1][6][0] = 0.0692; pRB26[1][6][0] = 0.0916; pRB24[1][6][1] =-0.1670; pRB26[1][6][1] =-0.1670;
-pRB24[1][7][2] = 0.0238; pRB26[1][7][2] =-0.0090; pRB24[1][7][0] = 0.0625; pRB26[1][7][0] = 0.0607; pRB24[1][7][1] =-0.1592; pRB26[1][7][1] =-0.1678;
-pRB24[1][8][2] = 0.0196; pRB26[1][8][2] =-0.0738; pRB24[1][8][0] = 0.0639; pRB26[1][8][0] = 0.0686; pRB24[1][8][1] =-0.2050; pRB26[1][8][1] =-0.2056;
-pRB24[1][9][2] = 0.0029; pRB26[1][9][2] =-0.0051; pRB24[1][9][0] = 0.0178; pRB26[1][9][0] = 0.0170; pRB24[1][9][1] =-0.1042; pRB26[1][9][1] =-0.1159;
-pRB24[1][10][2]=-0.0108; pRB26[1][10][2]=-0.0023; pRB24[1][10][0]=-0.0005; pRB26[1][10][0]= 0.0119; pRB24[1][10][1]=-0.1353; pRB26[1][10][1]=-0.1461;
-pRB24[1][11][2]=-0.0131; pRB26[1][11][2]=-0.0233; pRB24[1][11][0]=-0.0202; pRB26[1][11][0]=-0.0242; pRB24[1][11][1]=-0.1883; pRB26[1][11][1]=-0.2031;
-pRB24[1][12][2]= 0.0028; pRB26[1][12][2]= 0.0036; pRB24[1][12][0]=-0.0066; pRB26[1][12][0]= 0.0011; pRB24[1][12][1]= 0.2024; pRB26[1][12][1]= 0.2382;
-pRB24[1][13][2]= 0.0111; pRB26[1][13][2]= 0.0029; pRB24[1][13][0]= 0.0283; pRB26[1][13][0]= 0.0287; pRB24[1][13][1]= 0.2057; pRB26[1][13][1]= 0.2384;
-pRB24[1][14][2]= 0.0140; pRB26[1][14][2]=-0.0657; pRB24[1][14][0]= 0.0682; pRB26[1][14][0]= 0.0825; pRB24[1][14][1]= 0.1650; pRB26[1][14][1]= 0.2545;
-pRB24[1][15][2]= 0.0263; pRB26[1][15][2]=-0.0013; pRB24[1][15][0]= 0.0909; pRB26[1][15][0]= 0.0709; pRB24[1][15][1]= 0.1093; pRB26[1][15][1]= 0.1321;
-pRB24[1][16][2]= 0.0025; pRB26[1][16][2]=-0.0045; pRB24[1][16][0]= 0.0672; pRB26[1][16][0]= 0.0955; pRB24[1][16][1]= 0.0745; pRB26[1][16][1]= 0.0901;
-pRB24[1][17][2]= 0.0060; pRB26[1][17][2]= 0.0035; pRB24[1][17][0]= 0.0664; pRB26[1][17][0]= 0.0739; pRB24[1][17][1]= 0.0471; pRB26[1][17][1]= 0.0598;
-pRB24[1][18][2]=-0.0124; pRB26[1][18][2]=-0.0168; pRB24[1][18][0]= 0.0710; pRB26[1][18][0]= 0.0866; pRB24[1][18][1]= 0.0123; pRB26[1][18][1]= 0.0237;
-pRB24[1][19][2]=-0.0125; pRB26[1][19][2]=-0.0178; pRB24[1][19][0]= 0.0433; pRB26[1][19][0]= 0.0535; pRB24[1][19][1]= 0.0234; pRB26[1][19][1]= 0.0262;
-pRB24[1][20][2]=-0.0021; pRB26[1][20][2]= 0.0100; pRB24[1][20][0]= 0.0213; pRB26[1][20][0]= 0.0394; pRB24[1][20][1]= 0.0734; pRB26[1][20][1]= 0.0677;
-pRB24[1][21][2]=-0.0490; pRB26[1][21][2]=-0.0222; pRB24[1][21][0]=-0.0269; pRB26[1][21][0]=-0.0039; pRB24[1][21][1]= 0.0160; pRB26[1][21][1]= 0.0076;
-
-
-
   Int_t iLadd = 0;

   for (Int_t ilayer =  0; ilayer <  2; ilayer ++)
@@ -653,8 +632,6 @@
       ladName += (ilayer+2);
       ladName += "/Ladder";
       ladName += iLadder;
-      Double_t drLoc[3];
-      //      for(Int_t i=0; i<3; i++) drLoc[i]=(pRB26[ilayer][iLadder][i]+pRB24[ilayer][iLadder][i])/20.; // average

       /////////////////////////////////////////////////////////////////////////////
@@ -677,7 +654,6 @@
       if (tmpStr.Atoi() != ladder)
 	AliError(Form("Survey data file error. Expect pairs of RB24, RB26 points. Got ladders %d %d",ladder,tmpStr.Atoi()));

-      for(Int_t i=0; i<3; i++) drLoc[i]=pRB24[ilayer][iLadder][i]/10.;

       Double_t x24, y24, z24;
       Double_t x26, y26, z26;
@@ -710,7 +686,6 @@
       theta*= kRadToDeg;
       psi*= kRadToDeg;

-      AliDebug(1,Form("ladname %f %f %f %f %f %f ",drLoc[0],drLoc[1],drLoc[2],psi,theta,phi));
       // local delta transformation by passing 3 shifts (in centimeters) and 3 angles (expressed in degrees)
       //      new((*fAlignObjArray)[500+1698+144+iLadd]) AliAlignObjParams(ladName,0,drLoc[0],drLoc[1],drLoc[2],psi,theta,phi,kFALSE);
       fsymnameSDDl[iLadd]=TString(ladName);
@@ -889,6 +864,15 @@
   ///ALIC_1/ITSV_1/ITSsddLayer4_1/ITSsddLadd_16
   //  gLad.Print();
   //  printf("%s  : Module# %d  Point# %d\n",ladderPath.Data(), module, iPoint);
+
+  if((layer==3)&&(module<3)) rel.LocalToMaster(fgkLocR[1],fSDDidP[1]);
+  if((layer==3)&&(module>2)) rel.LocalToMaster(fgkLocL[1],fSDDidP[1]);
+  if((layer==4)&&(module<4)) rel.LocalToMaster(fgkLocR[1],fSDDidP[1]);
+  if((layer==4)&&(module>3)) rel.LocalToMaster(fgkLocL[1],fSDDidP[1]);
+  for(Int_t i=0; i<3; i++) fSDDidP[1][i]*=10;
+  fSDDidP[1][2]-=0.5205;
+
+  //  rel.LocalToMaster(fgkLocR[1],fSDDidP[1]);
   //  printf("ID   {%f, %f, %f}\n", fSDDidP[iPoint][0],fSDDidP[iPoint][1],fSDDidP[iPoint][2]);
   //  printf("Me   {%f, %f, %f}\n", fSDDmeP[iPoint][0],fSDDmeP[iPoint][1],fSDDmeP[iPoint][2]);
   //  }
@@ -990,7 +974,6 @@
   if((str[25+ord]=='L')&&(str[26+ord]=='C')) iPoint=4;
   if((str[25+ord]=='L')&&(str[26+ord]=='D')) iPoint=5;

-
   return;
 }

@@ -1013,12 +996,16 @@
   Double_t x0=fSDDidP[1][0];
   Double_t z0=fSDDidP[1][2];//-0.5205;
   //  Double_t z0=fSDDidP[1][2]-0.5;
+  //  printf("x0= %f   z0= %f \n",x0,z0);
   for(Int_t i=0; i<6; i++)
     {
       //      fSDDidP[i][2]-=0.5205;
       //      fSDDidP[i][2]-=0.5;

       if(!fSDDisMe[i]) continue;
+
+      //      printf("Me1_0: %d:  %f  %f  %f\n",i, fSDDmeP[i][0], fSDDmeP[i][1], fSDDmeP[i][2]);
+      //      printf("Id1_0: %d:  %f  %f  %f\n",i, fSDDidP[i][0], fSDDidP[i][1], fSDDidP[i][2]);

       fSDDidP[i][0]-=x0;
       fSDDidP[i][2]-=z0;
@@ -1053,6 +1040,9 @@
 	  fSDDmeP[i][0]*=(-1);
 	  fSDDmeP[i][2]*=(-1);
 	}
+      //      printf("Me1_1: %d:  %f  %f  %f\n",i, fSDDmeP[i][0], fSDDmeP[i][1], fSDDmeP[i][2] );
+      //      printf("Id1_1: %d:  %f  %f  %f\n",i, fSDDidP[i][0], fSDDidP[i][1], fSDDidP[i][2]);
+
     }
 }

@@ -1093,6 +1083,18 @@
   x0=x1;
   y0=x2;
   z0=x3;
+
+
+  for(Int_t iP1=0; iP1<=6; iP1++)
+    {
+      if(!fSDDisMe[iP1]) continue;
+
+      //      printf("%d Me: %6.3f  %6.3f  %6.3f\n",iP1, fSDDmeP[iP1][0], fSDDmeP[iP1][1], fSDDmeP[iP1][2]);
+      //      printf("%d Id: %6.3f  %6.3f  %6.3f\n",iP1, fSDDidP[iP1][0], fSDDidP[iP1][1], fSDDidP[iP1][2]);
+
+    }
+
+
   return;
 }

@@ -1135,7 +1137,10 @@
       yMe= fSDDmeP[iP1][1];
       zMe= fSDDmeP[iP1][2];

-
+      //      printf("Me1: %d:  %f  %f  %f\n",iP1, xMe, yMe, zMe );
+      //      printf("MeE: %d:  %f  %f  %f\n",iP1, fSDDmeP[iP1][3], fSDDmeP[iP1][4], fSDDmeP[iP1][5] );
+      //      printf("Id1: %d:  %f  %f  %f\n",iP1, xId, yId, zId );
+      //      printf("Res: %d:  %f  %f  %f\n",iP1, xMe-xId, yMe-yId, zMe-zId );

       //squared precisions of measured x,y,z for fiducial mark iP1
       sX2 = fSDDmeP[iP1][3]* fSDDmeP[iP1][3];
@@ -1143,6 +1148,7 @@
       sZ2 = fSDDmeP[iP1][5]* fSDDmeP[iP1][5];

       a[0][0]+=(zId*zId/sX2+xId*xId/sZ2);
+      //      printf("%f\n",a[0][0]);
       a[0][1]-=(zId*yId/sX2);
       a[0][2]-=(xId*yId/sZ2);
       a[0][3]-=(zId/sX2);
@@ -1255,5 +1261,20 @@
   x0=x4;
   y0=x5;
   z0=x6;
+
+  //  for(Int_t i=0; i<6; i++)
+    //  printf("%f  %f  %f  %f  %f  %f\n",a[i][0], a[i][1], a[i][2], a[i][3], a[i][4], a[i][5]);
+
+  //  pC.Print();
+  //  p1.Print();
+  //  p2.Print();
+  //  p3.Print();
+  //  p4.Print();
+  //  p5.Print();
+  //  p6.Print();
+
+
+  //  printf("fit: %f  %f  %f  %f  %f  %f\n",x0, y0, z0, tet, psi, phi);
+
   return;
 }


INTEGRATION: CWS basemodelrefactoring (1.23.62); FILE MERGED 2007/05/29 11:21:45 mba 1.23.62.2: RESYNC: (1.23-1.24); FILE MERGED 2007/03/23 22:35:38 mba 1.23.62.1: #i26672#: CharLocale property now named Language

--- xmloff/source/meta/xmlmetai.cxx
+++ xmloff/source/meta/xmlmetai.cxx
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: xmlmetai.cxx,v $
  *
- *  $Revision: 1.25 $
- *
- *  last change: $Author: hr $ $Date: 2007-06-27 15:19:39 $
+ *  $Revision: 1.26 $
+ *
+ *  last change: $Author: obo $ $Date: 2007-07-17 12:59:16 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -98,7 +98,7 @@
 #define PROP_EDITINGCYCLES  "EditingCycles"
 #define PROP_EDITINGDURATION "EditingDuration"

-#define PROP_CHARLOCALE     "CharLocale"
+#define PROP_CHARLOCALE     "Language"
 #define PROP_DOCSTATISTIC   "DocumentStatistic"

 //-------------------------------------------------------------------------


ERR: fix a segfault that occurs when using a stencil with nearest-neighbor interpolation

--- Imaging/vtkImageReslice.cxx
+++ Imaging/vtkImageReslice.cxx
@@ -24,7 +24,7 @@
 #include <float.h>
 #include <math.h>

-vtkCxxRevisionMacro(vtkImageReslice, "1.40.2.1");
+vtkCxxRevisionMacro(vtkImageReslice, "1.40.2.2");
 vtkStandardNewMacro(vtkImageReslice);
 vtkCxxSetObjectMacro(vtkImageReslice, InformationInput, vtkImageData);
 vtkCxxSetObjectMacro(vtkImageReslice,ResliceAxes,vtkMatrix4x4);
@@ -2594,7 +2594,7 @@
           }
         else // optimize for nearest-neighbor interpolation
           {
-          for (int iidX = r1; iidX <= r2; iidX++)
+          for (int iidX = idXmin; iidX <= idXmax; iidX++)
             {
             inPoint[0] = inPoint1[0] + iidX*xAxis[0];
             inPoint[1] = inPoint1[1] + iidX*xAxis[1];


Removed error dialog when texture file does not exist

--- xs/src/slic3r/GUI/GLTexture.cpp
+++ xs/src/slic3r/GUI/GLTexture.cpp
@@ -3,6 +3,8 @@
 #include <GL/glew.h>

 #include <wx/image.h>
+
+#include <boost/filesystem.hpp>

 #include <vector>
 #include <algorithm>
@@ -26,6 +28,9 @@
 bool GLTexture::load_from_file(const std::string& filename, bool generate_mipmaps)
 {
     reset();
+
+    if (!boost::filesystem::exists(filename))
+        return false;

     // Load a PNG with an alpha channel.
     wxImage image;


tidy up.

tidy up.

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

--- lib/Analysis/DebugInfo.cpp
+++ lib/Analysis/DebugInfo.cpp
@@ -32,7 +32,7 @@
 // DIDescriptor
 //===----------------------------------------------------------------------===//

-StringRef
+StringRef
 DIDescriptor::getStringField(unsigned Elt) const {
   if (DbgNode == 0)
     return StringRef();
@@ -60,7 +60,8 @@
     return DIDescriptor();

   if (Elt < DbgNode->getNumOperands())
-    return DIDescriptor(dyn_cast_or_null<const MDNode>(DbgNode->getOperand(Elt)));
+    return
+      DIDescriptor(dyn_cast_or_null<const MDNode>(DbgNode->getOperand(Elt)));
   return DIDescriptor();
 }

@@ -353,7 +354,7 @@
 bool DILocation::Verify() const {
   if (!DbgNode)
     return false;
-
+
   return DbgNode->getNumOperands() == 4;
 }

@@ -376,7 +377,7 @@
       Tag == dwarf::DW_TAG_const_type || Tag == dwarf::DW_TAG_volatile_type ||
       Tag == dwarf::DW_TAG_restrict_type) {
     DIType BaseType = getTypeDerivedFrom();
-    // If this type is not derived from any type then take conservative
+    // If this type is not derived from any type then take conservative
     // approach.
     if (!BaseType.isValid())
       return getSizeInBits();
@@ -385,17 +386,17 @@
     else
       return BaseType.getSizeInBits();
   }
-
+
   return getSizeInBits();
 }

-/// isInlinedFnArgument - Return trule if this variable provides debugging
+/// isInlinedFnArgument - Return true if this variable provides debugging
 /// information for an inlined function arguments.
 bool DIVariable::isInlinedFnArgument(const Function *CurFn) {
   assert(CurFn && "Invalid function");
   if (!getContext().isSubprogram())
     return false;
-  // This variable is not inlined function argument if its scope
+  // This variable is not inlined function argument if its scope
   // does not describe current function.
   return !(DISubprogram(getContext()).describes(CurFn));
 }
@@ -414,7 +415,7 @@
   return false;
 }

-unsigned DISubprogram::isOptimized() const     {
+unsigned DISubprogram::isOptimized() const {
   assert (DbgNode && "Invalid subprogram descriptor!");
   if (DbgNode->getNumOperands() == 16)
     return getUnsignedField(15);
@@ -424,7 +425,7 @@
 StringRef DIScope::getFilename() const {
   if (!DbgNode)
     return StringRef();
-  if (isLexicalBlock())
+  if (isLexicalBlock())
     return DILexicalBlock(DbgNode).getFilename();
   if (isSubprogram())
     return DISubprogram(DbgNode).getFilename();
@@ -443,7 +444,7 @@
 StringRef DIScope::getDirectory() const {
   if (!DbgNode)
     return StringRef();
-  if (isLexicalBlock())
+  if (isLexicalBlock())
     return DILexicalBlock(DbgNode).getDirectory();
   if (isSubprogram())
     return DISubprogram(DbgNode).getDirectory();
@@ -978,8 +979,8 @@
 }

 /// CreateSubprogramDefinition - Create new subprogram descriptor for the
-/// given declaration.
-DISubprogram DIFactory::CreateSubprogramDefinition(DISubprogram &SPDeclaration) {
+/// given declaration.
+DISubprogram DIFactory::CreateSubprogramDefinition(DISubprogram &SPDeclaration){
   if (SPDeclaration.isDefinition())
     return DISubprogram(SPDeclaration);

@@ -1087,7 +1088,7 @@
                                             const std::string &Name,
                                             DIFile F,
                                             unsigned LineNo,
-                                            DIType Ty,
+                                            DIType Ty,
                                             SmallVector<Value *, 9> &addr) {
   SmallVector<Value *, 9> Elts;
   Elts.push_back(GetTagConstant(Tag));
@@ -1177,7 +1178,7 @@

   // If this block already has a terminator then insert this intrinsic
   // before the terminator.
-  if (TerminatorInst *T = InsertAtEnd->getTerminator())
+  if (TerminatorInst *T = InsertAtEnd->getTerminator())
     return CallInst::Create(DeclareFn, Args, Args+2, "", T);
   else
     return CallInst::Create(DeclareFn, Args, Args+2, "", InsertAtEnd);}
@@ -1206,7 +1207,7 @@
   if (!ValueFn)
     ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value);

-  Value *Args[] = { MDNode::get(V->getContext(), &V, 1),
+  Value *Args[] = { MDNode::get(V->getContext(), &V, 1),
                     ConstantInt::get(Type::getInt64Ty(V->getContext()), Offset),
                     D };
   return CallInst::Create(ValueFn, Args, Args+3, "", InsertAtEnd);
@@ -1224,21 +1225,21 @@
            ++BI) {
         if (DbgDeclareInst *DDI = dyn_cast<DbgDeclareInst>(BI))
           processDeclare(DDI);
-
+
         DebugLoc Loc = BI->getDebugLoc();
         if (Loc.isUnknown())
           continue;
-
+
         LLVMContext &Ctx = BI->getContext();
         DIDescriptor Scope(Loc.getScope(Ctx));
-
+
         if (Scope.isCompileUnit())
           addCompileUnit(DICompileUnit(Scope));
         else if (Scope.isSubprogram())
           processSubprogram(DISubprogram(Scope));
         else if (Scope.isLexicalBlock())
           processLexicalBlock(DILexicalBlock(Scope));
-
+
         if (MDNode *IA = Loc.getInlinedAt(Ctx))
           processLocation(DILocation(IA));
       }
@@ -1396,16 +1397,16 @@
 /// It looks through pointer casts too.
 static const DbgDeclareInst *findDbgDeclare(const Value *V) {
   V = V->stripPointerCasts();
-
+
   if (!isa<Instruction>(V) && !isa<Argument>(V))
     return 0;
-
+
   const Function *F = NULL;
   if (const Instruction *I = dyn_cast<Instruction>(V))
     F = I->getParent()->getParent();
   else if (const Argument *A = dyn_cast<Argument>(V))
     F = A->getParent();
-
+
   for (Function::const_iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI)
     for (BasicBlock::const_iterator BI = (*FI).begin(), BE = (*FI).end();
          BI != BE; ++BI)
@@ -1463,10 +1464,10 @@
   DIDescriptor D(Scope);
   if (D.isSubprogram())
     return DISubprogram(Scope);
-
+
   if (D.isLexicalBlock())
     return getDISubprogram(DILexicalBlock(Scope).getContext());
-
+
   return DISubprogram();
 }

@@ -1474,9 +1475,9 @@
 DICompositeType llvm::getDICompositeType(DIType T) {
   if (T.isCompositeType())
     return DICompositeType(T);
-
+
   if (T.isDerivedType())
     return getDICompositeType(DIDerivedType(T).getTypeDerivedFrom());
-
+
   return DICompositeType();
 }


Count CallInsts correctly, remove unneccesary initializers
S: ----------------------------------------------------------------------

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

--- lib/Analysis/InstCount.cpp
+++ lib/Analysis/InstCount.cpp
@@ -74,7 +74,7 @@
     inline void visitBranchInst(BranchInst &I) { NumBranchInst++; }
     inline void visitPHINode(PHINode &I) { NumPHINode++; }
     inline void visitCastInst (CastInst &I) { NumCastInst++; }
-    inline void visitCallInst (CallInst &I) { NumCastInst++; }
+    inline void visitCallInst (CallInst &I) { NumCallInst++; }
     inline void visitMallocInst(MallocInst &I) { NumMallocInst++; }
     inline void visitAllocaInst(AllocaInst &I) { NumAllocaInst++; }
     inline void visitFreeInst  (FreeInst   &I) { NumFreeInst++; }
@@ -95,8 +95,8 @@
     }
   };

-  RegisterOpt<InstCount> X("instcount",
-			   "Counts the various types of Instructions");
+  RegisterAnalysis<InstCount> X("instcount",
+		    	   "Counts the various types of Instructions");

 }

@@ -108,40 +108,6 @@
 // function.
 //
 bool InstCount::run(Module &M) {
-    /* Initialization */
-  NumReturnInst = 0;
-  NumBranchInst = 0;
-  NumPHINode = 0;
-  NumCastInst = 0;
-  NumCallInst = 0;
-  NumMallocInst = 0;
-  NumAllocaInst = 0;
-  NumFreeInst = 0;
-  NumLoadInst = 0;
-  NumStoreInst = 0;
-  NumGetElementPtrInst = 0;
-  NumSwitchInst = 0;
-  NumInvokeInst = 0;
-  NumBinaryOperator = 0;
-  NumShiftInst = 0;
-  NumShlInst = 0;
-  NumShrInst = 0;
-  NumAddInst = 0;
-  NumSubInst = 0;
-  NumMulInst = 0;
-  NumDivInst = 0;
-  NumRemInst = 0;
-  NumAndInst = 0;
-  NumOrInst = 0;
-  NumXorInst = 0;
-  NumSetCondInst = 0;
-  NumSetEQInst = 0;
-  NumSetNEInst = 0;
-  NumSetLEInst = 0;
-  NumSetGEInst = 0;
-  NumSetLTInst = 0;
-  NumSetGTInst = 0;
-
   for (Module::iterator mI = M.begin(), mE = M.end(); mI != mE; ++mI)
     for (inst_iterator I = inst_begin(*mI), E = inst_end(*mI); I != E; ++I)
       visit(*I);


Eat the alignment keyword if we're in an attribute group.

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

--- lib/AsmParser/LLParser.cpp
+++ lib/AsmParser/LLParser.cpp
@@ -878,6 +878,7 @@
       // 2".
       unsigned Alignment;
       if (inAttrGrp) {
+        Lex.Lex();
         if (ParseToken(lltok::equal, "expected '=' here") ||
             ParseUInt32(Alignment))
           return true;
@@ -891,6 +892,7 @@
     case lltok::kw_alignstack: {
       unsigned Alignment;
       if (inAttrGrp) {
+        Lex.Lex();
         if (ParseToken(lltok::equal, "expected '=' here") ||
             ParseUInt32(Alignment))
           return true;


Fixed sign error in SIN/COS instructions

--- fpu/fpu_trig.cc
+++ fpu/fpu_trig.cc
@@ -169,6 +169,7 @@
   floatx80 y = BX_READ_FPU_REG(0);

   /* reduce trigonometric function argument */
+  int sign = floatx80_sign(y);
   Bit64u quotient = trig_arg_reduction(y, F_SIN, status);
   if (quotient == -1)
   {
@@ -185,6 +186,9 @@

       return;
   }
+
+  if (sign)
+      quotient = (Bit64u)(-quotient);

   if (handle_small_argument(y, quotient))
   {
@@ -225,7 +229,7 @@
   floatx80 y = BX_READ_FPU_REG(0);

   /* reduce trigonometric function argument */
-  Bit64u quotient = trig_arg_reduction(y, F_COS, status);
+  Bit64u quotient = trig_arg_reduction(floatx80_abs(y), F_COS, status);
   if (quotient == -1)
   {
       FPU_PARTIAL_STATUS |= FPU_SW_C2;
@@ -291,6 +295,7 @@
   floatx80 y = BX_READ_FPU_REG(0);

   /* reduce trigonometric function argument */
+  int sign = floatx80_sign(y);
   Bit64u quotient = trig_arg_reduction(y, F_SIN, status);
   if (quotient == -1)
   {
@@ -311,6 +316,9 @@

       return;
   }
+
+  if (sign)
+      quotient = (Bit64u)(-quotient);

   floatx80 siny = y, cosy = y;


ENH: MeshMath new functionality added for changing a point data field using a look up table

--- Applications/MetaMeshTools/MeshMath.cxx
+++ Applications/MetaMeshTools/MeshMath.cxx
@@ -44,6 +44,9 @@
 #include <vtkCell.h>
 #include <vtkPoints.h>
 #include <vtkVersion.h>
+
+#include <vtkTable.h>
+#include <vtkDelimitedTextReader.h>

 #if !defined(M_PI)
 #define M_PI 3.14159265358979323846264338327950288   /* pi */
@@ -354,6 +357,8 @@
 	      << "     <op>: [threshBelow | sub]  threshBelow: set to 0 all data below <value>, sub: subtract value"   << std::endl;
     //bp2013
     std::cout << " -translateMesh <tx_DimX> <tx_DimY> <tx_DimZ> ,  translates a mesh for a given amount " << std::endl;
+    //bp2015
+    std::cout << " -lookupPointData <csv_lookup> <scalar_field_name>,  substitutes scalar values in a given scalar field based on an input lookup " << std::endl;

     std::cout << " -verbose                   Verbose output" << std::endl;
     return 0;
@@ -845,6 +850,18 @@
     char * tmp_str = ipGetStringArgument(argv, "-translateMesh", NULL);
     ipExtractFloatTokens(TranslateParams, tmp_str, numtranslateparams);
     }
+
+  //bp2015
+  bool lookupPointOn = ipExistsArgument(argv, "-lookupPointData");
+  if( lookupPointOn )
+      {
+      nbfile = ipGetStringMultipArgument(argv, "-lookupPointData", files, maxNumFiles);
+      if( nbfile != 2 )
+        {
+        std::cerr << "Error: Incorrect number of arguments!" << std::endl;
+        exit(1);
+        }
+      }

   // PROCESSING STARTS HERE
   // PROCESSING STARTS HERE
@@ -6047,8 +6064,77 @@
      SurfaceWriter->Update();

     }
-    else
-    {
+    else if( lookupPointOn ) // bp2009
+  {
+  vtkPolyDataReader *polyRead = vtkPolyDataReader::New();
+  polyRead->SetFileName(inputFilename);
+  polyRead->Update();
+  vtkPolyData* polyIn = polyRead->GetOutput();
+  vtkPolyData* polyOut = polyRead->GetOutput();
+
+  if( debug )
+    {
+    std::cout << "Input Mesh read ...  " << inputFilename << std::endl;
+    }
+
+  // *** START PARSING the csv file
+  vtkSmartPointer<vtkDelimitedTextReader> CSVreader = vtkSmartPointer<vtkDelimitedTextReader>::New();
+  CSVreader->SetFieldDelimiterCharacters(",");
+  CSVreader->SetFileName(files[0]);
+  CSVreader->SetHaveHeaders(true);
+  CSVreader->Update();
+  vtkSmartPointer<vtkTable> table = CSVreader->GetOutput();
+
+  polyIn->GetPointData()->SetActiveScalars(files[1]);
+  vtkDoubleArray* inputScalars = (vtkDoubleArray *) polyIn->GetPointData()->GetArray(files[1]);
+  vtkDoubleArray* outputScalars = (vtkDoubleArray *) polyIn->GetPointData()->GetArray(files[1]);
+
+  if (inputScalars && outputScalars)
+  {
+      if (debug)
+      {
+          std::cout << "Got arrays!" << std::endl;
+      }
+  }
+
+  std::cout << files[1] << std::endl;
+  //std::string newScalarName = files[1].str_c() + "_new";
+  //outputScalars->SetName(newScalarName);
+
+  for (unsigned int idx=0; idx < table->GetNumberOfRows() ; idx++)
+  {
+    for (unsigned int idxs = 0 ; idxs < polyIn->GetNumberOfPoints() ; idxs++)
+    {
+        if (inputScalars->GetVariantValue(idxs) == table->GetValue(idx,0))
+        {
+            outputScalars->SetVariantValue(idxs,table->GetValue(idx,1));
+        }
+    }
+  }
+
+  polyOut->GetPointData()->AddArray(outputScalars);
+      if( debug )
+    {
+    std::cout << "Scalar map added to the mesh" << std::endl;
+    }
+
+
+  // Writing the new mesh
+  vtkPolyDataWriter *SurfaceWriter = vtkPolyDataWriter::New();
+  #if VTK_MAJOR_VERSION > 5
+  SurfaceWriter->SetInputData(polyOut);
+  #else
+  SurfaceWriter->SetInput(polyOut);
+  #endif
+  SurfaceWriter->SetFileName(outputFilename);
+  SurfaceWriter->Update();
+  if( debug )
+    {
+    std::cout << "Writing new mesh " << outputFilename << std::endl;
+    }
+
+  }
+   else {

     std::cout << "No operation to do -> exiting" << std::endl;
     exit(-1);


Do not use .xword and friends to emit zeros on V9.  Apparently there are issues
with emitting .xwords when not on an 8-byte boundary (.xword 0 is not the
same as 8 .byte 0's).  Because we do not know when or when we are not aligned,
just emit bytes like the old V9 asmprinter did.

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

--- lib/CodeGen/AsmPrinter.cpp
+++ lib/CodeGen/AsmPrinter.cpp
@@ -46,12 +46,6 @@
     if (ZeroDirective)
       O << ZeroDirective << NumZeros << "\n";
     else {
-      if (NumZeros >= 8 && Data64bitsDirective) {
-        for (; NumZeros >= 8; NumZeros -= 8)
-          O << Data64bitsDirective << "0\n";
-      }
-      for (; NumZeros >= 4; NumZeros -= 4)
-        O << Data32bitsDirective << "0\n";
       for (; NumZeros; --NumZeros)
         O << Data8bitsDirective << "0\n";
     }


PGO: Separate out common isMachO logic; no functionality change

<rdar://problem/15943240>

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@204297 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/CodeGen/CodeGenPGO.cpp
+++ lib/CodeGen/CodeGenPGO.cpp
@@ -221,25 +221,20 @@
                                              WriteAtExitTy);
 }

+static bool isMachO(const CodeGenModule &CGM) {
+  return CGM.getTarget().getTriple().isOSBinFormatMachO();
+}
+
 static StringRef getCountersSection(const CodeGenModule &CGM) {
-  if (CGM.getTarget().getTriple().isOSBinFormatMachO())
-    return "__DATA,__llvm_pgo_cnts";
-  else
-    return "__llvm_pgo_cnts";
+  return isMachO(CGM) ? "__DATA,__llvm_pgo_cnts" : "__llvm_pgo_cnts";
 }

 static StringRef getNameSection(const CodeGenModule &CGM) {
-  if (CGM.getTarget().getTriple().isOSBinFormatMachO())
-    return "__DATA,__llvm_pgo_names";
-  else
-    return "__llvm_pgo_names";
+  return isMachO(CGM) ? "__DATA,__llvm_pgo_names" : "__llvm_pgo_names";
 }

 static StringRef getDataSection(const CodeGenModule &CGM) {
-  if (CGM.getTarget().getTriple().isOSBinFormatMachO())
-    return "__DATA,__llvm_pgo_data";
-  else
-    return "__llvm_pgo_data";
+  return isMachO(CGM) ? "__DATA,__llvm_pgo_data" : "__llvm_pgo_data";
 }

 llvm::GlobalVariable *CodeGenPGO::buildDataVar() {


Support in the translation for unsigned inequalities

--- lib/CrabLlvm/CfgBuilder.cc
+++ lib/CrabLlvm/CfgBuilder.cc
@@ -124,12 +124,6 @@
 		     cl::Hidden);

 cl::opt<bool>
-CrabUnsoundUnsignedAsSigned("crab-unsigned-to-signed",
-	  cl::desc ("Convert (unsoundly) unsigned integer comparisons to signed."),
-	  cl::init (false),
-	  cl::Hidden);
-
-cl::opt<bool>
 CrabDisableWarnings("crab-disable-warnings",
 	      cl::desc ("Disable warning messages"),
 	      cl::init (false),
@@ -948,14 +942,11 @@
       break;
     }
     case CmpInst::ICMP_ULT:
-      if (!CrabUnsoundUnsignedAsSigned) {
-	// loss of precision
-	CRABLLVM_WARNING("translation skipped " << I << ".\n" <<
-			 "Enable --lower-unsigned-icmp");
-	break;
-      }
     case CmpInst::ICMP_SLT: {
       lin_cst_t cst(op0 <= op1 - number_t(1));
+      if (I.getPredicate() == CmpInst::ICMP_ULT) {
+	cst.set_unsigned();
+      }
       if (isBool(I))
 	bb.bool_assign(lhs, cst);
       else
@@ -963,14 +954,11 @@
       break;
     }
     case CmpInst::ICMP_ULE:
-      if (!CrabUnsoundUnsignedAsSigned) {
-	// loss of precision
-	CRABLLVM_WARNING("translation skipped " << I << ".\n" <<
-			 "Enable --lower-unsigned-icmp");
-	break;
-      }
     case CmpInst::ICMP_SLE: {
       lin_cst_t cst(op0 <= op1);
+      if (I.getPredicate() == CmpInst::ICMP_ULE) {
+	cst.set_unsigned();
+      }
       if (isBool(I))
 	bb.bool_assign(lhs, cst);
       else
@@ -1068,31 +1056,31 @@
 	return lin_cst_t(op0 == op1);
 	break;
     case CmpInst::ICMP_ULT:
-      if (!CrabUnsoundUnsignedAsSigned) {
-	// loss of precision
-	CRABLLVM_WARNING("translation skipped " << I << ".\n" <<
-			 "Enable --lower-unsigned-icmp");
-	break;
-      }
-    case CmpInst::ICMP_SLT:
+    case CmpInst::ICMP_SLT: {
+      lin_cst_t cst;
       if (!isNegated)
-	return lin_cst_t(op0 <= op1 - number_t(1));
+	cst = lin_cst_t(op0 <= op1 - number_t(1));
       else
-	return lin_cst_t(op0 >= op1);
+	cst = lin_cst_t(op0 >= op1);
+      if (I.getPredicate() == CmpInst::ICMP_ULT) {
+	cst.set_unsigned();
+      }
+      return cst;
       break;
+    }
     case CmpInst::ICMP_ULE:
-      if (!CrabUnsoundUnsignedAsSigned) {
-	// loss of precision
-	CRABLLVM_WARNING("translation skipped " << I << ".\n" <<
-			 "Enable --lower-unsigned-icmp");
-	break;
-      }
-    case CmpInst::ICMP_SLE:
+    case CmpInst::ICMP_SLE: {
+      lin_cst_t cst;
       if (!isNegated)
-	return lin_cst_t(op0 <= op1);
+	cst = lin_cst_t(op0 <= op1);
       else
-	return lin_cst_t(op0 >= op1 + number_t(1));
+	cst = lin_cst_t(op0 >= op1 + number_t(1));
+      if (I.getPredicate() == CmpInst::ICMP_ULE) {
+	cst.set_unsigned();
+      }
+      return cst;
       break;
+    }
     default: ;;
     }
     return boost::optional<lin_cst_t> ();


Driver: When compilation fails, don't try to remove output files we don't have
write access to.

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@130150 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Driver/Compilation.cpp
+++ lib/Driver/Compilation.cpp
@@ -101,6 +101,12 @@
     llvm::sys::Path P(*it);
     std::string Error;

+    // Don't try to remove files which we don't have write access to (but may be
+    // able to remove). Underlying tools may have intentionally not overwritten
+    // them.
+    if (!P.canWrite())
+      continue;
+
     if (P.eraseFromDisk(false, &Error)) {
       // Failure is only failure if the file exists and is "regular". There is
       // a race condition here due to the limited interface of


[IRGen] Don't eagerly look up and cache "NSString".

The type checker is long gone at this point, so if we /haven't/ imported
NSString yet we won't do the proper post-processing for it. That's not so
bad unless the current ASTContext survives to emit more decls later...
which is exactly what LLDB does.

We use this Swift-to-Clang type mapping for property metadata, so we can't
just ignore Swift types that ought to be bridged when it comes to actual
code. However, if we actually see one of them /and/ they've been marked
@objc, we've almost certainly seen the real NSString (or NSArray, etc.) by
this point. We just don't want to trigger this on non-@objc code or @objc
code that /doesn't/ use one of these types.

No test case because the normal Swift compiler doesn't have any problems
doing this. We can't add an assertion yet because SIL can do this too, and
sometimes it squeaks by. (See rdar://problem/19978257.)

rdar://problem/21081792

Swift SVN r28944

--- lib/IRGen/GenClangType.cpp
+++ lib/IRGen/GenClangType.cpp
@@ -160,6 +160,44 @@
 };
 }

+static clang::CanQualType
+getClangFoundationClassType(IRGenModule &IGM, StringRef name) {
+  auto &ctx = IGM.getClangASTContext();
+  // Fallback to returning the "id" type if the class type cannot be found.
+  auto id = [&]() -> clang::CanQualType {
+    return getClangIdType(ctx);
+  };
+
+  auto *Foundation = IGM.Context.getLoadedModule(IGM.Context.Id_Foundation);
+  if (!Foundation)
+    return id();
+
+  auto identifier = IGM.Context.getIdentifier(name);
+  SmallVector<ValueDecl *, 1> results;
+  Foundation->lookupQualified(Foundation->getType(),
+                                              identifier,
+                                              NL_QualifiedDefault, nullptr,
+                                              results);
+  for (auto result : results) {
+    // If we found a type with a clang node, get its declared class type.
+    auto clangNode = result->getClangNode();
+    if (!clangNode)
+      continue;
+
+    auto clangInterface = dyn_cast_or_null<clang::ObjCInterfaceDecl>
+      (clangNode.getAsDecl());
+
+    if (!clangInterface)
+      continue;
+
+    auto type = ctx.getObjCInterfaceType(clangInterface);
+    type = ctx.getObjCObjectPointerType(type);
+    return ctx.getCanonicalType(type);
+  }
+
+  return id();
+}
+
 clang::CanQualType GenClangType::visitStructType(CanStructType type) {
   auto swiftDecl = type->getDecl();
   auto &swiftCtx = type->getASTContext();
@@ -171,6 +209,8 @@
     return Converter.convert(IGM,
                              underlyingTypeDecl->getDeclaredType()
                                ->getCanonicalType());
+  } else if (swiftDecl->getName().str() == "String") {
+    return getClangFoundationClassType(IGM, "NSString");
   }

   // Everything else should have been handled as an imported type
@@ -222,44 +262,6 @@
   // Any @objc class type in Swift that shows up in an @objc method maps 1-1 to
   // "id <SomeProto>"; with clang's encoding ignoring the protocol list.
   return getClangIdType(getClangASTContext());
-}
-
-static clang::CanQualType
-getClangFoundationClassType(IRGenModule &IGM, StringRef name) {
-  auto &ctx = IGM.getClangASTContext();
-  // Fallback to returning the "id" type if the class type cannot be found.
-  auto id = [&]() -> clang::CanQualType {
-    return getClangIdType(ctx);
-  };
-
-  auto *Foundation = IGM.Context.getLoadedModule(IGM.Context.Id_Foundation);
-  if (!Foundation)
-    return id();
-
-  auto identifier = IGM.Context.getIdentifier(name);
-  SmallVector<ValueDecl *, 1> results;
-  Foundation->lookupQualified(Foundation->getType(),
-                                              identifier,
-                                              NL_QualifiedDefault, nullptr,
-                                              results);
-  for (auto result : results) {
-    // If we found a type with a clang node, get its declared class type.
-    auto clangNode = result->getClangNode();
-    if (!clangNode)
-      continue;
-
-    auto clangInterface = dyn_cast_or_null<clang::ObjCInterfaceDecl>
-      (clangNode.getAsDecl());
-
-    if (!clangInterface)
-      continue;
-
-    auto type = ctx.getObjCInterfaceType(clangInterface);
-    type = ctx.getObjCObjectPointerType(type);
-    return ctx.getCanonicalType(type);
-  }
-
-  return id();
 }

 clang::CanQualType
@@ -633,9 +635,6 @@
   //        probably be const char* for type encoding.
   CACHE_STDLIB_TYPE("CString", ctx.VoidPtrTy);

-  // We import NSString* as String.
-  CACHE_STDLIB_TYPE("String", getClangFoundationClassType(IGM, "NSString"));
-
   CACHE_STDLIB_TYPE("CVaListPointer", getClangDecayedVaListType(ctx));

   // These types come from the ObjectiveC module.


Fix comment (test commit)

Fix comment (test commit)

git-svn-id: ffe668792ed300d6c2daa1f6eba2e0aa28d7ec6c@137039 91177308-0d34-0410-b5e6-96231b3b80d8

--- lib/Lex/LiteralSupport.cpp
+++ lib/Lex/LiteralSupport.cpp
@@ -964,7 +964,7 @@
     const char *ThisTokEnd = ThisTokBuf+ThisTokLen-1;  // Skip end quote.
     // TODO: Input character set mapping support.

-    // Skip L marker for wide strings.
+    // Skip marker for wide or unicode strings.
     if (ThisTokBuf[0] == 'L' || ThisTokBuf[0] == 'u' || ThisTokBuf[0] == 'U') {
       ++ThisTokBuf;
       // Skip 8 of u8 marker for utf8 strings.


Update Receiver.cpp

Update Receiver.cpp

--- lib/LibDS/src/Receiver.cpp
+++ lib/LibDS/src/Receiver.cpp
@@ -32,25 +32,25 @@
 void DS_Receiver::onDataReceived()
 {
     while (m_socket.hasPendingDatagrams()) {
-
+
         /* Read the socket data */
         QByteArray data;
         data.resize (m_socket.pendingDatagramSize());
         m_socket.readDatagram (data.data(), data.size());
-
+
         /* Process downloaded data into a DS_RobotPacket */
         DS_RobotPacket packet = getRobotPacket (data);
-
+
         /* Read the values of the packet and notify other objects */
         emit voltageChanged (packet.voltage);
         emit voltageChanged (packet.voltageString);
-
+
         /* Only notify about code change if necessary */
         if (m_code != packet.hasCode) {
             m_code = packet.hasCode;
             emit userCodeChanged (m_code);
         }
-
+
         /* Send current date/time to robot */
         if (packet.requestDateTime) {
             /* TODO */
@@ -61,37 +61,37 @@
 DS_RobotPacket DS_Receiver::getRobotPacket (QByteArray data)
 {
     DS_RobotPacket receiver;
-
+
     /* Get communication version, god knows if we will use it... */
     receiver.commVersion = data.at (2);
-
+
     /* Get the pong data */
     receiver.pongData.byte1 = data.at (0);
     receiver.pongData.byte2 = data.at (1);
-
+
     /* Decide if we must send current date/time to robot */
     receiver.requestDateTime = (data.at (7) == 0x01);
-
+
     /* Get the confirmation code of control mode */
     receiver.controlMode = (DS_ControlMode) data.at (3);
-
+
     /* Get current mode and determine if user code is present */
     receiver.programMode = (DS_ProgramMode) data.at (4);
     receiver.hasCode = (receiver.programMode != DS_ProgramNoCode);
-
+
     /* Calculate the voltage */
     QString major = QString::number (data.at (5));
     QString minor = QString::number (data.at (6));
-
+
     if (minor.length() > 2)
         minor = QString ("%1%2").arg (minor.at (0), minor.at (1));
-
+
     else if (minor.length() == 1)
         minor = QString ("0%1").arg (minor);
-
+
     receiver.voltageString = QString ("%1.%2").arg (major, minor);
     receiver.voltageString = receiver.voltageString.replace ("-", "");
     receiver.voltage = receiver.voltageString.toDouble();
-
+
     return receiver;
 }


Mark a few variables const. NFC.

Mark a few variables const. NFC.

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

--- lib/Linker/LinkModules.cpp
+++ lib/Linker/LinkModules.cpp
@@ -403,9 +403,9 @@
     ValueToValueMapTy ValueMap;

     struct AppendingVarInfo {
-      GlobalVariable *NewGV;  // New aggregate global in dest module.
-      Constant *DstInit;      // Old initializer from dest module.
-      Constant *SrcInit;      // Old initializer from src module.
+      GlobalVariable *NewGV;   // New aggregate global in dest module.
+      const Constant *DstInit; // Old initializer from dest module.
+      const Constant *SrcInit; // Old initializer from src module.
     };

     std::vector<AppendingVarInfo> AppendingVars;
@@ -462,7 +462,7 @@

     /// Given a global in the source module, return the global in the
     /// destination module that is being linked to, if any.
-    GlobalValue *getLinkedToGlobal(GlobalValue *SrcGV) {
+    GlobalValue *getLinkedToGlobal(const GlobalValue *SrcGV) {
       // If the source has no name it can't link.  If it has local linkage,
       // there is no name match-up going on.
       if (!SrcGV->hasName() || SrcGV->hasLocalLinkage())
@@ -486,8 +486,9 @@
     void upgradeMismatchedGlobalArray(StringRef Name);
     void upgradeMismatchedGlobals();

-    bool linkAppendingVarProto(GlobalVariable *DstGV, GlobalVariable *SrcGV);
-    bool linkGlobalProto(GlobalVariable *SrcGV);
+    bool linkAppendingVarProto(GlobalVariable *DstGV,
+                               const GlobalVariable *SrcGV);
+    bool linkGlobalProto(const GlobalVariable *SrcGV);
     bool linkFunctionProto(Function *SrcF);
     bool linkAliasProto(GlobalAlias *SrcA);
     bool linkModuleFlagsMetadata();
@@ -944,7 +945,7 @@
 /// If there were any appending global variables, link them together now.
 /// Return true on error.
 bool ModuleLinker::linkAppendingVarProto(GlobalVariable *DstGV,
-                                         GlobalVariable *SrcGV) {
+                                         const GlobalVariable *SrcGV) {

   if (!SrcGV->hasAppendingLinkage() || !DstGV->hasAppendingLinkage())
     return emitError("Linking globals named '" + SrcGV->getName() +
@@ -1011,7 +1012,7 @@

 /// Loop through the global variables in the src module and merge them into the
 /// dest module.
-bool ModuleLinker::linkGlobalProto(GlobalVariable *SGV) {
+bool ModuleLinker::linkGlobalProto(const GlobalVariable *SGV) {
   GlobalValue *DGV = getLinkedToGlobal(SGV);
   llvm::Optional<GlobalValue::VisibilityTypes> NewVisibility;
   bool HasUnnamedAddr = SGV->hasUnnamedAddr();
@@ -1261,7 +1262,8 @@
   return false;
 }

-static void getArrayElements(Constant *C, SmallVectorImpl<Constant*> &Dest) {
+static void getArrayElements(const Constant *C,
+                             SmallVectorImpl<Constant *> &Dest) {
   unsigned NumElements = cast<ArrayType>(C->getType())->getNumElements();

   for (unsigned i = 0; i != NumElements; ++i)


MCELF: Count the section orders properly. Patch by Roman Divacky.

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

--- lib/MC/ELFObjectWriter.cpp
+++ lib/MC/ELFObjectWriter.cpp
@@ -932,10 +932,15 @@
   // ... then all of the sections ...
   DenseMap<const MCSection*, uint64_t> SectionOffsetMap;

+  DenseMap<const MCSection*, uint8_t> SectionIndexMap;
+
+  unsigned Index = 1;
   for (MCAssembler::const_iterator it = Asm.begin(),
          ie = Asm.end(); it != ie; ++it) {
     // Remember the offset into the file for this section.
     SectionOffsetMap[&it->getSection()] = FileOff;
+
+    SectionIndexMap[&it->getSection()] = Index++;

     const MCSectionData &SD = *it;
     FileOff += Layout.getSectionFileSize(&SD);
@@ -968,15 +973,11 @@
     case ELF::SHT_RELA: {
       const MCSection *SymtabSection;
       const MCSection *InfoSection;
-      const MCSectionData *SymtabSD;
-      const MCSectionData *InfoSD;

       SymtabSection = Asm.getContext().getELFSection(".symtab", ELF::SHT_SYMTAB, 0,
                                                      SectionKind::getReadOnly(),
                                                      false);
-      SymtabSD = &Asm.getSectionData(*SymtabSection);
-      // we have to count the empty section in too
-      sh_link = SymtabSD->getLayoutOrder() + 1;
+      sh_link = SectionIndexMap[SymtabSection];

       // Remove ".rel" and ".rela" prefixes.
       unsigned SecNameLen = (Section.getType() == ELF::SHT_REL) ? 4 : 5;
@@ -986,8 +987,7 @@
                                                    ELF::SHT_PROGBITS, 0,
                                                    SectionKind::getReadOnly(),
                                                    false);
-      InfoSD = &Asm.getSectionData(*InfoSection);
-      sh_info = InfoSD->getLayoutOrder() + 1;
+      sh_info = SectionIndexMap[InfoSection];
       break;
     }


Write the symbol table directly to the output file.

There is no need to first accumulate it in fragments.

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

--- lib/MC/ELFObjectWriter.cpp
+++ lib/MC/ELFObjectWriter.cpp
@@ -51,32 +51,29 @@

 typedef DenseMap<const MCSectionELF *, uint32_t> SectionIndexMapTy;

+class ELFObjectWriter;
+
 class SymbolTableWriter {
-  MCAssembler &Asm;
-  FragmentWriter &FWriter;
+  ELFObjectWriter &EWriter;
   bool Is64Bit;
-  std::vector<const MCSectionELF *> &Sections;
-
-  // The symbol .symtab fragment we are writting to.
-  MCDataFragment *SymtabF;
-
-  // .symtab_shndx fragment we are writting to.
-  MCDataFragment *ShndxF;
+
+  // indexes we are going to write to .symtab_shndx.
+  std::vector<uint32_t> ShndxIndexes;

   // The numbel of symbols written so far.
   unsigned NumWritten;

   void createSymtabShndx();

-  template <typename T> void write(MCDataFragment &F, T Value);
+  template <typename T> void write(T Value);

 public:
-  SymbolTableWriter(MCAssembler &Asm, FragmentWriter &FWriter, bool Is64Bit,
-                    std::vector<const MCSectionELF *> &Sections,
-                    MCDataFragment *SymtabF);
+  SymbolTableWriter(ELFObjectWriter &EWriter, bool Is64Bit);

   void writeSymbol(uint32_t name, uint8_t info, uint64_t value, uint64_t size,
                    uint8_t other, uint32_t shndx, bool Reserved);
+
+  ArrayRef<uint32_t> getShndxIndexes() const { return ShndxIndexes; }
 };

 class ELFObjectWriter : public MCObjectWriter {
@@ -190,6 +187,13 @@
         Write32(W);
     }

+    template <typename T> void write(T Val) {
+      if (IsLittleEndian)
+        support::endian::Writer<support::little>(OS).write(Val);
+      else
+        support::endian::Writer<support::big>(OS).write(Val);
+    }
+
     template <typename T> void write(MCDataFragment &F, T Value) {
       FWriter.write(F, Value);
     }
@@ -199,9 +203,12 @@
     void WriteSymbol(SymbolTableWriter &Writer, ELFSymbolData &MSD,
                      const MCAsmLayout &Layout);

-    void WriteSymbolTable(MCDataFragment *SymtabF, MCAssembler &Asm,
-                          const MCAsmLayout &Layout,
-                          std::vector<const MCSectionELF *> &Sections);
+    // Start and end offset of each section
+    typedef std::vector<std::pair<uint64_t, uint64_t>> SectionOffsetsTy;
+
+    void WriteSymbolTable(MCAssembler &Asm, const MCAsmLayout &Layout,
+                          std::vector<const MCSectionELF *> &Sections,
+                          SectionOffsetsTy &SectionOffsets);

     bool shouldRelocateWithSymbol(const MCAssembler &Asm,
                                   const MCSymbolRefExpr *RefA,
@@ -218,8 +225,6 @@

     // Map from a signature symbol to the group section index
     typedef DenseMap<const MCSymbol *, unsigned> RevGroupMapTy;
-    // Start and end offset of each section
-    typedef std::vector<std::pair<uint64_t, uint64_t>> SectionOffsetsTy;

     /// Compute the symbol table data
     ///
@@ -251,8 +256,6 @@
                                    std::vector<const MCSectionELF *> &Sections);
     void createStringTable(MCAssembler &Asm,
                            std::vector<const MCSectionELF *> &Sections);
-    void CreateMetadataSections(MCAssembler &Asm, const MCAsmLayout &Layout,
-                                std::vector<const MCSectionELF *> &Sections);

     // Create the sections that show up in the symbol table. Currently
     // those are the .note.GNU-stack section and the group sections.
@@ -309,32 +312,18 @@
 }

 void SymbolTableWriter::createSymtabShndx() {
-  if (ShndxF)
+  if (!ShndxIndexes.empty())
     return;

-  MCContext &Ctx = Asm.getContext();
-  const MCSectionELF *SymtabShndxSection =
-      Ctx.getELFSection(".symtab_shndxr", ELF::SHT_SYMTAB_SHNDX, 0, 4, "");
-  MCSectionData *SymtabShndxSD =
-      &Asm.getOrCreateSectionData(*SymtabShndxSection);
-  SymtabShndxSD->setAlignment(4);
-  ShndxF = new MCDataFragment(SymtabShndxSD);
-  Sections.push_back(SymtabShndxSection);
-
-  for (unsigned I = 0; I < NumWritten; ++I)
-    write(*ShndxF, uint32_t(0));
-}
-
-template <typename T>
-void SymbolTableWriter::write(MCDataFragment &F, T Value) {
-  FWriter.write(F, Value);
-}
-
-SymbolTableWriter::SymbolTableWriter(
-    MCAssembler &Asm, FragmentWriter &FWriter, bool Is64Bit,
-    std::vector<const MCSectionELF *> &Sections, MCDataFragment *SymtabF)
-    : Asm(Asm), FWriter(FWriter), Is64Bit(Is64Bit), Sections(Sections),
-      SymtabF(SymtabF), ShndxF(nullptr), NumWritten(0) {}
+  ShndxIndexes.resize(NumWritten);
+}
+
+template <typename T> void SymbolTableWriter::write(T Value) {
+  EWriter.write(Value);
+}
+
+SymbolTableWriter::SymbolTableWriter(ELFObjectWriter &EWriter, bool Is64Bit)
+    : EWriter(EWriter), Is64Bit(Is64Bit), NumWritten(0) {}

 void SymbolTableWriter::writeSymbol(uint32_t name, uint8_t info, uint64_t value,
                                     uint64_t size, uint8_t other,
@@ -344,29 +333,29 @@
   if (LargeIndex)
     createSymtabShndx();

-  if (ShndxF) {
+  if (!ShndxIndexes.empty()) {
     if (LargeIndex)
-      write(*ShndxF, shndx);
+      ShndxIndexes.push_back(shndx);
     else
-      write(*ShndxF, uint32_t(0));
+      ShndxIndexes.push_back(0);
   }

   uint16_t Index = LargeIndex ? uint16_t(ELF::SHN_XINDEX) : shndx;

   if (Is64Bit) {
-    write(*SymtabF, name);  // st_name
-    write(*SymtabF, info);  // st_info
-    write(*SymtabF, other); // st_other
-    write(*SymtabF, Index); // st_shndx
-    write(*SymtabF, value); // st_value
-    write(*SymtabF, size);  // st_size
+    write(name);  // st_name
+    write(info);  // st_info
+    write(other); // st_other
+    write(Index); // st_shndx
+    write(value); // st_value
+    write(size);  // st_size
   } else {
-    write(*SymtabF, name);            // st_name
-    write(*SymtabF, uint32_t(value)); // st_value
-    write(*SymtabF, uint32_t(size));  // st_size
-    write(*SymtabF, info);            // st_info
-    write(*SymtabF, other);           // st_other
-    write(*SymtabF, Index);           // st_shndx
+    write(name);            // st_name
+    write(uint32_t(value)); // st_value
+    write(uint32_t(size));  // st_size
+    write(info);            // st_info
+    write(other);           // st_other
+    write(Index);           // st_shndx
   }

   ++NumWritten;
@@ -595,14 +584,31 @@
 }

 void ELFObjectWriter::WriteSymbolTable(
-    MCDataFragment *SymtabF, MCAssembler &Asm, const MCAsmLayout &Layout,
-    std::vector<const MCSectionELF *> &Sections) {
+    MCAssembler &Asm, const MCAsmLayout &Layout,
+    std::vector<const MCSectionELF *> &Sections,
+    SectionOffsetsTy &SectionOffsets) {
+
+  MCContext &Ctx = Asm.getContext();
+
+  unsigned EntrySize = is64Bit() ? ELF::SYMENTRY_SIZE64 : ELF::SYMENTRY_SIZE32;
+
+  // Symbol table
+  const MCSectionELF *SymtabSection =
+      Ctx.getELFSection(".symtab", ELF::SHT_SYMTAB, 0, EntrySize, "");
+  MCSectionData &SymtabSD = Asm.getOrCreateSectionData(*SymtabSection);
+  SymtabSD.setAlignment(is64Bit() ? 8 : 4);
+  SymbolTableIndex = Sections.size() + 1;
+  Sections.push_back(SymtabSection);
+
   // The string table must be emitted first because we need the index
   // into the string table for all the symbol names.

-  // FIXME: Make sure the start of the symbol table is aligned.
-
-  SymbolTableWriter Writer(Asm, FWriter, is64Bit(), Sections, SymtabF);
+  SymbolTableWriter Writer(*this, is64Bit());
+
+  uint64_t Padding = OffsetToAlignment(OS.tell(), SymtabSD.getAlignment());
+  WriteZeros(Padding);
+
+  uint64_t SecStart = OS.tell();

   // The first entry is the undefined symbol entry.
   Writer.writeSymbol(0, 0, 0, 0, 0, 0, false);
@@ -638,6 +644,25 @@
     if (MCELF::GetBinding(Data) == ELF::STB_LOCAL)
       LastLocalSymbolIndex++;
   }
+
+  uint64_t SecEnd = OS.tell();
+  SectionOffsets.push_back(std::make_pair(SecStart, SecEnd));
+
+  ArrayRef<uint32_t> ShndxIndexes = Writer.getShndxIndexes();
+  if (ShndxIndexes.empty())
+    return;
+
+  SecStart = OS.tell();
+  const MCSectionELF *SymtabShndxSection =
+      Ctx.getELFSection(".symtab_shndxr", ELF::SHT_SYMTAB_SHNDX, 0, 4, "");
+  Sections.push_back(SymtabShndxSection);
+  MCSectionData *SymtabShndxSD =
+      &Asm.getOrCreateSectionData(*SymtabShndxSection);
+  SymtabShndxSD->setAlignment(4);
+  for (uint32_t Index : ShndxIndexes)
+    write(Index);
+  SecEnd = OS.tell();
+  SectionOffsets.push_back(std::make_pair(SecStart, SecEnd));
 }

 // It is always valid to create a relocation with a symbol. It is preferable
@@ -1396,26 +1421,6 @@
   OS << StrTabBuilder.data();
 }

-void ELFObjectWriter::CreateMetadataSections(
-    MCAssembler &Asm, const MCAsmLayout &Layout,
-    std::vector<const MCSectionELF *> &Sections) {
-  MCContext &Ctx = Asm.getContext();
-  MCDataFragment *F;
-
-  unsigned EntrySize = is64Bit() ? ELF::SYMENTRY_SIZE64 : ELF::SYMENTRY_SIZE32;
-
-  // Symbol table
-  const MCSectionELF *SymtabSection =
-    Ctx.getELFSection(".symtab", ELF::SHT_SYMTAB, 0,
-                      EntrySize, "");
-  MCSectionData &SymtabSD = Asm.getOrCreateSectionData(*SymtabSection);
-  SymtabSD.setAlignment(is64Bit() ? 8 : 4);
-  SymbolTableIndex = Sections.size() + 1;
-  Sections.push_back(SymtabSection);
-  F = new MCDataFragment(&SymtabSD);
-  WriteSymbolTable(F, Asm, Layout, Sections);
-}
-
 void ELFObjectWriter::createIndexedSections(
     MCAssembler &Asm, const MCAsmLayout &Layout, RevGroupMapTy &RevGroupMap,
     std::vector<const MCSectionELF *> &Sections,
@@ -1570,7 +1575,6 @@

   WriteRelocations(Asm, Layout);

-  CreateMetadataSections(Asm, Layout, Sections);

   SectionOffsetsTy SectionOffsets;

@@ -1590,6 +1594,8 @@
     uint64_t SecEnd = OS.tell();
     SectionOffsets.push_back(std::make_pair(SecStart, SecEnd));
   }
+
+  WriteSymbolTable(Asm, Layout, Sections, SectionOffsets);

   {
     uint64_t SecStart = OS.tell();


[gardening] Rename fields of SILGenApply to match SILGen naming conventions.

--- lib/SILGen/SILGenApply.cpp
+++ lib/SILGen/SILGenApply.cpp
@@ -701,47 +701,47 @@

   /// The apply callee that abstractly represents the entry point that is being
   /// called.
-  Optional<Callee> ApplyCallee;
+  Optional<Callee> applyCallee;

   /// The lvalue or rvalue representing the argument source of self.
-  ArgumentSource SelfParam;
-  Expr *SelfApplyExpr = nullptr;
-  Type SelfType;
-  std::vector<ApplyExpr*> CallSites;
-  Expr *SideEffect = nullptr;
+  ArgumentSource selfParam;
+  Expr *selfApplyExpr = nullptr;
+  Type selfType;
+  std::vector<ApplyExpr*> callSites;
+  Expr *sideEffect = nullptr;

   /// When visiting expressions, sometimes we need to emit self before we know
   /// what the actual callee is. In such cases, we assume that we are passing
   /// self at +0 and then after we know what the callee is, we check if the
   /// self is passed at +1. If so, we add an extra retain.
-  bool AssumedPlusZeroSelf = false;
+  bool assumedPlusZeroSelf = false;

   SILGenApply(SILGenFunction &SGF)
     : SGF(SGF)
   {}

   void setCallee(Callee &&c) {
-    assert(!ApplyCallee && "already set callee!");
-    ApplyCallee.emplace(std::move(c));
+    assert(!applyCallee && "already set callee!");
+    applyCallee.emplace(std::move(c));
   }

   void setSideEffect(Expr *sideEffectExpr) {
-    assert(!SideEffect && "already set side effect!");
-    SideEffect = sideEffectExpr;
+    assert(!sideEffect && "already set side effect!");
+    sideEffect = sideEffectExpr;
   }

   void setSelfParam(ArgumentSource &&theSelfParam, Expr *theSelfApplyExpr) {
-    assert(!SelfParam && "already set this!");
-    SelfParam = std::move(theSelfParam);
-    SelfApplyExpr = theSelfApplyExpr;
-    SelfType = theSelfApplyExpr->getType();
+    assert(!selfParam && "already set this!");
+    selfParam = std::move(theSelfParam);
+    selfApplyExpr = theSelfApplyExpr;
+    selfType = theSelfApplyExpr->getType();
   }

   void setSelfParam(ArgumentSource &&theSelfParam, Type selfType) {
-    assert(!SelfParam && "already set this!");
-    SelfParam = std::move(theSelfParam);
-    SelfApplyExpr = nullptr;
-    SelfType = selfType;
+    assert(!selfParam && "already set this!");
+    selfParam = std::move(theSelfParam);
+    selfApplyExpr = nullptr;
+    selfType = selfType;
   }

   void decompose(Expr *e) {
@@ -772,7 +772,7 @@
     if (applyInitDelegation(e))
       return;

-    CallSites.push_back(e);
+    callSites.push_back(e);
     visit(e->getFn());
   }

@@ -822,9 +822,9 @@

   void processProtocolDecl(DeclRefExpr *e, AbstractFunctionDecl *afd,
                            ProtocolDecl *proto) {
-    assert(!CallSites.empty());
-    ApplyExpr *thisCallSite = CallSites.back();
-    CallSites.pop_back();
+    assert(!callSites.empty());
+    ApplyExpr *thisCallSite = callSites.back();
+    callSites.pop_back();

     ArgumentSource selfValue = thisCallSite->getArg();

@@ -856,7 +856,7 @@
     // Prepare the callee.  This can modify both selfValue and subs.
     Callee theCallee = Callee::forArchetype(SGF, selfValue.getSubstRValueType(),
                                             constant, subs, e);
-    AssumedPlusZeroSelf =
+    assumedPlusZeroSelf =
         selfValue.isRValue() &&
         selfValue.forceAndPeekRValue(SGF).peekIsPlusZeroRValueOrTrivial();

@@ -908,7 +908,7 @@
     if (isa<FuncDecl>(afd) && isDynamicallyDispatched) {
       kind = SILDeclRef::Kind::Func;
     } else if (auto ctor = dyn_cast<ConstructorDecl>(afd)) {
-      ApplyExpr *thisCallSite = CallSites.back();
+      ApplyExpr *thisCallSite = callSites.back();
       // Required constructors are dynamically dispatched when the 'self'
       // value is not statically derived.
       if (ctor->isRequired() &&
@@ -933,8 +933,8 @@

     // At this point, we know for sure that we are actually dynamically
     // dispatched.
-    ApplyExpr *thisCallSite = CallSites.back();
-    CallSites.pop_back();
+    ApplyExpr *thisCallSite = callSites.back();
+    callSites.pop_back();

     // Emit the rvalue for self, allowing for guaranteed plus zero if we
     // have a func.
@@ -947,7 +947,7 @@
     // then we assumed that self could be passed at +0. We will check later
     // if the actual callee passes self at +1 later when we know its actual
     // type.
-    AssumedPlusZeroSelf =
+    assumedPlusZeroSelf =
         AllowPlusZero && self.peekIsPlusZeroRValueOrTrivial();

     // If we require a dynamic allocation of the object here, do so now.
@@ -1022,7 +1022,7 @@
         SmallVector<ManagedValue, 4> captures;
         SGF.emitCaptures(e, afd, CaptureEmission::ImmediateApplication,
                          captures);
-        ApplyCallee->setCaptures(std::move(captures));
+        applyCallee->setCaptures(std::move(captures));
       }
     }
   }
@@ -1054,7 +1054,7 @@
       SmallVector<ManagedValue, 4> captures;
       SGF.emitCaptures(e, e, CaptureEmission::ImmediateApplication,
                        captures);
-      ApplyCallee->setCaptures(std::move(captures));
+      applyCallee->setCaptures(std::move(captures));
     }
   }

@@ -1300,7 +1300,7 @@
     // that's the only thing that's witnessed. For classes,
     // this is the initializing constructor, to which we will dynamically
     // dispatch.
-    if (SelfParam.getSubstRValueType()->getRValueInstanceType()
+    if (selfParam.getSubstRValueType()->getRValueInstanceType()
           ->is<ArchetypeType>()
         && isa<ProtocolDecl>(ctorRef->getDecl()->getDeclContext())) {
       // Look up the witness for the constructor.
@@ -1342,8 +1342,8 @@
   }

   Callee getCallee() {
-    assert(ApplyCallee && "did not find callee?!");
-    return std::move(*ApplyCallee);
+    assert(applyCallee && "did not find callee?!");
+    return std::move(*applyCallee);
   }

   /// Ignore parentheses and implicit conversions.
@@ -1402,7 +1402,7 @@

     // Since we'll be collapsing this call site, make sure there's another
     // call site that will actually perform the invocation.
-    if (CallSites.empty())
+    if (callSites.empty())
       return false;

     // Only @objc methods can be forced.
@@ -4498,23 +4498,23 @@
   apply.decompose(e);

   // Evaluate and discard the side effect if present.
-  if (apply.SideEffect)
-    SGF.emitRValue(apply.SideEffect);
+  if (apply.sideEffect)
+    SGF.emitRValue(apply.sideEffect);

   // Build the call.
   // Pass the writeback scope on to CallEmission so it can thread scopes through
   // nested calls.
   CallEmission emission(SGF, apply.getCallee(), std::move(writebacks),
-                        apply.AssumedPlusZeroSelf);
+                        apply.assumedPlusZeroSelf);

   // Apply 'self' if provided.
-  if (apply.SelfParam) {
-    emission.addCallSite(RegularLocation(e), std::move(apply.SelfParam),
-                         apply.SelfType->getCanonicalType(), /*throws*/ false);
+  if (apply.selfParam) {
+    emission.addCallSite(RegularLocation(e), std::move(apply.selfParam),
+                         apply.selfType->getCanonicalType(), /*throws*/ false);
   }

   // Apply arguments from call sites, innermost to outermost.
-  for (auto site = apply.CallSites.rbegin(), end = apply.CallSites.rend();
+  for (auto site = apply.callSites.rbegin(), end = apply.callSites.rend();
        site != end;
        ++site) {
     emission.addCallSite(*site);