From 2300414425ab918ba52223e4a698c70bcbf02cc4 Mon Sep 17 00:00:00 2001 From: foreman Date: Fri, 17 Jun 2016 13:49:36 -0400 Subject: [PATCH] P4 to Git Change 1281101 by smekhano@stas-rampitec-hsa on 2016/06/17 13:42:09 SWDEV-95698 - Complib: set data layout string from the subtarget in codegen This logic was broken since llvm 3.6 merge and datalayout was not set as supposed. This results in a different compilation results with complib and llc. In addition that leads to the suboptimal codegen. Testing: smoke, precheckin, llc_opt, ocl_features, vec_ldst, ocl_sdk_aoc2_compare_main Reviewed by Evgeny Mankov Affected files ... ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/codegen.cpp#71 edit ... //depot/stg/opencl/drivers/opencl/tests/hsa/src/ocl/regression/95698/calcweight-nounroll-min.cl#1 add ... //depot/stg/opencl/drivers/opencl/tests/hsa/tlst/ocl_regression.tlst#37 edit --- rocclr/compiler/lib/backends/common/codegen.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/rocclr/compiler/lib/backends/common/codegen.cpp b/rocclr/compiler/lib/backends/common/codegen.cpp index 10bdf5542a..92908ab058 100644 --- a/rocclr/compiler/lib/backends/common/codegen.cpp +++ b/rocclr/compiler/lib/backends/common/codegen.cpp @@ -32,6 +32,7 @@ #include "llvm/Support/TargetRegistry.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" +#include "llvm/Target/TargetSubtargetInfo.h" #include "llvm/ExecutionEngine/JITEventListener.h" #include "llvm/ExecutionEngine/MCJIT.h" #include @@ -555,15 +556,10 @@ llvmCodeGen( // Basic Block. PassManager Passes; - // Add the target data from the target machine, if it exists, or the module. -#if defined(LEGACY_COMPLIB) - if (const DataLayout *TD = Target.getDataLayout()) - Passes.add(new DataLayout(*TD)); - else - Passes.add(new DataLayout(&mod)); -#else + // Add the target data from the target machine, if it exists. + if (const DataLayout *TD = Target.getSubtargetImpl()->getDataLayout()) + mod.setDataLayout(TD); Passes.add(new DataLayoutPass()); -#endif // Override default to generate verbose assembly, if the device is not the GPU. // The GPU sets this in AMDILTargetMachine.cpp.