aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/TableGen/TableGen.cpp
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2011-07-11 18:25:51 +0000
committerDavid Greene <greened@obbligato.org>2011-07-11 18:25:51 +0000
commitaf973b4f36b4a7f171a92d89d4a9c6156276a600 (patch)
treee05d900e5a00aa45185f9595e4bf44b7a11ac180 /llvm/utils/TableGen/TableGen.cpp
parent256d39d47d27a2752cdfba97e2ecf03ec44bb5b3 (diff)
downloadllvm-af973b4f36b4a7f171a92d89d4a9c6156276a600.zip
llvm-af973b4f36b4a7f171a92d89d4a9c6156276a600.tar.gz
llvm-af973b4f36b4a7f171a92d89d4a9c6156276a600.tar.bz2
[AVX] Make Inits Foldable
Manage Inits in a FoldingSet. This provides several benefits: - Memory for Inits is properly managed - Duplicate Inits are folded into Flyweights, saving memory - It enforces const-correctness, protecting against certain classes of bugs The above benefits allow Inits to be used in more contexts, which in turn provides more dynamism to TableGen. This enhanced capability will be used by the AVX code generator to a fold common patterns together. llvm-svn: 134907
Diffstat (limited to 'llvm/utils/TableGen/TableGen.cpp')
-rw-r--r--llvm/utils/TableGen/TableGen.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/llvm/utils/TableGen/TableGen.cpp b/llvm/utils/TableGen/TableGen.cpp
index e8eacb8..23a67c0 100644
--- a/llvm/utils/TableGen/TableGen.cpp
+++ b/llvm/utils/TableGen/TableGen.cpp
@@ -208,6 +208,7 @@ int main(int argc, char **argv) {
if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), File)) {
errs() << "Could not open input file '" << InputFilename << "': "
<< ec.message() <<"\n";
+ Init::ReleaseMemory();
return 1;
}
MemoryBuffer *F = File.take();
@@ -221,25 +222,30 @@ int main(int argc, char **argv) {
TGParser Parser(SrcMgr, Records);
- if (Parser.ParseFile())
+ if (Parser.ParseFile()) {
+ Init::ReleaseMemory();
return 1;
+ }
std::string Error;
tool_output_file Out(OutputFilename.c_str(), Error);
if (!Error.empty()) {
errs() << argv[0] << ": error opening " << OutputFilename
<< ":" << Error << "\n";
+ Init::ReleaseMemory();
return 1;
}
if (!DependFilename.empty()) {
if (OutputFilename == "-") {
errs() << argv[0] << ": the option -d must be used together with -o\n";
+ Init::ReleaseMemory();
return 1;
}
tool_output_file DepOut(DependFilename.c_str(), Error);
if (!Error.empty()) {
errs() << argv[0] << ": error opening " << DependFilename
<< ":" << Error << "\n";
+ Init::ReleaseMemory();
return 1;
}
DepOut.os() << DependFilename << ":";
@@ -382,11 +388,14 @@ int main(int argc, char **argv) {
}
default:
assert(1 && "Invalid Action");
+ Init::ReleaseMemory();
return 1;
}
// Declare success.
Out.keep();
+
+ Init::ReleaseMemory();
return 0;
} catch (const TGError &Error) {
@@ -399,5 +408,7 @@ int main(int argc, char **argv) {
errs() << argv[0] << ": Unknown unexpected exception occurred.\n";
}
+ Init::ReleaseMemory();
+
return 1;
}