cpc / openasip

Open Application-Specific Instruction Set processor tools (OpenASIP)
http://openasip.org
Other
140 stars 42 forks source link

Assertion `!instructionStartCache_.empty()' failed #175

Open nrother opened 2 years ago

nrother commented 2 years ago

When trying to compile a program using tcecc I get the following error message:

rother@pikachu:~/Documents/TTA/GBP_TTA/tta_bug$ tcecc --version
tcecc - TCE retargetable compiler 1.25
rother@pikachu:~/Documents/TTA/GBP_TTA/tta_bug$ tcecc -x c++ -O3 -a baseline.adf -o gbp.tpef gbp.cpp
llvm-tce: CodeSection.cc:131: void TPEF::CodeSection::initInstructionCache() const: Assertion `!instructionStartCache_.empty()' failed.

This looks like a compiler bug to me.

Minimal example to reproduce this bug:

gbp.cpp

#include "fpm_tta/fixed.hpp"
namespace ff = fpm;
using position_t = fpm::fixed<int32_t, int32_t, 16>;

volatile int32_t antennaPositions[20];

int main()
{
    position_t *antennaPositions = (position_t*)antennaPositions;

    position_t beamlimitMaxRangeDist = antennaPositions[1];

    volatile int *tmp = (volatile int*)0x200;
    *tmp = (volatile int)beamlimitMaxRangeDist;

    return 0;
}

fpm_tta/fixed.hpp

#ifndef FPM_FIXED_HPP
#define FPM_FIXED_HPP

#include <stdint.h> //note: not int64_t on TTA!

namespace fpm
{

template <typename BaseType, typename IntermediateType, unsigned int FractionBits>
class fixed
{
    static constexpr BaseType FRACTION_MULT = BaseType(1) << FractionBits;

public:
    template <typename T>
    constexpr inline explicit operator T() const noexcept
    {
        return static_cast<T>(m_value) / FRACTION_MULT;
    }

private:
    BaseType m_value;
};

} // namespace fpm

#endif

Let me know if you need any further information!

nrother commented 2 years ago

Interestingly, it fails in version 1.22 with a different error message:

rother@pikachu:~/Documents/TTA/GBP_TTA/tta_bug$ tcecc --version
tcecc - TCE retargetable compiler 1.22
rother@pikachu:~/Documents/TTA/GBP_TTA/tta_bug$ tcecc -x c++ -O3 -a baseline.adf -o gbp.tpef gbp.cpp
Error: procedure '_exit' not found!

I have no tested it with the latest version from git.

pjaaskel commented 2 years ago

Let me know if you need any further information!

Just a pull request to fix it will do :) Just kidding. The C++ support is not much tested and far from stable, so either you have to be prepared to stabilize the code related to that and contribute back to OpenASIP or use C.