================================================================================================
| 656 | |
| 657 | // ================================================================================================ |
| 658 | bool Program::linkImpl(const std::vector<Program*>& inputPrograms, amd::option::Options* options, |
| 659 | bool createLibrary) { |
| 660 | amd_comgr_data_set_t inputs; |
| 661 | |
| 662 | if (amd::Comgr::create_data_set(&inputs) != AMD_COMGR_STATUS_SUCCESS) { |
| 663 | buildLog_ += "Error: COMGR fails to create data set.\n"; |
| 664 | return false; |
| 665 | } |
| 666 | |
| 667 | size_t idx = 0; |
| 668 | for (auto program : inputPrograms) { |
| 669 | bool result = true; |
| 670 | if (program->llvmBinary_.empty()) { |
| 671 | result = (program->clBinary() != nullptr); |
| 672 | if (result) { |
| 673 | // We are using CL binary directly. |
| 674 | // Setup elfIn() and try to load llvmIR from binary |
| 675 | // This elfIn() will be released at the end of build by finiBuild(). |
| 676 | result = program->clBinary()->setElfIn(); |
| 677 | } |
| 678 | |
| 679 | if (result) { |
| 680 | result = |
| 681 | program->clBinary()->loadLlvmBinary(program->llvmBinary_, program->elfSectionType_); |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | if (result) { |
| 686 | result = (program->elfSectionType_ == amd::Elf::LLVMIR); |
| 687 | } |
| 688 | |
| 689 | if (result) { |
| 690 | std::string llvmName = "LLVM Binary " + std::to_string(idx); |
| 691 | result = (addCodeObjData(program->llvmBinary_.data(), program->llvmBinary_.size(), |
| 692 | AMD_COMGR_DATA_KIND_BC, llvmName.c_str(), |
| 693 | &inputs) == AMD_COMGR_STATUS_SUCCESS); |
| 694 | } |
| 695 | |
| 696 | if (!result) { |
| 697 | amd::Comgr::destroy_data_set(inputs); |
| 698 | buildLog_ += "Error: Linking bitcode failed: failing to generate LLVM binary.\n"; |
| 699 | return false; |
| 700 | } |
| 701 | |
| 702 | idx++; |
| 703 | |
| 704 | // release elfIn() for the program |
| 705 | program->clBinary()->resetElfIn(); |
| 706 | } |
| 707 | |
| 708 | // create the linked output |
| 709 | amd_comgr_data_set_t output; |
| 710 | if (amd::Comgr::create_data_set(&output) != AMD_COMGR_STATUS_SUCCESS) { |
| 711 | buildLog_ += "Error: COMGR fails to create output buffer for LLVM bitcode.\n"; |
| 712 | amd::Comgr::destroy_data_set(inputs); |
| 713 | return false; |
| 714 | } |
| 715 |
nothing calls this directly
no test coverage detected