From 770a084e70e4b2654462867af2f6a1e6b620d62e Mon Sep 17 00:00:00 2001
From: foreman
Date: Fri, 23 Jan 2015 11:35:29 -0500
Subject: [PATCH] P4 to Git Change 1114755 by emankov@em-hsa-amd on 2015/01/23
11:28:27
ECR #333753 - Partial fix for Bug 10478 "Fix -fno-bin-llvmir/-fno-bin-hsail options"
If option -fno-bin-llvmi is set, .llvmir section is deleted from BIF on CG phase instead of FE. Both HSA & AMDIL are affected.
[Fixed] -fno-bin-llvm option causes clBuildProgram fail with error -11.
Took place only if compiled from OpenCL
[TODO] If possible -fno-bin-hsail should avoid putting HSAIL binary (BRIG) into BIF.
[Tests] pre check-in, make smoke, complib
[Reviewers] Brian Sumner, Nikolay Haustov
Affected files ...
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/frontend.cpp#31 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/frontend_clang.cpp#17 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/v0_8/if_acl.cpp#58 edit
... //depot/stg/opencl/drivers/opencl/compiler/tools/aoc2/aoc2.cpp#63 edit
... //depot/stg/opencl/drivers/opencl/tests/hsa/src/complib/options/-fbin-llvmir/HelloWorld_Kernel_cl.cl#1 add
... //depot/stg/opencl/drivers/opencl/tests/hsa/src/complib/options/-fno-bin-llvmir/HelloWorld_Kernel_cl.cl#1 add
... //depot/stg/opencl/drivers/opencl/tests/hsa/tlst/complib.tlst#3 edit
---
rocclr/compiler/lib/backends/common/frontend.cpp | 15 ++-------------
.../lib/backends/common/frontend_clang.cpp | 15 ++-------------
.../compiler/lib/backends/common/v0_8/if_acl.cpp | 5 ++++-
3 files changed, 8 insertions(+), 27 deletions(-)
diff --git a/rocclr/compiler/lib/backends/common/frontend.cpp b/rocclr/compiler/lib/backends/common/frontend.cpp
index a89e7802a1..1ef0352303 100644
--- a/rocclr/compiler/lib/backends/common/frontend.cpp
+++ b/rocclr/compiler/lib/backends/common/frontend.cpp
@@ -269,19 +269,8 @@ amdcl::OCLFrontend::compileCommand(const std::string& singleSrc)
if (!llvmbinary_) {
ret |= 1;
}
- if (!ret &&
-#if WITH_VERSION_0_8
- checkFlag(aclutGetCaps(Elf()), capSaveLLVMIR)
-#elif WITH_VERSION_0_9
- Options()->oVariables->BinLLVMIR
-#else
-#error "The current version was not handled correctly here."
-#endif
- ) {
- CL()->clAPI.insSec(CL(), Elf(), Source().data(),
- Source().size(), aclLLVMIR);
- } else {
- CL()->clAPI.remSec(CL(), Elf(), aclLLVMIR);
+ if (!ret) {
+ CL()->clAPI.insSec(CL(), Elf(), Source().data(), Source().size(), aclLLVMIR);
}
log_ += loadFileToStr(logFile);
amd::Os::unlink(logFile.c_str());
diff --git a/rocclr/compiler/lib/backends/common/frontend_clang.cpp b/rocclr/compiler/lib/backends/common/frontend_clang.cpp
index b34b71cbe9..650cd079c2 100644
--- a/rocclr/compiler/lib/backends/common/frontend_clang.cpp
+++ b/rocclr/compiler/lib/backends/common/frontend_clang.cpp
@@ -190,19 +190,8 @@ int amdcl::ClangOCLFrontend::compileCommand(const std::string& src) {
ret |= 1;
}
- if (!ret &&
-#if WITH_VERSION_0_8
- checkFlag(aclutGetCaps(Elf()), capSaveLLVMIR)
-#elif WITH_VERSION_0_9
- Options()->oVariables->BinLLVMIR
-#else
-#error "The current version was not handled correctly here."
-#endif
- ) {
- CL()->clAPI.insSec(CL(), Elf(), Source().data(),
- Source().size(), aclLLVMIR);
- } else {
- CL()->clAPI.remSec(CL(), Elf(), aclLLVMIR);
+ if (!ret) {
+ CL()->clAPI.insSec(CL(), Elf(), Source().data(), Source().size(), aclLLVMIR);
}
log_ += logFromClang;
if (isCpuTarget(Elf()->target)
diff --git a/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp b/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp
index e3197c9231..179d9b4640 100644
--- a/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp
+++ b/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp
@@ -1214,7 +1214,10 @@ aclCompileInternal(
}
dataStr = *cg;
}
-
+ if (!checkFlag(aclutGetCaps(bin), capSaveLLVMIR) ||
+ !(reinterpret_cast(ald))->Options()->oVariables->BinLLVMIR) {
+ cl->clAPI.remSec(cl, bin, aclLLVMIR);
+ }
cl->cgAPI.fini(ald);
if (error_code != ACL_SUCCESS) {
goto internal_compile_failure;