Closed yxsamliu closed 7 years ago
Which temp files does clang generate when compiling directly from OpenCL to ISA? Also, are the flags -print-before-all or -print-after-all enough to get the dumps that you want?
When the driver is called by runtime, the cl file, pch file, and bc files are saved as temp files and clang is called to compile the cl file first to bc, then clang is called again to generate the obj file.
The CC_PRINT_OPTIONS=1 will output something like
"/path/to/clang" "-cc1" "-triple" "amdgcn-amd-amdhsa-opencl" "-emit-llvm-bc" "-emit-llvm-uselists" "-disable-free" "-main-file-name" "t_13055_3.cl" "-mrelocation-model" "static" "-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-target-cpu" "fiji" "-dwarf-column-info" "-debugger-tuning=gdb" "-coverage-notes-file" "/tmp/AMD_13055_1/t_13055_4.gcno" "-resource-dir" "/../lib/clang/4.0" "-include-pch" "/tmp/AMD_13055_1/t_13055_2" "-D" "AMD=1" "-D" "gfx803=1" "-D" "gfx803=1" "-D" "__OPENCL_VERSION=120" "-D" "IMAGE_SUPPORT=1" "-D" "cl_khr_fp64=1" "-D" "cl_amd_fp64=1" "-D" "cl_khr_global_int32_base_atomics=1" "-D" "cl_khr_global_int32_extended_atomics=1" "-D" "cl_khr_local_int32_base_atomics=1" "-D" "cl_khr_local_int32_extended_atomics=1" "-D" "cl_khr_3d_image_writes=1" "-D" "cl_khr_byte_addressable_store=1" "-D" "cl_khr_gl_sharing=1" "-D" "cl_amd_media_ops=1" "-D" "cl_amd_media_ops2=1" "-D" "cl_khr_subgroups=1" "-D" "cl_khr_depth_images=1" "-O3" "-fdebug-compilation-dir" "/2.0/x86_64/math_brute_force" "-ferror-limit" "19" "-fmessage-length" "161" "-cl-kernel-arg-info" "-cl-std=CL1.2" "-fobjc-runtime=gcc" "-fdiagnostics-show-option" "-vectorize-loops" "-vectorize-slp" "-fno-validate-pch" "-o" "/tmp/AMD_13055_1/t_13055_4.bc" "-x" "cl" "/tmp/AMD_13055_1/t_13055_3.cl"
I want to be able to rerun these commands exactly as they are. Then I need the driver do not delete the temp files.
This can be done by changing AmdCompiler.cpp
TempFile::~TempFile() { if (getenv("KEEP_TMP")) return; std::remove(Name().c_str()); }
TempDir::~TempDir() { if (getenv("KEEP_TMP")) return;
RemoveDirectory(Name().c_str());
rmdir(Name().c_str());
}
-print-before-all won't help since I need to rerun clang as the driver does.
Done. SHA-1: cb13e4a9
It is pretty inconvenient to debug the compiler without a way to keep the temp files generated during the compilation. Can we add an env var to keep the temp files? Then we can simply rerun the command dumped by CC_PRINT_OPTIONS=1 to repeat the compilation steps.
Thanks.