Tweak code into an equivalent form for which icc

doesn't warn about unreachable instructions.  Patch
by Erick Tryzelaar (#111).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81110 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan Sands
2009-09-06 10:53:22 +00:00
parent 12fd767ed8
commit 740eb5323e
4 changed files with 33 additions and 33 deletions

View File

@@ -93,32 +93,36 @@ namespace llvm
MutexImpl(rec), acquired(0), recursive(rec) { } MutexImpl(rec), acquired(0), recursive(rec) { }
bool acquire() { bool acquire() {
if (!mt_only || llvm_is_multithreaded()) if (!mt_only || llvm_is_multithreaded()) {
return MutexImpl::acquire(); return MutexImpl::acquire();
} else {
// Single-threaded debugging code. This would be racy in multithreaded // Single-threaded debugging code. This would be racy in
// mode, but provides not sanity checks in single threaded mode. // multithreaded mode, but provides not sanity checks in single
// threaded mode.
assert((recursive || acquired == 0) && "Lock already acquired!!"); assert((recursive || acquired == 0) && "Lock already acquired!!");
++acquired; ++acquired;
return true; return true;
} }
}
bool release() { bool release() {
if (!mt_only || llvm_is_multithreaded()) if (!mt_only || llvm_is_multithreaded()) {
return MutexImpl::release(); return MutexImpl::release();
} else {
// Single-threaded debugging code. This would be racy in multithreaded // Single-threaded debugging code. This would be racy in
// mode, but provides not sanity checks in single threaded mode. // multithreaded mode, but provides not sanity checks in single
// threaded mode.
assert(((recursive && acquired) || (acquired == 1)) && assert(((recursive && acquired) || (acquired == 1)) &&
"Lock not acquired before release!"); "Lock not acquired before release!");
--acquired; --acquired;
return true; return true;
} }
}
bool tryacquire() { bool tryacquire() {
if (!mt_only || llvm_is_multithreaded()) if (!mt_only || llvm_is_multithreaded())
return MutexImpl::tryacquire(); return MutexImpl::tryacquire();
return true; else return true;
} }
private: private:

View File

@@ -115,8 +115,7 @@ MutexImpl::acquire()
int errorcode = pthread_mutex_lock(mutex); int errorcode = pthread_mutex_lock(mutex);
return errorcode == 0; return errorcode == 0;
} } else return false;
return false;
} }
bool bool
@@ -129,8 +128,7 @@ MutexImpl::release()
int errorcode = pthread_mutex_unlock(mutex); int errorcode = pthread_mutex_unlock(mutex);
return errorcode == 0; return errorcode == 0;
} } else return false;
return false;
} }
bool bool
@@ -143,8 +141,7 @@ MutexImpl::tryacquire()
int errorcode = pthread_mutex_trylock(mutex); int errorcode = pthread_mutex_trylock(mutex);
return errorcode == 0; return errorcode == 0;
} } else return false;
return false;
} }
} }

View File

@@ -117,8 +117,7 @@ RWMutexImpl::reader_acquire()
int errorcode = pthread_rwlock_rdlock(rwlock); int errorcode = pthread_rwlock_rdlock(rwlock);
return errorcode == 0; return errorcode == 0;
} } else return false;
return false;
} }
bool bool
@@ -131,8 +130,7 @@ RWMutexImpl::reader_release()
int errorcode = pthread_rwlock_unlock(rwlock); int errorcode = pthread_rwlock_unlock(rwlock);
return errorcode == 0; return errorcode == 0;
} } else return false;
return false;
} }
bool bool
@@ -145,8 +143,7 @@ RWMutexImpl::writer_acquire()
int errorcode = pthread_rwlock_wrlock(rwlock); int errorcode = pthread_rwlock_wrlock(rwlock);
return errorcode == 0; return errorcode == 0;
} } else return false;
return false;
} }
bool bool
@@ -159,8 +156,7 @@ RWMutexImpl::writer_release()
int errorcode = pthread_rwlock_unlock(rwlock); int errorcode = pthread_rwlock_unlock(rwlock);
return errorcode == 0; return errorcode == 0;
} } else return false;
return false;
} }
} }

View File

@@ -181,25 +181,28 @@ void Process::PreventCoreFiles() {
bool Process::StandardInIsUserInput() { bool Process::StandardInIsUserInput() {
#if HAVE_ISATTY #if HAVE_ISATTY
return isatty(0); return isatty(0);
#endif #else
// If we don't have isatty, just return false. // If we don't have isatty, just return false.
return false; return false;
#endif
} }
bool Process::StandardOutIsDisplayed() { bool Process::StandardOutIsDisplayed() {
#if HAVE_ISATTY #if HAVE_ISATTY
return isatty(1); return isatty(1);
#endif #else
// If we don't have isatty, just return false. // If we don't have isatty, just return false.
return false; return false;
#endif
} }
bool Process::StandardErrIsDisplayed() { bool Process::StandardErrIsDisplayed() {
#if HAVE_ISATTY #if HAVE_ISATTY
return isatty(2); return isatty(2);
#endif #else
// If we don't have isatty, just return false. // If we don't have isatty, just return false.
return false; return false;
#endif
} }
static unsigned getColumns(int FileID) { static unsigned getColumns(int FileID) {