From b49c9b62b069ff89ff40dbe6ad0e628b8368353b Mon Sep 17 00:00:00 2001
From: foreman
Date: Fri, 5 Jun 2015 14:12:54 -0400
Subject: [PATCH] P4 to Git Change 1158377 by smekhano@stas-rampitec-hsa on
2015/06/05 14:01:35
ECR #333753 - HSA HLC: fix for cannot select __hsail_memfence intrinsic under -O0
Fix for bug 10808.
We have missed always inliner pass on runtime only for -O0 build. aoc2 and opt.exe run it, but conformance binary itself does not.
As a result a set of always_inline functions was not inlined and we cannot lower __hsail_memfence call which should accept only immediate arguments,
where we are passing call arguments if it is not inlined.
The fix ensures we are running at either of two inliner always if building for GPU. Under -O0 that is always inliner pass.
In addition three helper functions in the library were marked as always_inline to ensure these are also inlined into atomic_work_item_fence() and thus
supply immediate arguments into __hsail_memfence call. The dialect we are using in clang to build the library does not provide inlining of a "static inline"
functions, so an additional attribute was needed.
Also the fix unifies -O0 inliner invocation code for offline opt.exe and complib.
Additionally fixed the complib bug, under -O0 OptLevel::setup() extis early, so does not change HLC_Disable_Amd_Inline_All variable.
This variable contains the value left after blit kernels compilation. Added corresponding setup code to GPUO0OptLevel::optimize().
In a long run we should call AMDPassManagerBuilder under -O0 as well and handle all that logic there.
Testing: test_c11_atomics atomic_fence -O0, pipes -O0, smoke, precheckin, ocl_features
Reviewed by Brian Sumner, Matthew Arsenalut and Evgeny Mankov
Affected files ...
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/opt_level.cpp#27 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/tools/opt/opt.cpp#70 edit
... //depot/stg/opencl/drivers/opencl/library/hsa/hsail/src/misc/atomicWorkItemFence.cl#9 edit
---
.../compiler/lib/backends/common/opt_level.cpp | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/rocclr/compiler/lib/backends/common/opt_level.cpp b/rocclr/compiler/lib/backends/common/opt_level.cpp
index e1130028c7..c755e00c6f 100644
--- a/rocclr/compiler/lib/backends/common/opt_level.cpp
+++ b/rocclr/compiler/lib/backends/common/opt_level.cpp
@@ -204,14 +204,20 @@ GPUO0OptLevel::optimize(aclBinary *elf, Module *input, bool isGPU)
HLC_HSAIL_Enable_Calls = false;
HLC_Disable_Amd_Inline_All = false;
}
+ else if (HLC_HSAIL_Enable_Calls) {
+ HLC_Disable_Amd_Inline_All = true;
+ }
+ else {
+ HLC_Disable_Amd_Inline_All = false;
+ }
Passes().add(createAMDSymbolLinkagePass(true, NULL));
Passes().add(createGlobalOptimizerPass());
- if (!HLC_Disable_Amd_Inline_All && !DisableInline ) {
- if (HLC_Force_Always_Inliner_Pass) {
- Passes().add(createAlwaysInlinerPass());
- } else {
- Passes().add(createAMDInlineAllPass(true));
- }
+ if (!HLC_Disable_Amd_Inline_All &&
+ !DisableInline &&
+ !HLC_Force_Always_Inliner_Pass) {
+ Passes().add(createAMDInlineAllPass(true));
+ } else {
+ Passes().add(createAlwaysInlinerPass());
}
}
#endif