I have just write a simple case for llvm code generation. test-llvm/test_llvm.cpp at main · jiamo/test-llvm · GitHub .
// B
Function *addFunc = CreateAdd(context, module);
AddFuncType addFuncAddr = (AddFuncType)exEngine->getFunctionAddress(addFunc->getName());
printf("addFuncAddr=%lx %s \n", (unsigned long)addFuncAddr, addFunc->getName());
// A
Function *minFunc = CreateMin(context, module);
MinFuncType minFuncAddr = (MinFuncType)exEngine->getFunctionAddress(minFunc->getName());
printf("minFuncAddr=%lx %s \n", (unsigned long)minFuncAddr, minFunc->getName());
It is very strange. After I swap minFunc
and addFunc
position. The first call of getFunctionAddress
is ok. The second still return NULL
.
The dump of IR was almost same with function swap.
with ubuntu 20.04 + llvm-10 (default version).