smowton / llpe Goto Github PK
View Code? Open in Web Editor NEWLicense: Other
License: Other
Hi, I just posted this in the LLPE Google Group but just reposting here as well.
I have been trying to use LLPE's feature to unconditionally specialize a function pointer-typed parameter. However, I would keep getting the following error:
clang func_ptr.c -c -emit-llvm func_ptr.bc
$LLPE_OPT func_ptr.bc -o func_ptr_spec.bc -llpe-root f -spec-param 0,void_func
Type mismatch: constant
; Function Attrs: noinline nounwind optnone uwtable
define dso_local void @void_func() #0 {
%1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
ret void
}
supplied for parameter of type void (...)*
My program looks like the following:
void void_func() {
printf("hello");
}
void f(void (*func_ptr)()) {
func_ptr();
}
int main() {
f(&void_func);
}
Is it a usage problem where I'm issuing the command incorrectly? Or am I potentially encountering a bug?
Thanks for any help!
Maybe it would only 'install' the tool mentioned in #3, but it would be helpful to allow folks to use LLPE without persisting the entire build tree :).
Depending on what makes sense to be "installed" from the project, a few CMakeLists tweaks might be all that's needed.
Just thought I'd mention it ๐ .
I want to use LLPE on my own set of examples such as mini_httpd, gzip, binutils etc.
I have downloaded and installed LLPE -7 version from github but it gives errors on these.
Can you help me suggest which version of LLPE is most update and complete so that I can use those?
Secondly, I am using the following command to invoke LLPE.
opt -load /home/aatiranum/llpe/build/main/libLLVMLLPEMain.so -load /home/aatiranum/llpe/build/driver/libLLVMLLPEDriver.so -mem2reg -simplifycfg -loop-simplify -lcssa -llpe -spec-argv 0,1,tmp/argv unspecialized.bc -o specialised.bc
Am I doing fine?
I am also attaching some of the screen shots of examples I found errors with. The bitocde files are made by wllvm and currently I am not building with C library.
Please help me out solving these errors.
examples.zip
Would be nice to have a tool that acts like LLPE_OPT
from the tutorial but without having to find the path containing the required libraries.
Creating a generated script works, but I'd suggest using a slightly modified version of LLVM's "opt" that links against your pass(es) and perhaps enables them by default.
What do you think?
When attempting to set both the C_COMPILER
and CXX_COMPILER
together, cmake identifies the C compiler as clang but the CXX compiler as gcc. So instead I used the CC and CXX environments instead which appears to have worked. Either way both compilers generate similar errors, formatted in their particular manners.
Note: I am not using a build directory, but this doesn't change the result.
% ~/build/lab/llpe-git/src/llpe/llpe CC=clang CXX=clang++ cmake .
-- The C compiler identification is Clang 3.7.0
-- The CXX compiler identification is Clang 3.7.0
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/clang++
-- Check for working CXX compiler: /usr/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenSSL: /usr/lib64/libssl.so;/usr/lib64/libcrypto.so (found version "1.0.2d")
-- Found wxWidgets: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/earnest/build/lab/llpe-git/src/llpe/llpe
% ~/build/lab/llpe-git/src/llpe/llpe make
Scanning dependencies of target LLVMLLPEMain
[ 2%] Building CXX object main/CMakeFiles/LLVMLLPEMain.dir/ArgSpec.cpp.o
In file included from /home/earnest/build/lab/llpe-git/src/llpe/llpe/main/ArgSpec.cpp:16:
/home/earnest/build/lab/llpe-git/src/llpe/llpe/include/llvm/Analysis/LLPE.h:403:7: error: deleted function '~LLPEAnalysisPass' cannot override a non-deleted function
class LLPEAnalysisPass : public ModulePass {
^
/usr/include/llvm/Pass.h:253:3: note: overridden virtual function is here
~ModulePass() override;
^
In file included from /home/earnest/build/lab/llpe-git/src/llpe/llpe/main/ArgSpec.cpp:16:
/home/earnest/build/lab/llpe-git/src/llpe/llpe/include/llvm/Analysis/LLPE.h:535:13: error: constructor for 'llvm::LLPEAnalysisPass' must explicitly initialize the member
'fakeDebugType' which does not have a default constructor
explicit LLPEAnalysisPass() : ModulePass(ID), cacheDisabled(false) {
^
/home/earnest/build/lab/llpe-git/src/llpe/llpe/include/llvm/Analysis/LLPE.h:533:20: note: member is declared here
DICompositeType fakeDebugType;
^
/usr/include/llvm/IR/DebugInfoMetadata.h:838:7: note: 'llvm::DICompositeType' declared here
class DICompositeType : public DICompositeTypeBase {
^
In file included from /home/earnest/build/lab/llpe-git/src/llpe/llpe/main/ArgSpec.cpp:16:
/home/earnest/build/lab/llpe-git/src/llpe/llpe/include/llvm/Analysis/LLPE.h:533:20: error: field of type 'llvm::DICompositeType' has private destructor
DICompositeType fakeDebugType;
^
/usr/include/llvm/IR/DebugInfoMetadata.h:849:3: note: implicitly declared private here
~DICompositeType() = default;
^
/home/earnest/build/lab/llpe-git/src/llpe/llpe/main/ArgSpec.cpp:72:31: error: no matching function for call to 'getGetElementPtr'
lineStartConsts.push_back(ConstantExpr::getGetElementPtr(EnvInitG, gepArgs, 2));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/llvm/IR/Constants.h:1092:20: note: candidate function not viable: no known conversion from 'llvm::GlobalVariable *' to 'llvm::Type *' for 1st argument
static Constant *getGetElementPtr(Type *Ty, Constant *C,
^
/usr/include/llvm/IR/Constants.h:1100:20: note: candidate function not viable: no known conversion from 'llvm::GlobalVariable *' to 'llvm::Type *' for 1st argument
static Constant *getGetElementPtr(Type *Ty, Constant *C, Constant *Idx,
^
/usr/include/llvm/IR/Constants.h:1108:20: note: candidate function not viable: no known conversion from 'llvm::GlobalVariable *' to 'llvm::Type *' for 1st argument
static Constant *getGetElementPtr(Type *Ty, Constant *C,
^
/home/earnest/build/lab/llpe-git/src/llpe/llpe/main/ArgSpec.cpp:84:26: error: no matching function for call to 'getGetElementPtr'
Constant* EnvPtrsPtr = ConstantExpr::getGetElementPtr(EnvPtrsG, gepArgs, 2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/llvm/IR/Constants.h:1092:20: note: candidate function not viable: no known conversion from 'llvm::GlobalVariable *' to 'llvm::Type *' for 1st argument
static Constant *getGetElementPtr(Type *Ty, Constant *C,
^
/usr/include/llvm/IR/Constants.h:1100:20: note: candidate function not viable: no known conversion from 'llvm::GlobalVariable *' to 'llvm::Type *' for 1st argument
static Constant *getGetElementPtr(Type *Ty, Constant *C, Constant *Idx,
^
/usr/include/llvm/IR/Constants.h:1108:20: note: candidate function not viable: no known conversion from 'llvm::GlobalVariable *' to 'llvm::Type *' for 1st argument
static Constant *getGetElementPtr(Type *Ty, Constant *C,
^
/home/earnest/build/lab/llpe-git/src/llpe/llpe/main/ArgSpec.cpp:156:29: error: no matching function for call to 'getGetElementPtr'
Constant* stringPtr = ConstantExpr::getGetElementPtr(ArgvConsts, gepArgs, 2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/llvm/IR/Constants.h:1092:20: note: candidate function not viable: no known conversion from 'llvm::GlobalVariable *' to 'llvm::Type *' for 1st argument
static Constant *getGetElementPtr(Type *Ty, Constant *C,
^
/usr/include/llvm/IR/Constants.h:1100:20: note: candidate function not viable: no known conversion from 'llvm::GlobalVariable *' to 'llvm::Type *' for 1st argument
static Constant *getGetElementPtr(Type *Ty, Constant *C, Constant *Idx,
^
/usr/include/llvm/IR/Constants.h:1108:20: note: candidate function not viable: no known conversion from 'llvm::GlobalVariable *' to 'llvm::Type *' for 1st argument
static Constant *getGetElementPtr(Type *Ty, Constant *C,
^
/home/earnest/build/lab/llpe-git/src/llpe/llpe/main/ArgSpec.cpp:160:30: error: no matching function for call to 'Create'
Instruction* argvPtr = GetElementPtrInst::Create(Arg, gepArg, "argv_ptr", InsertBefore);
^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/llvm/IR/Instructions.h:854:29: note: candidate function not viable: no known conversion from 'Function::arg_iterator' (aka 'ilist_iterator<llvm::Argument>')
to 'llvm::Type *' for 1st argument
static GetElementPtrInst *Create(Type *PointeeType, Value *Ptr,
^
/usr/include/llvm/IR/Instructions.h:869:29: note: candidate function not viable: requires 5 arguments, but 4 were provided
static GetElementPtrInst *Create(Type *PointeeType, Value *Ptr,
^
/home/earnest/build/lab/llpe-git/src/llpe/llpe/main/ArgSpec.cpp:169:29: error: no matching function for call to 'Create'
Instruction* argvEndPtr = GetElementPtrInst::Create(Arg, gepArg, "argv_end_ptr", InsertBefore);
^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/llvm/IR/Instructions.h:854:29: note: candidate function not viable: no known conversion from 'Function::arg_iterator' (aka 'ilist_iterator<llvm::Argument>')
to 'llvm::Type *' for 1st argument
static GetElementPtrInst *Create(Type *PointeeType, Value *Ptr,
^
/usr/include/llvm/IR/Instructions.h:869:29: note: candidate function not viable: requires 5 arguments, but 4 were provided
static GetElementPtrInst *Create(Type *PointeeType, Value *Ptr,
^
8 errors generated.
main/CMakeFiles/LLVMLLPEMain.dir/build.make:62: recipe for target 'main/CMakeFiles/LLVMLLPEMain.dir/ArgSpec.cpp.o' failed
make[2]: *** [main/CMakeFiles/LLVMLLPEMain.dir/ArgSpec.cpp.o] Error 1
CMakeFiles/Makefile2:85: recipe for target 'main/CMakeFiles/LLVMLLPEMain.dir/all' failed
make[1]: *** [main/CMakeFiles/LLVMLLPEMain.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
If there is any other information I can provide which will help please ask,
thanks
Hi there, I've been trying to conditionally specialize a global integer variable but was getting an assertion error Assertion failed: (ConstType->isIntegerTy() || (ConstType->isPointerTy() && !assumeInt)) && "Instructions with an integer assumption must be integer typed"
every time LLPE tries to specialize the program. Note that I have tried conditionally specializing an integer argument to a function as well which results in the same assertion failure. I am wondering if I'm using LLPE correctly?
Below is the C code that is being specialized, where global_int
is the global variable that serves as the condition:
#include "string.h"
#include "stdio.h"
int global_int = 3;
int exponent (int e) { // assume e >= 1
int result = 1;
for (int i = 0; i < e; i++) {
result *= global_int;
}
return result;
}
int main(int argc, char** argv) {
int ret = 0;
for (int i = 0; i < 10; i++) {
ret += exponent(5);
}
printf("%i\n", ret);
return ret;
}
Here are the commands that I am running in terminal to conditionally specialize the program:
$ clang -c -emit-llvm int_spec.c -o int_spec.bc
$ clang int_spec.bc -o int_spec.out
$ opt -load /home/tina/Codes/llpe/build/utils/libLLVMLLPEUtils.so -nameblocks int_spec.bc -o int_spec_named.bc
$ $LLPE_OPT -llpe-root exponent \
-llpe-force-noalias-arg 0 \
-llpe-path-condition-int exponent,__globals__,global_int,3,exponent,1 \
int_spec_named.bc -o int_spec_spec.bc
And below is the resulting output:
Assertion failed: (ConstType->isIntegerTy() || (ConstType->isPointerTy() && !assumeInt)) && "Instructions with an integer assumption must be integer typed"
Stack dump:
0. Program arguments: opt -load /home/tina/Codes/llpe/build/main/libLLVMLLPEMain.so -load /home/tina/Codes/llpe/build/driver/libLLVMLLPEDriver.so -loop-simplify -lcssa -llpe -llpe-root exponent -llpe-force-noalias-arg 0 -llpe-path-condition-int exponent,__globals__,global_int,3,exponent,1 int_spec_named.bc -o int_spec_spec.bc
1. Running pass 'LLPE Analysis' on module 'int_spec_named.bc'.
#0 0x0000000001f72364 PrintStackTraceSignalHandler(void*) (/home/tina/Codes/clang+llvm-9.0.0-x86_64-pc-linux-gnu/bin/opt+0x1f72364)
#1 0x0000000001f7021e llvm::sys::RunSignalHandlers() (/home/tina/Codes/clang+llvm-9.0.0-x86_64-pc-linux-gnu/bin/opt+0x1f7021e)
#2 0x0000000001f72758 SignalHandler(int) (/home/tina/Codes/clang+llvm-9.0.0-x86_64-pc-linux-gnu/bin/opt+0x1f72758)
#3 0x00007fcf02842520 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007fcf02896a7c pthread_kill (/usr/lib/x86_64-linux-gnu/libc.so.6+0x96a7c)
#5 0x00007fcf02842476 raise (/usr/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007fcf028287f3 abort (/usr/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x00007fcf02fa0fc1 llvm::LLPEAnalysisPass::parsePathConditions(llvm::cl::list<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, llvm::cl::parser<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&, llvm::PathConditionTypes, llvm::InlineAttempt*) (/home/tina/Codes/llpe/build/main/libLLVMLLPEMain.so+0xe0fc1)
#8 0x00007fcf02fa78ac llvm::LLPEAnalysisPass::parseArgsPostCreation(llvm::InlineAttempt*) (/home/tina/Codes/llpe/build/main/libLLVMLLPEMain.so+0xe78ac)
#9 0x00007fcf02fb29b2 llvm::LLPEAnalysisPass::runOnModule(llvm::Module&) (/home/tina/Codes/llpe/build/main/libLLVMLLPEMain.so+0xf29b2)
#10 0x0000000001a46b48 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/tina/Codes/clang+llvm-9.0.0-x86_64-pc-linux-gnu/bin/opt+0x1a46b48)
#11 0x0000000000831338 main (/home/tina/Codes/clang+llvm-9.0.0-x86_64-pc-linux-gnu/bin/opt+0x831338)
#12 0x00007fcf02829d90 (/usr/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#13 0x00007fcf02829e40 __libc_start_main (/usr/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#14 0x000000000081a7ba _start (/home/tina/Codes/clang+llvm-9.0.0-x86_64-pc-linux-gnu/bin/opt+0x81a7ba)
Thank you for your time and greatly appreciate any help here!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.