[llvm] r222971 - Revert r222957 "Replace std::map<K, V*> with std::map<K, V> to handle ownership and deletion of the values."

Shankar Easwaran shankare at codeaurora.org
Sat Nov 29 21:18:54 PST 2014


You might want to use git-svnrevert in the future. This will add the svn 
revision rather than using the git commit id in the revert commit message.

On 11/29/2014 7:28 PM, Craig Topper wrote:
> Ok one of the bots caught it with clang, but my local build passed. Weird.
>
> On Sat, Nov 29, 2014 at 7:20 PM, Craig Topper <craig.topper at gmail.com>
> wrote:
>
>> Author: ctopper
>> Date: Sat Nov 29 19:20:17 2014
>> New Revision: 222971
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=222971&view=rev
>> Log:
>> Revert r222957 "Replace std::map<K, V*> with std::map<K, V> to handle
>> ownership and deletion of the values."
>>
>> Upon further review I think the MultiClass is being copied into the map
>> instead of being moved due to the copy constructor on the nested Record
>> type. This ultimately got exposed when the vector in DefPrototype vector
>> was changed to hold unique_ptrs in another commit. This caused gcc 4.7 to
>> fail due to the use of the copy constructor on unique_ptr with the error
>> pointing back to one of the insert calls from this commit. Not sure why
>> clang was able to build.
>>
>> This reverts commit 710cdf729f84b428bf41aa8d32dbdb35fff79fde.
>>
>> Modified:
>>      llvm/trunk/lib/TableGen/TGParser.cpp
>>      llvm/trunk/lib/TableGen/TGParser.h
>>
>> Modified: llvm/trunk/lib/TableGen/TGParser.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=222971&r1=222970&r2=222971&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/TableGen/TGParser.cpp (original)
>> +++ llvm/trunk/lib/TableGen/TGParser.cpp Sat Nov 29 19:20:17 2014
>> @@ -459,12 +459,12 @@ MultiClass *TGParser::ParseMultiClassID(
>>       return nullptr;
>>     }
>>
>> -  auto it = MultiClasses.find(Lex.getCurStrVal());
>> -  if (it == MultiClasses.end())
>> +  MultiClass *Result = MultiClasses[Lex.getCurStrVal()];
>> +  if (!Result)
>>       TokError("Couldn't find multiclass '" + Lex.getCurStrVal() + "'");
>>
>>     Lex.Lex();
>> -  return &it->second;
>> +  return Result;
>>   }
>>
>>   /// ParseSubClassReference - Parse a reference to a subclass or to a
>> templated
>> @@ -2290,13 +2290,11 @@ bool TGParser::ParseMultiClass() {
>>       return TokError("expected identifier after multiclass for name");
>>     std::string Name = Lex.getCurStrVal();
>>
>> -  auto Result =
>> -    MultiClasses.insert(std::make_pair(Name,
>> -                                       MultiClass(Name,
>> Lex.getLoc(),Records)));
>> -  if (!Result.second)
>> +  if (MultiClasses.count(Name))
>>       return TokError("multiclass '" + Name + "' already defined");
>> -  CurMultiClass = &Result.first->second;
>>
>> +  CurMultiClass = MultiClasses[Name] = new MultiClass(Name,
>> +                                                      Lex.getLoc(),
>> Records);
>>     Lex.Lex();  // Eat the identifier.
>>
>>     // If there are template args, parse them.
>> @@ -2557,9 +2555,8 @@ bool TGParser::ParseDefm(MultiClass *Cur
>>       // To instantiate a multiclass, we need to first get the multiclass,
>> then
>>       // instantiate each def contained in the multiclass with the
>> SubClassRef
>>       // template parameters.
>> -    auto it = MultiClasses.find(Ref.Rec->getName());
>> -    assert(it != MultiClasses.end() && "Didn't lookup multiclass
>> correctly?");
>> -    MultiClass *MC = &it->second;
>> +    MultiClass *MC = MultiClasses[Ref.Rec->getName()];
>> +    assert(MC && "Didn't lookup multiclass correctly?");
>>       std::vector<Init*> &TemplateVals = Ref.TemplateArgs;
>>
>>       // Verify that the correct number of template arguments were
>> specified.
>>
>> Modified: llvm/trunk/lib/TableGen/TGParser.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.h?rev=222971&r1=222970&r2=222971&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/TableGen/TGParser.h (original)
>> +++ llvm/trunk/lib/TableGen/TGParser.h Sat Nov 29 19:20:17 2014
>> @@ -55,7 +55,7 @@ namespace llvm {
>>   class TGParser {
>>     TGLexer Lex;
>>     std::vector<std::vector<LetRecord> > LetStack;
>> -  std::map<std::string, MultiClass> MultiClasses;
>> +  std::map<std::string, MultiClass*> MultiClasses;
>>
>>     /// Loops - Keep track of any foreach loops we are within.
>>     ///
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141129/40063e21/attachment.html>


More information about the llvm-commits mailing list