Hi Johannes,
Excuse me for the late answer. Regarding the question if the pthread call
inserted in the LLVM IR works, I implemented a new function pass and I would
like to test the insertion of pthread call all in one, when testing the entire
implementation. It is easier for me to do like that.
What are the next steps after a pass implementation in llvm before commit? Is
there a review process involved also? I haven't tested the implementation
(the tests are not straight forward), so I would like to know if, in llvm, the
validation is after or before the review? Or maybe both before and after? I am
not expecting many changes after the testing.
Looking forward for your answer.Regards,Iulia
On Monday, April 22, 2019, 5:03:15 PM GMT+3, Doerfert, Johannes <jdoerfert
at anl.gov> wrote:
Hi Iulia,
The declaration Rob has shared was never part of mainline LLVM (afaik).
The implementation Rob provided should however still work.
Have you tried it?
There is no need to add/change anything in the machine representation.
Cheers,
Johannes
On 04/22, Iulia Stirb via llvm-dev wrote:> Hello all,
> I am returning to this subject after a while and I was looking for
CBuilder::CreatePThreadCreateCall function below. I cannot find it anywere and I
guess it has been rename or changed into a more generic one. I would want to
insert a phtread call into the input source code. Which builder class to use for
that instead of CBuilder class? If I insert the call into IR representation, do
I need to insert the call also into machine representation?
> Kind regards,
> ----------------------------------------------------------Iulia ȘTIRBPhD
Student in Computer ScienceAssociate Teaching AssistantDepartment of Computers
and Software EngineeringPolitehnica University of Timișoara2 Piața Victoriei,
Timișoara, Romania, 300006 Tel.: +(40) 76 560 3230E-mail: iulia.stirb at
gmail.com, iulia_s24 at yahoo.comSkype:
iulia.stirb----------------------------------------------------------
>
>
>
>
>
>
> On Saturday, May 6, 2017, 5:58:03 PM GMT+3, Rob Cameron <cameron at
cs.sfu.ca> wrote:
>
> Hi, Iulia.
>
> You can create calls to pthread routines. For example, this is a
declaration
> in one of our header files.
>
> // Create a call to: int pthread_create(pthread_t *thread, const
pthread_attr_t *attr,
> // void *(*start_routine)(void*), void *arg);
> llvm::Value * CreatePThreadCreateCall(llvm::Value * thread, llvm::Value *
attr,
> llvm::Function * start_routine,
llvm::Value * arg);
>
> Here is our implementation (mMod is the Module * containing the code we are
building).
>
> Value * CBuilder::CreatePThreadCreateCall(Value * thread, Value * attr,
Function * start_routine, Value * arg) {
> Type * const voidPtrTy = getVoidPtrTy();
> Function * pthreadCreateFunc =
mMod->getFunction("pthread_create");
> if (pthreadCreateFunc == nullptr) {
> Type * pthreadTy = getSizeTy();
> FunctionType * funVoidPtrVoidTy = FunctionType::get(getVoidTy(),
{getVoidPtrTy()}, false);
> FunctionType * fty = FunctionType::get(getInt32Ty(),
{pthreadTy->getPointerTo(), voidPtrTy, funVoidPtrVoidTy->getPointerTo(),
voidPtrTy}, false);
> pthreadCreateFunc = Function::Create(fty,
Function::ExternalLinkage, "pthread_create", mMod);
> pthreadCreateFunc->setCallingConv(CallingConv::C);
> }
> return CreateCall(pthreadCreateFunc, {thread, attr, start_routine,
CreatePointerCast(arg, voidPtrTy)});
> }
>
> The actual routine called is determined at link time. In our case,
> we rely on the ExecutionEngine to dynamically link to the pthread routines
> available on our target platform. This approach works well for us on both
> Linux and Mac OS. I don't know what happens with Windows OS.
>
>
>
> ----- On May 6, 2017, at 4:16 AM, Iulia Stirb via llvm-dev llvm-dev at
lists.llvm.org wrote:
>
> > Hello,
> > I know clang supports -pthread option (here). Does this mean I can
call pthread
> > routines inside llvm code and which pthread library is used, the one
for Linux
> > OS or the one for Windows?
> > Thank you.Iulia
> >
> >
> > _______________________________________________
> > LLVM Developers mailing list
> > llvm-dev at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
--
Johannes Doerfert
Researcher
Argonne National Laboratory
Lemont, IL 60439, USA
jdoerfert at anl.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20190804/05f7bfec/attachment-0001.html>