Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Singlepath: crashes on break from nested loop #19

Open
@Emoun

Description

llc crashes on an assertion error when trying to compile a program, using singlepath, where an inner loop breaks out of an outer loop:

#include <stdio.h>

volatile int _1 = 1;

int init_func(int outer, int inner){
  int x = 0; 
  #pragma loopbound min 0 max 10
  for(int i = 0; i < outer; i++){
    #pragma loopbound min 0 max 4
    for(int k = 0; k < 5; k++){
      if( (x%100) == inner){
        goto breakLoops; // break out of both loops
      }
      x += _1;
    }
    x += 100;
  }
  breakLoops:
  return x;
}

int main(){
  int outer, inner;
  scanf("%d %d", &outer, &inner);
  printf("%d\n", init_func(outer, inner));
}

Compiling using the command patmos-clang main.c -mpatmos-singlepath=init_func results in the following error:

patmos-llc: /home/s123791/emoun/llvm/lib/Target/Patmos/PatmosSPReduce.cpp:1225: void {anonymous}::PatmosSPReduce::insertDefEdge(llvm::SPScope*, llvm::MachineBasicBlock&, unsigned int, llvm::SPScope::Edge): Assertion `!S->isSubHeader(&Node) || (RI.Scope->getParent() == S)' failed.
0  libLLVMSupport.so       0x00007fb9fe9ec39c llvm::sys::PrintStackTrace(_IO_FILE*) + 53
1  libLLVMSupport.so       0x00007fb9fe9ec62c
2  libLLVMSupport.so       0x00007fb9fe9ebfda
3  libc.so.6               0x00007fb9fe18a4b0
4  libc.so.6               0x00007fb9fe18a428 gsignal + 56
5  libc.so.6               0x00007fb9fe18c02a abort + 362
6  libc.so.6               0x00007fb9fe182bd7
7  libc.so.6               0x00007fb9fe182c82
8  libLLVMPatmosCodeGen.so 0x00007fba016669e7
9  libLLVMPatmosCodeGen.so 0x00007fba01666710
10 libLLVMPatmosCodeGen.so 0x00007fba016651fb
11 libLLVMPatmosCodeGen.so 0x00007fba01663362
12 libLLVMCodeGen.so       0x00007fba000cfd07 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 95
13 libLLVMCore.so          0x00007fb9ff258946 llvm::FPPassManager::runOnFunction(llvm::Function&) + 330
14 libLLVMCore.so          0x00007fb9ff258abc llvm::FPPassManager::runOnModule(llvm::Module&) + 120
15 libLLVMCore.so          0x00007fb9ff258dbc
16 libLLVMCore.so          0x00007fb9ff25938f llvm::legacy::PassManagerImpl::run(llvm::Module&) + 267
17 libLLVMCore.so          0x00007fb9ff259569 llvm::legacy::PassManager::run(llvm::Module&) + 39
18 patmos-llc              0x000000000040ce99
19 patmos-llc              0x000000000040beac
20 libc.so.6               0x00007fb9fe175830 __libc_start_main + 240
21 patmos-llc              0x000000000040b779
Stack dump:
0.      Program arguments: /home/s123791/emoun/local/bin/patmos-llc -O0 -mforce-block-labels -disable-separate-nested-loops -mpatmos-singlepath=init_func -filetype=obj -o /tmp/a-104e35.bc.o /tmp/a-8e960e.bc
1.      Running pass 'Function Pass Manager' on module '/tmp/a-8e960e.bc'.
2.      Running pass 'Patmos Single-Path Reducer' on function '@init_func'
patmos-clang-3.4: error: unable to execute command: Aborted (core dumped)
patmos-clang-3.4: error: link  via llvm-link, opt and llc command failed due to signal (use -v to see invocation)

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions