leaningtech / cheerp-meta

Cheerp - a C/C++ compiler for Web applications - compiles to WebAssembly and JavaScript
https://labs.leaningtech.com/cheerp
Other
1.02k stars 50 forks source link

Issues are not enabled on "cheerp-compiler" #148

Closed mingodad closed 1 year ago

mingodad commented 1 year ago

I was going to report some issues on cheerp-compiler but the Issues functionality is not enabled on that github project.

Anyway it's about eliminating several warnings due to only using some variables inside assert() like the ones shown bellow that can be wraped around #ifndef NDEBUG;

In cheerp-compiler/llvm/include/llvm/Cheerp/PointerAnalyzer.h:432:23: warning: variable 'modulePtr' set but not used [-Wunused-but-set-variable]

  /// Run the analysis pass over a function and produce a dominator tree.
  Result run(llvm::Module &M, llvm::ModuleAnalysisManager &MAM)
  {
#ifndef NDEBUG    
    static llvm::Module* modulePtr = nullptr;
    assert(modulePtr != &M);
    modulePtr = &M;
#endif    
      return PointerAnalysisWrapper();
  }
};

In cheerp-compiler/llvm/include/llvm/Cheerp/Registerize.h:116:14: warning: variable 'C' set but not used [-Wunused-but-set-variable]

            for (uint32_t j=0; j<N; j++)
            {
                bool isFriend = false;
#ifndef NDEBUG
                uint32_t C = 0;
#endif              
                for (const Friend& f : friends[i])
                {
                    if (f.first == j)
                    {
                        isFriend = true;
#ifndef NDEBUG
                        C++;
#endif
                    }
                }
                assert(C<2);
                if (isFriend)
                    llvm::errs() << "x";
                else if (constraints[i][j])
                    llvm::errs() << "1";
                else
                    llvm::errs() << ".";
            }

In cheerp-compiler/llvm/lib/CheerpUtils/IdenticalCodeFolding.cpp:973:16: warning: unused variable 'GType' [-Wunused-variable]

    for (const Use &U : F->uses()) {
        User *FU = U.getUser();
        if (!isa<CallInst>(FU) && !isa<InvokeInst>(FU))
            continue;
        CallBase* CS = cast<CallBase>(FU);
        if (CS->isCallee(&U))
            directCalls.push_back(CS);
    }

    FunctionType* FType = F->getFunctionType();
#ifndef NDEBUG  
    FunctionType* GType = G->getFunctionType();

    assert(FType->getNumParams() == GType->getNumParams());
#endif  
    for (CallBase* CS: directCalls) {
        // BitCasts in call sites causes spurious indirect call
        // Avoid this problem by bitcasting parameters and return values as appropriate
        CS->setCalledOperand(ConstantExpr::getBitCast(G, CS->getCalledOperand()->getType()));

        replaceCallOfBitCastWithBitCastOfCall(*CS, /*mayFail*/ false, /*performPtrIntConversions*/ true);
    }
alexp-sssup commented 1 year ago

The issues are deliberately not enabled on cheerp-compiler. We want to make sure all bugs are reported in a centralized location since it might be difficult for the user to isolate what component is causing the problem.

About the warnings, it is unlikely that we will be able to commit developer work to fixing these sort of "cosmetic" issues for the build. Feel free about sending a PR though.

mingodad commented 1 year ago

Thanks ! The thing is that these sort of "cosmetic" issues make the output noisy and can hide real important issues.

Anyway again thanks !

By the way even after changing the order of installing:

ninja -C build_runtimes_genericjs install
ninja -C build_runtimes_wasm install

I'm not able to get a success build of cheerp.

alexp-sssup commented 1 year ago

Please provide an update log in the other issue then