Guys,
I would like to instrument the bytecode that LLVM produces with assertions. I have written the instrumentation code manually, but I do not know how to halt the program in case the assertion is false. I took a look into the bytecode that LLVM produces for a program like:
#include <stdlib.h>
int main() {
exit(1);
}
And it is like this:
define i32 @main() nounwind {
entry:
%retval = alloca i32 ; <i32*> [#uses=1]
%0 = alloca i32 ; <i32*> [#uses=0]
%“alloca point” = bitcast i32 0 to i32 ; [#uses=0]
call void @exit(i32 1) noreturn nounwind
unreachable
return: ; No predecessors!
%retval1 = load i32* %retval ; [#uses=1]
ret i32 %retval1
}
So, what is the LLVM code to insert the call “call void @exit(i32 1) noreturn nounwind”? I thought about something like:
CallInst abort = CallInst::Create(/POINTER TO ABORT/, ArrayRef<Value>(), Twine(), assertfail);
abort->addAttribute(~0, Attribute::NoReturn);
abort->addAttribute(~0, Attribute::NoUnwind);
However, I do not know what to fill up in /POINTER TO ABORT/. Can anyone help me?
Thank you very much,
Victor