<html><head></head><body><div class="ydp5838f890yahoo-style-wrap" style="font-family: verdana, helvetica, sans-serif; font-size: 10px;"><div id="ydp5838f890yiv3142119401"><div><div class="ydp5838f890yiv3142119401ydp8e3d7e62yahoo-style-wrap" style="font-family:verdana, helvetica, sans-serif;font-size:10px;"><div><div class="ydp5838f890yiv3142119401ydp8e3d7e62signature"><div style="font-family:verdana, helvetica, sans-serif;font-size:10px;"><div dir="ltr">Hi Andrzej,</div><div dir="ltr"><br clear="none"></div><div dir="ltr">Sorry. I will place the answer to the points inline. Could it be infinite loop in my pass? Shouldn't the opt command display at least the first print at the very beginning, even if there is infinite loop in the pass?</div><div dir="ltr"><br></div><div dir="ltr" data-setdir="false">Thank you.<br clear="none"></div><div dir="ltr">Regards,</div><div dir="ltr">Iulia<br clear="none"></div><div dir="ltr"><br clear="none"></div></div></div></div><div><br clear="none"></div>
        
        </div><div class="ydp5838f890yiv3142119401ydp41824e59yahoo_quoted" id="ydp5838f890yiv3142119401ydp41824e59yahoo_quoted_1230633559">
            <div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">
                
                <div>
                    On Wednesday, October 2, 2019, 10:49:56 AM GMT+3, Andrzej Warzynski <Andrzej.Warzynski@arm.com> wrote:
                </div>
                <div><br clear="none"></div>
                <div><br clear="none"></div>
                <div><div dir="ltr">Hi Iulia,<br clear="none"><br clear="none">This is really weird - the Hello pass from LLVM definitely works (I run<br clear="none">it occasionally for reference).<br clear="none"><br clear="none">"Infinite loop" might mean that you're missing an argument - opt will<br clear="none">wait indefinitely until all positional argument are specified (i.e. the<br clear="none">*.ll file to process). I might be wrong here - that's just my experience<br clear="none">with opt.<br clear="none"><br clear="none">Let's take a step back and focus on LLVMHello.so - could you send the<br clear="none">following:<br clear="none"><div>1. Your input *.c (well, just copy and paste the contents here)</div><div dir="ltr"><div>#define _GNU_SOURCE<br clear="none">#include <pthread.h><br clear="none">#include <stdio.h><br clear="none">#include <stdlib.h><br clear="none">#include <sched.h><br clear="none">#define NUM_THREADS 2<br clear="none">void * inc(void *args) {<br clear="none">    (*(int *)args)++; <br clear="none">    return args;<br clear="none">}<br clear="none">void * dec(void *args) {<br clear="none">    (*(int *)args)--; <br clear="none">    return args;<br clear="none">}<br clear="none">int main(int argc, char **argv) {<br clear="none">    pthread_t *thr = (pthread_t *)malloc(NUM_THREADS*sizeof(pthread_t));<br clear="none">    void * arg_thr0 = malloc(sizeof(void)), * arg_thr1 = malloc(sizeof(void));<br clear="none">    *(int *)arg_thr0 = atoi(argv[1]); <br clear="none">    <br clear="none">    if(pthread_create(&thr[0], NULL, inc, arg_thr0)) { <br clear="none">        return EXIT_FAILURE;<br clear="none">    }<br clear="none">    else <br clear="none">    {<br clear="none">        cpu_set_t cpuset_thr0; <br clear="none">        CPU_ZERO(&cpuset_thr0); <br clear="none">        CPU_SET(0, &cpuset_thr0); <br clear="none">        <br clear="none">        if(pthread_setaffinity_np(thr[0], sizeof(cpu_set_t), &cpuset_thr0)) { <br clear="none">            return EXIT_FAILURE;<br clear="none">        }<br clear="none">    }<br clear="none">    *(int *)arg_thr1 = atoi(argv[2]); <br clear="none">    <br clear="none">    if(pthread_create(&thr[1], NULL, dec, arg_thr1)) { <br clear="none">        return EXIT_FAILURE;<br clear="none">    }<br clear="none">    else <br clear="none">    {<br clear="none">        cpu_set_t cpuset_thr1; <br clear="none">        CPU_ZERO(&cpuset_thr1); <br clear="none">        CPU_SET(1, &cpuset_thr1); <br clear="none">        <br clear="none">        if(pthread_setaffinity_np(thr[1], sizeof(cpu_set_t), &cpuset_thr1)) { <br clear="none">            return EXIT_FAILURE;<br clear="none">        }<br clear="none">    }<br clear="none">    void *status;<br clear="none">    int i;<br clear="none">    for (i = 0; i < NUM_THREADS; ++i) {<br clear="none">        pthread_join(thr[i], &status); <br clear="none">        printf("%d ", *(int *)status);</div></div></div></div></div></div></div></div></div><div class="ydpae5eae29yiv3142119401yqt5848454586" id="ydpae5eae29yiv3142119401yqtfd59761"><br clear="none">    }<br clear="none">}</div><div class="ydpae5eae29yiv3142119401yqt5848454586" id="ydpae5eae29yiv3142119401yqtfd40068"><div><br clear="none"></div></div><div class="ydpae5eae29yiv3142119401yqt5848454586" id="ydpae5eae29yiv3142119401yqtfd88163"><div>2. The command that you use to generate the *.ll file</div><div dir="ltr" data-setdir="false"><span>llvm-dis test.bc</span><br></div><div>3. The command that you use to run the Hello pass</div><div dir="ltr" data-setdir="false"><span>opt -load lib­/LLVMHello.so -hello test.ll</span><br></div><div>4. The command that you used to build LLVM (in particular, LLVMHello.so)</div><div dir="ltr" data-setdir="false">ninja</div><div dir="ltr" data-setdir="false">(builds all LLVM)<br></div><br clear="none">Cheers,<br clear="none">Andrzej<br clear="none"><div class="ydpae5eae29yiv3142119401ydp41824e59yqt8032625194" id="ydpae5eae29yiv3142119401ydp41824e59yqtfd11552"><br clear="none">On 30/09/2019 18:59, Iulia Stirb wrote:<br clear="none">> Hi Lorenzo,<br clear="none">><br clear="none">> Sorry for the late answer.<br clear="none">><br clear="none">> I am loading LLVMHello.so in the command, but, as I was explaining to<br clear="none">> Andrzej in the previous mail, I copy pasted in the mail another command,<br clear="none">> from the source article, which uses dummypass. I also registered the<br clear="none">> Hello pass. There is no error or warning when executing the opt load<br clear="none">> command, but it seems like it is doing some processing (maybe in<br clear="none">> infinite loop) because the command does not finish execution. It is<br clear="none">> strange though that the command is not displaying nothing, even though<br clear="none">> there is a print at the very beginning of the runOnModule function.<br clear="none">><br clear="none">> This is the structure of my pass:<br clear="none">><br clear="none">> classHello: publicModulePass{<br clear="none">> public:<br clear="none">> staticcharID;<br clear="none">> Hello() : ModulePass(ID) {<br clear="none">> }<br clear="none">><br clear="none">> boolrunOnModule(Module &M) override;<br clear="none">><br clear="none">> voidgetAnalysisUsage(AnalysisUsage &AU) constoverride{<br clear="none">> getAnalysisUsage(AU);<br clear="none">> }<br clear="none">><br clear="none">> ...<br clear="none">><br clear="none">> staticRegisterPass<Hello>X("hello", "Hello World Pass",<br clear="none">> false/* Only looks at CFG */,<br clear="none">> false/* Analysis Pass */);<br clear="none">><br clear="none">> staticRegisterStandardPasses Y(<br clear="none">> PassManagerBuilder::EP_EarlyAsPossible,<br clear="none">> [](constPassManagerBuilder &Builder,<br clear="none">> legacy::PassManagerBase &PM) { PM.add(newHello()); });<br clear="none">><br clear="none">> ...<br clear="none">><br clear="none">> boolHello::runOnModule(Module &M) {<br clear="none">> errs() <<"Start pass: ";<br clear="none">><br clear="none">><br clear="none">> Could you please help with any ideas?<br clear="none">><br clear="none">> Thank you.<br clear="none">> Kind regards,<br clear="none">> Iulia Stirb<br clear="none">><br clear="none">><br clear="none">><br clear="none">> On Thursday, September 19, 2019, 12:32:06 AM GMT+3, Lorenzo Casalino<br clear="none">> <<a shape="rect" href="mailto:lorenzo.casalino93@gmail.com" rel="nofollow" target="_blank">lorenzo.casalino93@gmail.com</a>> wrote:<br clear="none">><br clear="none">><br clear="none">>> opt -load lib­dum­my­pass.so -dum­my­pass hel­lo.ll<br clear="none">>><br clear="none">><br clear="none">> Looks like you are loading a shared library different from "LLVMHello.so".<br clear="none">><br clear="none">> did you change the name of the compilation unit from "Hello.cpp" into<br clear="none">> "dummypass.cpp"?<br clear="none">><br clear="none">><br clear="none">> (As asked previously by Andrzej) did you register the dummy pass?<br clear="none">><br clear="none">>  > RegisterPass<DummyPass> X("dummypass", "whatever");<br clear="none">><br clear="none">><br clear="none">> Is any error/warning triggered when loading the library, executing "opt" or<br clear="none">> during compilation?<br clear="none">><br clear="none">><br clear="none">> Could you attach the fragment containing the "DummyPass"?<br clear="none">><br clear="none">><br clear="none">> Lorenzo</div><br clear="none">><br clear="none">><br clear="none">IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.<div class="ydpae5eae29yiv3142119401ydp41824e59yqt8032625194" id="ydpae5eae29yiv3142119401ydp41824e59yqtfd55554"><br clear="none"></div></div><div class="ydpae5eae29yiv3142119401yqt5848454586" id="ydpae5eae29yiv3142119401yqtfd90182">
            </div><div class="ydpae5eae29yiv3142119401yqt5848454586" id="ydpae5eae29yiv3142119401yqtfd49908">
        </div></body></html>