Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while making rtlib example #19

Open
youngmaia5 opened this issue Jun 5, 2019 · 6 comments
Open

Error while making rtlib example #19

youngmaia5 opened this issue Jun 5, 2019 · 6 comments

Comments

@youngmaia5
Copy link

Hi,

I ran into an error when I tried to run "make" on the rtlib example. The output is below. Do you have any suggestions on how to fix this error?

Scanning dependencies of target SkeletonPass
[ 50%] Building CXX object skeleton/CMakeFiles/SkeletonPass.dir/Skeleton.cpp.o
/llvm-pass-skeleton/skeleton/Skeleton.cpp: In member function ‘virtual bool {anonymous}::SkeletonPass::runOnFunction(llvm::Function&)’:
/llvm-pass-skeleton/skeleton/Skeleton.cpp:23:84: error: cannot convert ‘llvm::FunctionCallee’ to ‘llvm::Constant*’ in initialization
      Constant *logFunc = F.getParent()->getOrInsertFunction("logop", logFuncType);
                                                                                 ^
skeleton/CMakeFiles/SkeletonPass.dir/build.make:62: recipe for target 'skeleton/CMakeFiles/SkeletonPass.dir/Skeleton.cpp.o' failed
make[2]: *** [skeleton/CMakeFiles/SkeletonPass.dir/Skeleton.cpp.o] Error 1
CMakeFiles/Makefile2:117: recipe for target 'skeleton/CMakeFiles/SkeletonPass.dir/all' failed
make[1]: *** [skeleton/CMakeFiles/SkeletonPass.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Thank you!

@sampsyo
Copy link
Owner

sampsyo commented Jun 5, 2019

Hello! As the README says, this repository currently targets LLVM 3.8. Which version are you trying to use?

@youngmaia5
Copy link
Author

I'm using LLVM 8.0. However, I also followed another tutorial by Mike Shah (Northeastern+MIT LLVM Seminar - Introduction to LLVM) that works with LLVM 8.0, and I get the same error using his code. So, I'm thinking it does not have to do with the LLVM version. What do you think?

@sampsyo
Copy link
Owner

sampsyo commented Jun 5, 2019

I'm not sure about that other tutorial, but I'm nearly certain that this error with this code is version-related. In 3.8, getOrInsertFunction returned a Function*. Now, it returns a FunctionCallee. You can either try with 3.8 or—if you're feeling generous!—help update the code for the new API changes since then.

@youngmaia5
Copy link
Author

OK, that makes sense. Thank you!

@alisemi
Copy link

alisemi commented Apr 9, 2020

I came here following the Mike Shah's seminar, and I am using LLVM version 11.0. Here is my solution for the problem:
Change the line
Constant* hook = M.getOrInsertFunction(InstrumentingFunctionName, funcTy);
to
Value* hook = M.getOrInsertFunction(InstrumentingFunctionName, funcTy).getCallee();

and add #include "llvm/IR/Value.h" . Here is the explanation, the FunctionCallee class has a *Value attribute and Value class is a super class of Constant. In the new version of LLVM, the CallInst::Create also takes *Value as parameter rather than *Constant. Alternatively, passing the FunctionCallee as an argument to CallInst::Create might also work.

@gururaj-s
Copy link

To build on the previous answer - the exact changes needed in the Skeleton.cpp code to make it work with LLVM-10 were the following:

Change line-23 from Constant *logFunc = F.getParent()->getOrInsertFunction("logop", logFuncType);
to : FunctionCallee logFunc = F.getParent()->getOrInsertFunction("logop", logFuncType);

Change line-34 from builder.CreateCall(logFunc, args);
to : builder.CreateCall(logFuncType,logFunc.getCallee(), args);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants