[llvm-commits] [llvm] r134219 - in /llvm/trunk: include/llvm/MC/SubtargetFeature.h lib/MC/SubtargetFeature.cpp

Cameron Zwarich zwarich at apple.com
Fri Jul 1 02:01:00 PDT 2011


It looks like this is causing the Valgrind bot failures:

http://google1.osuosl.org:8011/builders/llvm-x86_64-linux-vg_leak/builds/1387

Cameron

On 2011-06-30, at 5:23 PM, Evan Cheng wrote:

> Author: evancheng
> Date: Thu Jun 30 19:23:10 2011
> New Revision: 134219
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=134219&view=rev
> Log:
> Switch SubtargetFeatures from std::string to StringRef.
> 
> Modified:
>    llvm/trunk/include/llvm/MC/SubtargetFeature.h
>    llvm/trunk/lib/MC/SubtargetFeature.cpp
> 
> Modified: llvm/trunk/include/llvm/MC/SubtargetFeature.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/SubtargetFeature.h?rev=134219&r1=134218&r2=134219&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/MC/SubtargetFeature.h (original)
> +++ llvm/trunk/include/llvm/MC/SubtargetFeature.h Thu Jun 30 19:23:10 2011
> @@ -18,13 +18,13 @@
> #ifndef LLVM_MC_SUBTARGETFEATURE_H
> #define LLVM_MC_SUBTARGETFEATURE_H
> 
> -#include <string>
> #include <vector>
> #include "llvm/ADT/Triple.h"
> #include "llvm/Support/DataTypes.h"
> 
> namespace llvm {
>   class raw_ostream;
> +  class StringRef;
> 
> //===----------------------------------------------------------------------===//
> ///
> @@ -74,24 +74,23 @@
> class SubtargetFeatures {
>   std::vector<std::string> Features;    // Subtarget features as a vector
> public:
> -  explicit SubtargetFeatures(const std::string &Initial = std::string());
> +  explicit SubtargetFeatures(const StringRef Initial = "");
> 
>   /// Features string accessors.
> -  std::string getString() const;
> -  void setString(const std::string &Initial);
> +  StringRef getString() const;
> 
>   /// Adding Features.
> -  void AddFeature(const std::string &String, bool IsEnabled = true);
> +  void AddFeature(const StringRef String, bool IsEnabled = true);
> 
>   /// Get feature bits of a CPU.
> -  uint64_t getFeatureBits(const std::string &CPU,
> +  uint64_t getFeatureBits(const StringRef CPU,
>                           const SubtargetFeatureKV *CPUTable,
>                           size_t CPUTableSize,
>                           const SubtargetFeatureKV *FeatureTable,
>                           size_t FeatureTableSize);
> 
>   /// Get scheduling itinerary of a CPU.
> -  void *getItinerary(const std::string &CPU,
> +  void *getItinerary(const StringRef CPU,
>                      const SubtargetInfoKV *Table, size_t TableSize);
> 
>   /// Print feature string.
> 
> Modified: llvm/trunk/lib/MC/SubtargetFeature.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/SubtargetFeature.cpp?rev=134219&r1=134218&r2=134219&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/SubtargetFeature.cpp (original)
> +++ llvm/trunk/lib/MC/SubtargetFeature.cpp Thu Jun 30 19:23:10 2011
> @@ -27,7 +27,7 @@
> 
> /// hasFlag - Determine if a feature has a flag; '+' or '-'
> ///
> -static inline bool hasFlag(const std::string &Feature) {
> +static inline bool hasFlag(const StringRef Feature) {
>   assert(!Feature.empty() && "Empty string");
>   // Get first character
>   char Ch = Feature[0];
> @@ -37,13 +37,13 @@
> 
> /// StripFlag - Return string stripped of flag.
> ///
> -static inline std::string StripFlag(const std::string &Feature) {
> +static inline std::string StripFlag(const StringRef Feature) {
>   return hasFlag(Feature) ? Feature.substr(1) : Feature;
> }
> 
> /// isEnabled - Return true if enable flag; '+'.
> ///
> -static inline bool isEnabled(const std::string &Feature) {
> +static inline bool isEnabled(const StringRef Feature) {
>   assert(!Feature.empty() && "Empty string");
>   // Get first character
>   char Ch = Feature[0];
> @@ -53,16 +53,19 @@
> 
> /// PrependFlag - Return a string with a prepended flag; '+' or '-'.
> ///
> -static inline std::string PrependFlag(const std::string &Feature,
> -                                      bool IsEnabled) {
> +static inline StringRef PrependFlag(const StringRef Feature,
> +                                    bool IsEnabled) {
>   assert(!Feature.empty() && "Empty string");
> -  if (hasFlag(Feature)) return Feature;
> -  return std::string(IsEnabled ? "+" : "-") + Feature;
> +  if (hasFlag(Feature))
> +    return Feature;
> +  std::string Prefix = IsEnabled ? "+" : "-";
> +  Prefix += Feature;
> +  return StringRef(Prefix);
> }
> 
> /// Split - Splits a string of comma separated items in to a vector of strings.
> ///
> -static void Split(std::vector<std::string> &V, const std::string &S) {
> +static void Split(std::vector<std::string> &V, const StringRef S) {
>   if (S.empty())
>     return;
> 
> @@ -106,7 +109,7 @@
> }
> 
> /// Adding features.
> -void SubtargetFeatures::AddFeature(const std::string &String,
> +void SubtargetFeatures::AddFeature(const StringRef String,
>                                    bool IsEnabled) {
>   // Don't add empty features
>   if (!String.empty()) {
> @@ -116,10 +119,10 @@
> }
> 
> /// Find KV in array using binary search.
> -template<typename T> const T *Find(const std::string &S, const T *A, size_t L) {
> +template<typename T> const T *Find(const StringRef S, const T *A, size_t L) {
>   // Make the lower bound element we're looking for
>   T KV;
> -  KV.Key = S.c_str();
> +  KV.Key = S.data();
>   // Determine the end of the array
>   const T *Hi = A + L;
>   // Binary search the array
> @@ -173,21 +176,15 @@
> //                    SubtargetFeatures Implementation
> //===----------------------------------------------------------------------===//
> 
> -SubtargetFeatures::SubtargetFeatures(const std::string &Initial) {
> +SubtargetFeatures::SubtargetFeatures(const StringRef Initial) {
>   // Break up string into separate features
>   Split(Features, Initial);
> }
> 
> 
> -std::string SubtargetFeatures::getString() const {
> +StringRef SubtargetFeatures::getString() const {
>   return Join(Features);
> }
> -void SubtargetFeatures::setString(const std::string &Initial) {
> -  // Throw out old features
> -  Features.clear();
> -  // Break up string into separate features
> -  Split(Features, LowercaseString(Initial));
> -}
> 
> /// SetImpliedBits - For each feature that is (transitively) implied by this
> /// feature, set it.
> @@ -229,7 +226,7 @@
> 
> /// getFeatureBits - Get feature bits a CPU.
> ///
> -uint64_t SubtargetFeatures::getFeatureBits(const std::string &CPU,
> +uint64_t SubtargetFeatures::getFeatureBits(const StringRef CPU,
>                                          const SubtargetFeatureKV *CPUTable,
>                                          size_t CPUTableSize,
>                                          const SubtargetFeatureKV *FeatureTable,
> @@ -272,7 +269,7 @@
>   }
>   // Iterate through each feature
>   for (size_t i = 0, E = Features.size(); i < E; i++) {
> -    const std::string &Feature = Features[i];
> +    const StringRef Feature = Features[i];
> 
>     // Check for help
>     if (Feature == "+help")
> @@ -306,7 +303,7 @@
> }
> 
> /// Get scheduling itinerary of a CPU.
> -void *SubtargetFeatures::getItinerary(const std::string &CPU,
> +void *SubtargetFeatures::getItinerary(const StringRef CPU,
>                                       const SubtargetInfoKV *Table,
>                                       size_t TableSize) {
>   assert(Table && "missing table");
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110701/8e7ada78/attachment.html>


More information about the llvm-commits mailing list