Skip to content

Compiling with optimizations disabled results in runtime error #57

Description

@matteo-meluzzi

When running a genmc executable compiled with optimizations disabled, I get a runtime error.
When running genmc with the default compiler flags, everything runs smoothly.

How to reproduce:

  1. checkout master branch
  2. autoreconf -i to generate the configure script
  3. ./configure AR=llvm-ar CXXFLAGS="-O0 -g" to generate Makefile
  4. make genmc to generate genmc executable
  5. ./genmc --print-exec-graphs tests/correct/litmus/LB2/variants/lb0.c
    outputs:
GenMC v0.10.0 (LLVM 15.0.7)
Copyright (C) 2023 MPI-SWS. All rights reserved.

*** Compilation complete.
*** Transformation complete.
Tip: Estimating state-space size. For better performance, you can use --disable-estimation.
libc++abi: terminating due to uncaught exception of type std::length_error: vector
zsh: abort      ./genmc --print-exec-graphs tests/correct/litmus/LB2/variants/lb0.c

In contrast the same steps except for
3) ./configure AR=llvm-ar
outputs

No errors were detected.
Number of complete executions explored: 3
Total wall-clock time: 0.11s

I am using MacOS 14, llvm@15 installed

Activity

  1. JonasOberhauser commented on Feb 27, 2024

    @JonasOberhauser

    unlikely to be fixed. IIRC llvm requires at least -O2

  2. matteo-meluzzi commented on Mar 14, 2024

    @matteo-meluzzi
    Author

    I see. Thank you for the reply! Is there any online resources that explain why this is the case?

  3. JonasOberhauser commented on Apr 23, 2024

    @JonasOberhauser

    Can't find anything now. Heck maybe I dreamed the whole thing up, or it has been fixed since Iooked at it 4 years ago?

    But as I remember, llvm used some... uh... not so sound things that break under -O0.

    Maybe @michaliskok can weigh in and provide some clarity

  4. JonasOberhauser commented on Apr 23, 2024

    @JonasOberhauser

    Also just for the sake of it, try downgrading to LLVM 15.0.0

  5. michaliskok commented on Sep 11, 2024

    @michaliskok
    Collaborator

    This took embarrassingly long but here's a possible explanation.

    First, I could only reproduce this in macOS. I am not aware of LLVM having issues with -O0, but the crash anyway indicates that this is some issue in how internal genmc functions are handled.

    The precise cause is still a bit vague to me, but the cause of the crashes seems to be that some function calls that are normally resolved internally got offloaded to some LLVM-provided utils.

    If a patch like this fixes the crashes, I'll merge something similar in the next release.

    diff --git a/src/Runtime/Interpreter.h b/src/Runtime/Interpreter.h
    index c8d9b670..3694f0ab 100644
    --- a/src/Runtime/Interpreter.h
    +++ b/src/Runtime/Interpreter.h
    @@ -585,11 +585,14 @@ public:
            void visitSelectInst(SelectInst &I);
     
            void visitCallInstWrapper(CallInstWrapper CIW);
    -#if LLVM_VERSION_MAJOR < 11
    -       void visitCallSite(CallSite CS) { visitCallInstWrapper(CallInstWrapper(CS)); }
    -#else
    +// #if LLVM_VERSION_MAJOR < 11
    +//     void visitCallSite(CallSite CS) { visitCallInstWrapper(CallInstWrapper(CS)); }
    +// #else
            void visitCallBase(CallBase &CB) { visitCallInstWrapper(CallInstWrapper(CB)); }
    -#endif
    +// #endif
    +       void visitCallInst(CallInst &I) { visitCallInstWrapper(CallInstWrapper(I)); }
    +       void visitInvokeInst(InvokeInst &I) { visitCallInstWrapper(CallInstWrapper(I)); }
    +       void visitCallBrInst(CallBrInst &I) { visitCallInstWrapper(CallInstWrapper(I)); }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions