summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-10-06 06:29:41 +0000
committerChris Lattner <sabre@nondot.org>2007-10-06 06:29:41 +0000
commitb5fc6fbcfc4299db190634c9b1c28cfc032d44e6 (patch)
treebdc02dc15efdf126b88f40512a8bc25d614f14e2
parent2a9bcb9ea7866b58a24722babb6183f99653a8e1 (diff)
downloadbcm5719-llvm-b5fc6fbcfc4299db190634c9b1c28cfc032d44e6.tar.gz
bcm5719-llvm-b5fc6fbcfc4299db190634c9b1c28cfc032d44e6.zip
speed up clang startup time by about 23% by avoiding lots of
stringmap operations when there are no secondary targets. llvm-svn: 42688
-rw-r--r--clang/Basic/TargetInfo.cpp50
-rw-r--r--clang/clang.xcodeproj/project.pbxproj1
2 files changed, 29 insertions, 22 deletions
diff --git a/clang/Basic/TargetInfo.cpp b/clang/Basic/TargetInfo.cpp
index 2c476b8627c..afa4285aaa9 100644
--- a/clang/Basic/TargetInfo.cpp
+++ b/clang/Basic/TargetInfo.cpp
@@ -88,6 +88,35 @@ static void GetTargetDefineMap(const TargetInfoImpl *Target,
/// getTargetDefines - Appends the target-specific #define values for this
/// target set to the specified buffer.
void TargetInfo::getTargetDefines(std::vector<char> &Buffer) {
+ // If we have no secondary targets, be a bit more efficient.
+ if (SecondaryTargets.empty()) {
+ std::vector<std::string> PrimaryDefines;
+ PrimaryTarget->getTargetDefines(PrimaryDefines);
+
+ for (unsigned i = 0, e = PrimaryDefines.size(); i != e; ++i) {
+ // Always produce a #define.
+ const char *Command = "#define ";
+ Buffer.insert(Buffer.end(), Command, Command+strlen("#define "));
+
+ const std::string &Val = PrimaryDefines[i];
+ unsigned EqualPos = Val.find('=');
+ if (EqualPos != std::string::npos) {
+ // Insert "defname defvalue\n".
+ Buffer.insert(Buffer.end(), Val.begin(), Val.begin()+EqualPos);
+ Buffer.push_back(' ');
+ Buffer.insert(Buffer.end(), Val.begin()+EqualPos+1, Val.end());
+ Buffer.push_back('\n');
+ } else {
+ // Insert "defname 1\n".
+ Buffer.insert(Buffer.end(), Val.begin(), Val.end());
+ Buffer.push_back(' ');
+ Buffer.push_back('1');
+ Buffer.push_back('\n');
+ }
+ }
+ return;
+ }
+
// This is tricky in the face of secondary targets. Specifically,
// target-specific #defines that are present and identical across all
// secondary targets are turned into #defines, #defines that are present in
@@ -101,27 +130,6 @@ void TargetInfo::getTargetDefines(std::vector<char> &Buffer) {
llvm::StringMap<std::string> PrimaryDefines;
GetTargetDefineMap(PrimaryTarget, PrimaryDefines);
- // If we have no secondary targets, be a bit more efficient.
- if (SecondaryTargets.empty()) {
- for (llvm::StringMap<std::string>::iterator I =
- PrimaryDefines.begin(), E = PrimaryDefines.end(); I != E; ++I) {
- // If this define is non-portable, turn it into #define_target, otherwise
- // just use #define.
- const char *Command = "#define ";
- Buffer.insert(Buffer.end(), Command, Command+strlen(Command));
-
- // Insert "defname defvalue\n".
- const char *KeyStart = I->getKeyData();
- const char *KeyEnd = KeyStart + I->getKeyLength();
-
- Buffer.insert(Buffer.end(), KeyStart, KeyEnd);
- Buffer.push_back(' ');
- Buffer.insert(Buffer.end(), I->getValue().begin(), I->getValue().end());
- Buffer.push_back('\n');
- }
- return;
- }
-
// Get the sets of secondary #defines.
llvm::StringMap<std::string> *SecondaryDefines
= new llvm::StringMap<std::string>[SecondaryTargets.size()];
diff --git a/clang/clang.xcodeproj/project.pbxproj b/clang/clang.xcodeproj/project.pbxproj
index 3e20445759c..22a3173a065 100644
--- a/clang/clang.xcodeproj/project.pbxproj
+++ b/clang/clang.xcodeproj/project.pbxproj
@@ -739,7 +739,6 @@
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
- compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
projectDirPath = "";
OpenPOWER on IntegriCloud