@@ -116,7 +116,6 @@ bool RTCProgram::findIsa() {
116116
117117// RTC Compile Program Member Functions
118118void RTCProgram::AppendOptions (const std::string app_env_var, std::vector<std::string>* options) {
119-
120119 if (options == nullptr ) {
121120 LogError (" Append options passed is nullptr." );
122121 return ;
@@ -261,10 +260,6 @@ bool RTCCompileProgram::transformOptions(std::vector<std::string>& compile_optio
261260 i = " --offload-arch=" + val;
262261 continue ;
263262 }
264- if (i == " --save-temps" ) {
265- settings_.dumpISA = true ;
266- continue ;
267- }
268263 }
269264
270265 // Removed consumed options
@@ -300,78 +295,28 @@ bool RTCCompileProgram::compile(const std::vector<std::string>& options, bool fg
300295 compileOpts.reserve (compile_options_.size () + options.size () + 2 );
301296 compileOpts.insert (compileOpts.end (), options.begin (), options.end ());
302297
303- if (!fgpu_rdc_) {
304- compileOpts.push_back (" -Xclang" );
305- compileOpts.push_back (" -disable-llvm-passes" );
306- }
307-
308298 if (!transformOptions (compileOpts)) {
309299 LogError (" Error in hiprtc: unable to transform options" );
310300 return false ;
311301 }
312302
313- if (!compileToBitCode (compile_input_, isa_, compileOpts, build_log_, LLVMBitcode_)) {
314- LogError (" Error in hiprtc: unable to compile source to bitcode" );
315- return false ;
316- }
317-
318- if (fgpu_rdc_ && !mangled_names_.empty ()) {
319- if (!fillMangledNames (LLVMBitcode_, mangled_names_, true )) {
320- LogError (" Error in hiprtc: unable to fill mangled names" );
303+ if (fgpu_rdc_) {
304+ if (!compileToBitCode (compile_input_, isa_, compileOpts, build_log_, LLVMBitcode_)) {
305+ LogError (" Error in hiprtc: unable to compile source to bitcode" );
321306 return false ;
322307 }
323-
324- return true ;
325- }
326-
327- std::string linkFileName = " linked" ;
328- if (!addCodeObjData (link_input_, LLVMBitcode_, linkFileName, AMD_COMGR_DATA_KIND_BC)) {
329- LogError (" Error in hiprtc: unable to add linked code object" );
330- return false ;
331- }
332-
333- std::vector<char > LinkedLLVMBitcode;
334- if (!linkLLVMBitcode (link_input_, isa_, link_options_, build_log_, LinkedLLVMBitcode)) {
335- LogError (" Error in hiprtc: unable to add device libs to linked bitcode" );
336- return false ;
337- }
338-
339- std::string linkedFileName = " LLVMBitcode.bc" ;
340- if (!addCodeObjData (exec_input_, LinkedLLVMBitcode, linkedFileName, AMD_COMGR_DATA_KIND_BC)) {
341- LogError (" Error in hiprtc: unable to add device libs linked code object" );
342- return false ;
343- }
344-
345- std::vector<std::string> exe_options;
346- // Find the options passed by the app which can be used during BC to Relocatable phase.
347- if (!findExeOptions (options, exe_options)) {
348- LogError (" Error in hiprtc: unable to find executable options" );
349- return false ;
350- }
351-
352- std::vector<std::string> exeOpts (exe_options_);
353- exeOpts.reserve (exeOpts.size () + exe_options.size () + 2 );
354- // Add these below options by default for optimizations during BC to Relocatable phase.
355- exeOpts.push_back (" -mllvm" );
356- exeOpts.push_back (" -amdgpu-internalize-symbols" );
357- // User provided options are appended at the end since they can override the above
358- // default options if necessary
359- exeOpts.insert (exeOpts.end (), exe_options.begin (), exe_options.end ());
360-
361- if (settings_.dumpISA ) {
362- if (!dumpIsaFromBC (exec_input_, isa_, exeOpts, name_, build_log_)) {
363- LogError (" Error in hiprtc: unable to dump isa code" );
308+ } else {
309+ LogInfo (" Using the new path of comgr" );
310+ if (!compileToExecutable (compile_input_, isa_, compileOpts, link_options_, build_log_,
311+ executable_)) {
312+ LogError (" Failing to compile to realloc" );
364313 return false ;
365314 }
366315 }
367316
368- if (!createExecutable (exec_input_, isa_, exeOpts, build_log_, executable_)) {
369- LogError (" Error in hiprtc: unable to create executable" );
370- return false ;
371- }
372-
373317 if (!mangled_names_.empty ()) {
374- if (!fillMangledNames (executable_, mangled_names_, false )) {
318+ auto & compile_step_output = fgpu_rdc_ ? LLVMBitcode_ : executable_;
319+ if (!fillMangledNames (compile_step_output, mangled_names_, fgpu_rdc_)) {
375320 LogError (" Error in hiprtc: unable to fill mangled names" );
376321 return false ;
377322 }
@@ -380,6 +325,7 @@ bool RTCCompileProgram::compile(const std::vector<std::string>& options, bool fg
380325 return true ;
381326}
382327
328+
383329void RTCCompileProgram::stripNamedExpression (std::string& strippedName) {
384330 if (strippedName.back () == ' )' ) {
385331 strippedName.pop_back ();
@@ -453,7 +399,6 @@ RTCLinkProgram::RTCLinkProgram(std::string name) : RTCProgram(name) {
453399bool RTCLinkProgram::AddLinkerOptions (unsigned int num_options, hiprtcJIT_option* options_ptr,
454400 void ** options_vals_ptr) {
455401 for (size_t opt_idx = 0 ; opt_idx < num_options; ++opt_idx) {
456-
457402 switch (options_ptr[opt_idx]) {
458403 case HIPRTC_JIT_MAX_REGISTERS:
459404 link_args_.max_registers_ = *(reinterpret_cast <unsigned int *>(&options_vals_ptr[opt_idx]));
0 commit comments