UO-OACISS / tau2

TAU Performance System Public Mirror (Updated every night at midnight, USA Pacific Time)
http://tau.uoregon.edu
Other
39 stars 16 forks source link

[LLVM 18] TAU fails to compile LLVM plugin due to changes in LLVM #11

Closed Thyre closed 6 months ago

Thyre commented 6 months ago

LLVM 18 has changed handling of pointer types, which causes some functions to not exist anymore. This affects TAU 2.33.1 and the mirrored state, where Type::getInt8PtrTy is still being used.

https://github.com/UO-OACISS/tau2/blob/b140a6bcfbb6d39b9c71a75890822ca7c7c202a2/plugins/llvm/src/Instrument.cpp#L187

When trying to compile this with LLVM 18.1.1, we end up with:

/home/jreuter/Downloads/tau-2.33.1/plugins/llvm/src/Instrument.cpp: In function ‘llvm::FunctionCallee {anonymous}::getVoidFunc(llvm::StringRef, llvm::LLVMContext&, llvm::Module*)’:
/home/jreuter/Downloads/tau-2.33.1/plugins/llvm/src/Instrument.cpp:187:29: error: ‘getInt8PtrTy’ is not a member of ‘llvm::Type’
  187 |         Type *argTy = Type::getInt8PtrTy(context);
      |                             ^~~~~~~~~~~~
/home/jreuter/Downloads/tau-2.33.1/plugins/llvm/src/Instrument.cpp: In function ‘llvm::FunctionCallee {anonymous}::getVoidFunc_init(llvm::StringRef, llvm::LLVMContext&, llvm::Module*)’:
/home/jreuter/Downloads/tau-2.33.1/plugins/llvm/src/Instrument.cpp:209:53: error: ‘getInt8PtrTy’ is not a member of ‘llvm::Type’
  209 |         Type* argTy1 = PointerType::getUnqual(Type::getInt8PtrTy(context));
      |                                                     ^~~~~~~~~~~~
/home/jreuter/Downloads/tau-2.33.1/plugins/llvm/src/Instrument.cpp: In function ‘llvm::FunctionCallee {anonymous}::getVoidFunc(llvm::StringRef, llvm::LLVMContext&, llvm::Module*)’:
/home/jreuter/Downloads/tau-2.33.1/plugins/llvm/src/Instrument.cpp:187:29: error: ‘getInt8PtrTy’ is not a member of ‘llvm::Type’
  187 |         Type *argTy = Type::getInt8PtrTy(context);
      |                             ^~~~~~~~~~~~
/home/jreuter/Downloads/tau-2.33.1/plugins/llvm/src/Instrument.cpp: In function ‘llvm::FunctionCallee {anonymous}::getVoidFunc_init(llvm::StringRef, llvm::LLVMContext&, llvm::Module*)’:
/home/jreuter/Downloads/tau-2.33.1/plugins/llvm/src/Instrument.cpp:209:53: error: ‘getInt8PtrTy’ is not a member of ‘llvm::Type’
  209 |         Type* argTy1 = PointerType::getUnqual(Type::getInt8PtrTy(context));
      |                                                     ^~~~~~~~~~~~
make[4]: *** [src/CMakeFiles/TAU_Profiling.dir/build.make:76: src/CMakeFiles/TAU_Profiling.dir/Instrument.cpp.o] Error 1
make[4]: Leaving directory '/home/jreuter/Downloads/tau-2.33.1/plugins/llvm/build'
make[3]: *** [CMakeFiles/Makefile2:212: src/CMakeFiles/TAU_Profiling.dir/all] Error 2
make[3]: *** Waiting for unfinished jobs....
make[4]: *** [src/CMakeFiles/TAU_Profiling_CXX.dir/build.make:76: src/CMakeFiles/TAU_Profiling_CXX.dir/Instrument.cpp.o] Error 1
make[4]: Leaving directory '/home/jreuter/Downloads/tau-2.33.1/plugins/llvm/build'
make[3]: *** [CMakeFiles/Makefile2:290: src/CMakeFiles/TAU_Profiling_CXX.dir/all] Error 2
make[3]: Leaving directory '/home/jreuter/Downloads/tau-2.33.1/plugins/llvm/build'
make[2]: *** [Makefile:136: all] Error 2
make[2]: Leaving directory '/home/jreuter/Downloads/tau-2.33.1/plugins/llvm/build'
make[1]: *** [Makefile:11: install] Error 2
make[1]: Leaving directory '/home/jreuter/Downloads/tau-2.33.1/plugins/llvm'
make: *** [Makefile:195: install] Error 2

In Score-P (not upstreamed in GitLab mirror yet), we use these functions to convert the pointer types based on the LLVM version:

llvm::Type*
SCOREP::Compiler::LLVMPlugin::GetCharPointerType( llvm::LLVMContext& context )
{
    #if LLVM_VERSION_MAJOR > 17
    auto pointer_type = PointerType::get( context, 0 );
    #else
    auto pointer_type = Type::getInt8PtrTy( context, 0 );
    #endif

    return pointer_type;
}

llvm::Type*
SCOREP::Compiler::LLVMPlugin::GetInt32PointerType( llvm::LLVMContext& context )
{
    #if LLVM_VERSION_MAJOR > 17
    auto int_pointer = PointerType::get( context, 0 );
    #else
    auto int_pointer = Type::getInt32PtrTy( context );
    #endif

    return int_pointer;
}
coti commented 6 months ago

Thank you for the report, I will look at it.

jordialcaraz commented 6 months ago

Hi Thyre,

TAU has been updated to apply the change for LLVM 18. However, the public repository is updated at night, so you won't be able to clone the updated version of TAU(from this repository) until tomorrow.

If you find any issues, please report them.