Skip to content

Commit f8127f3

Browse files
lwesiersigcbot
authored andcommitted
Redesign and correct building of BiFModule
Corrected the cmake setup of BiFModule and simplified.
1 parent 9cf5a0b commit f8127f3

File tree

13 files changed

+543
-581
lines changed

13 files changed

+543
-581
lines changed

IGC/BiFManager/BiFManagerCommon.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ void CollectBuiltinsPass::visitCallInst(llvm::CallInst &callInst) {
4141
}
4242
}
4343
}
44+

IGC/BiFManager/BiFManagerCommon.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class BiFManagerCommon {
6969
static size_t getHash(const std::string &FlagName);
7070

7171
protected:
72+
7273
inline static const std::string bifMark = "igc_bif";
7374

7475
llvm::LLVMContext &Context;

IGC/BiFManager/BiFManagerTool.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ void BiFManagerTool::writeHashMapSingle(llvm::raw_fd_ostream &fileDataHeader, Bi
5858
std::string funcName = *rec_i;
5959
std::string funcKey;
6060
funcKey = funcName;
61-
6261
auto listOfDependency = ListOfFunctions->operator[](funcKey);
6362

6463
std::string record = "\n // bif func: " + funcName;
@@ -91,8 +90,7 @@ void BiFManagerTool::writeHashMap(llvm::raw_fd_ostream &fileDataHeader, BiFDicti
9190
for (auto rec_i = ListOfFunctions->begin(); rec_i != ListOfFunctions->end(); ++rec_i) {
9291
const auto &record_inst = *rec_i;
9392
const std::string &funcName =
94-
record_inst.first;
95-
93+
record_inst.first;
9694
auto funcNameSize = funcName.size();
9795

9896
if (sortBySizeNameFunc.find(funcNameSize) == sortBySizeNameFunc.end()) {
@@ -398,6 +396,7 @@ void BiFManagerTool::generateSplitedBiFModules(llvm::Module *pMainModule) {
398396
mpm.add(createStripDeadPrototypesPass()); // Remove dead func decls.
399397

400398
mpm.run(*kernelM.get());
399+
401400
BiFSections[setData.first] = (std::move(kernelM));
402401
}
403402
}

IGC/BiFManager/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ add_library("${IGC_BUILD__PROJ__BiFManager}"
3232
"${CMAKE_CURRENT_SOURCE_DIR}/../AdaptorOCL/OCL/LoadBuffer.cpp"
3333
)
3434

35-
add_dependencies("${IGC_BUILD__PROJ__BiFManager}" "${IGC_BUILD__PROJ__BiFManagerSplitTask}")
35+
add_dependencies("${IGC_BUILD__PROJ__BiFManager}" "${IGC_BUILD__PROJ__BiFModuleCache_OCL}")
3636
target_include_directories("${IGC_BUILD__PROJ__BiFManager}" PRIVATE ${IGC_BUILD__BIF_DIR})
3737

3838

IGC/BiFManager/main.cpp

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ SPDX-License-Identifier: MIT
3131
#include <string>
3232
#include <list>
3333
#include <fstream>
34+
#include <sstream>
3435

3536
using namespace std;
3637
using namespace llvm;
@@ -63,18 +64,38 @@ int main(int argc, char *argv[]) {
6364
std::unique_ptr<llvm::MemoryBuffer> genericBufferPtr(FileOrErr.get().release());
6465
Expected<std::unique_ptr<Module>> M = llvm::parseBitcodeFile(genericBufferPtr->getMemBufferRef(), Context);
6566
if (llvm::Error EC = M.takeError()) {
66-
Err.print("Unable to Parse bitcode", errs());
67+
std::stringstream stringBuilder("");
68+
stringBuilder << "[BiFManager] - Unable to Parse bitcode:";
69+
llvm::handleAllErrors(std::move(EC),
70+
[&](llvm::ErrorInfoBase &EIB) {
71+
stringBuilder << EIB.message();
72+
});
73+
Err.print(stringBuilder.str().c_str(), errs());
6774
}
6875
return M;
6976
};
70-
printf("[BiFManager] - Start loading modules\n");
71-
7277
auto ModuleMain = LoadModule(&InputBCFilename);
73-
printf("[BiFManager] - Loaded Main module\n");
78+
if(ModuleMain)
79+
printf("[BiFManager] - Loaded Main module\n");
80+
else {
81+
printf("[BiFManager] - Problem with loading Main module\n");
82+
return -13;
83+
}
84+
7485
auto Module32 = LoadModule(&InputBC32Filename);
75-
printf("[BiFManager] - Loaded Size32 module\n");
86+
if(Module32)
87+
printf("[BiFManager] - Loaded Size32 module\n");
88+
else {
89+
printf("[BiFManager] - Problem with loading Size32 module\n");
90+
return -13;
91+
}
7692
auto Module64 = LoadModule(&InputBC64Filename);
77-
printf("[BiFManager] - Loaded Size64 module\n");
93+
if(Module64)
94+
printf("[BiFManager] - Loaded Size64 module\n");
95+
else {
96+
printf("[BiFManager] - Problem with loading Size64 module\n");
97+
return -13;
98+
}
7899

79100
IGC::BiFManager::BiFManagerTool bif(Context);
80101
bif.MakeBiFPackage(&(*ModuleMain.get()), &(*Module32.get()), &(*Module64.get()));

0 commit comments

Comments
 (0)