From ae3a15d33105495cbcb403a0c87d9b56cfe2cc5b Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 19 Mar 2015 20:50:35 -0400
Subject: [PATCH] P4 to Git Change 1132635 by smekhano@stas-rampitec-hsa on
2015/03/19 17:27:36
ECR #333753 - part of the changes to use llvm 3.6
Testing: smoke, precheckin
Reviewed by Brian Sumner
Affected files ...
... //depot/stg/opencl/drivers/opencl/compiler/lib/api/v0_8/acl.cpp#27 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/linker.cpp#122 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/sync.cpp#1 add
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/sync.hpp#1 add
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/v0_8/if_acl.cpp#63 edit
[ROCm/clr commit: 7168d2421085ece455bb7de618b6e0319d8f357d]
---
.../compiler/lib/backends/common/linker.cpp | 6 ++---
.../compiler/lib/backends/common/sync.cpp | 24 +++++++++++++++++++
.../compiler/lib/backends/common/sync.hpp | 13 ++++++++++
.../lib/backends/common/v0_8/if_acl.cpp | 5 ++--
4 files changed, 42 insertions(+), 6 deletions(-)
create mode 100644 projects/clr/rocclr/compiler/lib/backends/common/sync.cpp
create mode 100644 projects/clr/rocclr/compiler/lib/backends/common/sync.hpp
diff --git a/projects/clr/rocclr/compiler/lib/backends/common/linker.cpp b/projects/clr/rocclr/compiler/lib/backends/common/linker.cpp
index c8e5bc1429..99d15def97 100644
--- a/projects/clr/rocclr/compiler/lib/backends/common/linker.cpp
+++ b/projects/clr/rocclr/compiler/lib/backends/common/linker.cpp
@@ -115,8 +115,7 @@ using namespace llvm;
inline llvm::Module*
LoadFile(const std::string &Filename, LLVMContext& Context)
{
- bool Exists;
- if (sys::fs::exists(Filename, Exists) || !Exists) {
+ if (!sys::fs::exists(Filename)) {
// dbgs() << "Bitcode file: '" << Filename.c_str() << "' does not exist.\n";
return 0;
}
@@ -137,8 +136,7 @@ inline llvm::Module*
inline llvm::Module*
LoadLibrary(const std::string& libFile, LLVMContext& Context, MemoryBuffer** Buffer) {
- bool Exists;
- if (sys::fs::exists(libFile, Exists) || !Exists) {
+ if (!sys::fs::exists(libFile)) {
// dbgs() << "Bitcode file: '" << Filename.c_str() << "' does not exist.\n";
return 0;
}
diff --git a/projects/clr/rocclr/compiler/lib/backends/common/sync.cpp b/projects/clr/rocclr/compiler/lib/backends/common/sync.cpp
new file mode 100644
index 0000000000..45183fea6e
--- /dev/null
+++ b/projects/clr/rocclr/compiler/lib/backends/common/sync.cpp
@@ -0,0 +1,24 @@
+//
+// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
+//
+#include "sync.hpp"
+#include "llvm/Support/Mutex.h"
+#include "llvm/Support/Threading.h"
+
+
+static llvm::sys::MutexImpl mtx;
+
+namespace amdcl
+{
+
+void acquire_global_lock() {
+ if (llvm::llvm_is_multithreaded())
+ mtx.acquire();
+}
+
+void release_global_lock() {
+ if (llvm::llvm_is_multithreaded())
+ mtx.release();
+}
+
+} // namespace amdcl
diff --git a/projects/clr/rocclr/compiler/lib/backends/common/sync.hpp b/projects/clr/rocclr/compiler/lib/backends/common/sync.hpp
new file mode 100644
index 0000000000..1d62a81934
--- /dev/null
+++ b/projects/clr/rocclr/compiler/lib/backends/common/sync.hpp
@@ -0,0 +1,13 @@
+//
+// Copyright (c) 2008 Advanced Micro Devices, Inc. All rights reserved.
+//
+#ifndef _BE_SYNC_HPP_
+#define _BE_SYNC_HPP_
+
+namespace amdcl
+{
+ void acquire_global_lock();
+
+ void release_global_lock();
+} // namespace amdcl
+#endif // _BE_SYNC_HPP_
diff --git a/projects/clr/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp b/projects/clr/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp
index e7329678a6..ad666fe39a 100644
--- a/projects/clr/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp
+++ b/projects/clr/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp
@@ -31,6 +31,7 @@
#include "utils/options.hpp"
#include "utils/target_mappings.h"
#include "utils/versions.hpp"
+#include "sync.hpp"
#include "llvm/LLVMContext.h"
#include "llvm/Analysis/Passes.h"
@@ -55,7 +56,7 @@ aclLoaderData * ACL_API_ENTRY
if_aclCompilerInit(aclCompiler *cl, aclBinary *bin,
aclLogFunction log, acl_error *error)
{
- llvm::llvm_acquire_global_lock();
+ amdcl::acquire_global_lock();
char* timing = ::getenv("AMD_DEBUG_HLC_ENABLE_TIMING");
if (timing && (timing[0] == '1'))
llvm::TimePassesIsEnabled = true;
@@ -85,7 +86,7 @@ if_aclCompilerInit(aclCompiler *cl, aclBinary *bin,
llvm::initializeVerifierPass(Registry);
llvm::initializeDominatorTreePass(Registry);
llvm::initializePreVerifierPass(Registry);
- llvm::llvm_release_global_lock();
+ amdcl::release_global_lock();
if (error) (*error) = ACL_SUCCESS;
return reinterpret_cast(cl);
}