Skip to content

Immediate Branching related compiler crash #67

@PhilippvK

Description

@PhilippvK

I ran into segfaults trying to use the xcvbi extension on various benchmarks including tacle-bench. Here is the crash dump:

llc ./dijkstra.ll -mattr=+m,+xcvbi -O3 -mtriple=riscv32
Unknown condition code!
UNREACHABLE executed at /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp:782!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /var/tmp/ga87puy/hwlp/install/llvm2/bin/llc ./dijkstra.ll -mattr=+m,+xcvbi -O3 -mtriple=riscv32
1.      Running pass 'Function Pass Manager' on module './dijkstra.ll'.
2.      Running pass 'Control Flow Optimizer' on function '@dijkstra_main'
 #0 0x0000557b04bd5bc2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/lib/Support/Unix/Signals.inc:569:22
 #1 0x0000557b04bd5c7d PrintStackTraceSignalHandler(void*) /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/lib/Support/Unix/Signals.inc:636:1
 #2 0x0000557b04bd3888 llvm::sys::RunSignalHandlers() /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/lib/Support/Signals.cpp:104:20
 #3 0x0000557b04bd54fa SignalHandler(int) /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #4 0x00007fa9607b0420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #5 0x00007fa9601a400b raise /build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #6 0x00007fa960183859 abort /build/glibc-SzIz7B/glibc-2.31/stdlib/abort.c:81:7
 #7 0x0000557b04afe42b bindingsErrorHandler(void*, char const*, bool) /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/lib/Support/ErrorHandling.cpp:221:55
 #8 0x0000557b030d73e9 llvm::RISCVInstrInfo::getBrCond(llvm::RISCVCC::CondCode, bool) const /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp:784:33
 #9 0x0000557b030d7e50 llvm::RISCVInstrInfo::insertBranch(llvm::MachineBasicBlock&, llvm::MachineBasicBlock*, llvm::MachineBasicBlock*, llvm::ArrayRef<llvm::MachineOperand>, llvm::DebugLoc const&, int*) const /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp:947:76
#10 0x0000557b03e28bb9 llvm::BranchFolder::OptimizeBlock(llvm::MachineBasicBlock*) /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/lib/CodeGen/BranchFolding.cpp:1446:24
#11 0x0000557b03e277ea llvm::BranchFolder::OptimizeBranches(llvm::MachineFunction&) /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/lib/CodeGen/BranchFolding.cpp:1207:16
#12 0x0000557b03e22b9e llvm::BranchFolder::OptimizeFunction(llvm::MachineFunction&, llvm::TargetInstrInfo const*, llvm::TargetRegisterInfo const*, llvm::MachineLoopInfo*, bool) /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/lib/CodeGen/BranchFolding.cpp:212:31
#13 0x0000557b03e225f8 (anonymous namespace)::BranchFolderPass::runOnMachineFunction(llvm::MachineFunction&) /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/lib/CodeGen/BranchFolding.cpp:137:33
#14 0x0000557b039a2954 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:91:33
#15 0x0000557b040d39c4 llvm::FPPassManager::runOnFunction(llvm::Function&) /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1430:20
#16 0x0000557b040d3c8d llvm::FPPassManager::runOnModule(llvm::Module&) /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1476:13
#17 0x0000557b040d40ff (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1545:20
#18 0x0000557b040cf020 llvm::legacy::PassManagerImpl::run(llvm::Module&) /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/lib/IR/LegacyPassManager.cpp:535:13
#19 0x0000557b040d49d5 llvm::legacy::PassManager::run(llvm::Module&) /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1673:1
#20 0x0000557b03004f3e compileModule(char**, llvm::LLVMContext&) /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/tools/llc/llc.cpp:737:66
#21 0x0000557b03002ae8 main /var/tmp/ga87puy/hwlp/corev-llvm-project/llvm/tools/llc/llc.cpp:418:35
#22 0x00007fa960185083 __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:342:3
#23 0x0000557b0300184e _start (/var/tmp/ga87puy/hwlp/install/llvm2/bin/llc+0x139884e)
[1]    3337800 abort (core dumped)

#64 contains the fixes for this crash.

LLVM IR for reproducing the issue

Program: sequential/dijkstra

; ModuleID = 'dijkstra.c'
source_filename = "dijkstra.c"
target datalayout = "e-m:e-p:32:32-i64:64-n32-S128"
target triple = "riscv32-unknown-unknown"

%struct._QITEM = type { i32, i32, i32, ptr }
%struct._NODE = type { i32, i32 }

@dijkstra_checksum = dso_local local_unnamed_addr global i32 0, align 4
@dijkstra_AdjMatrix = external dso_local local_unnamed_addr global [100 x [100 x i8]], align 1
@dijkstra_queueCount = dso_local local_unnamed_addr global i32 0, align 4
@dijkstra_queueNext = dso_local local_unnamed_addr global i32 0, align 4
@dijkstra_queueHead = dso_local local_unnamed_addr global ptr null, align 4
@dijkstra_queueItems = dso_local global [1000 x %struct._QITEM] zeroinitializer, align 4
@dijkstra_rgnNodes = dso_local local_unnamed_addr global [100 x %struct._NODE] zeroinitializer, align 4

; Function Attrs: nofree nounwind
define dso_local void @dijkstra_init() local_unnamed_addr #0 {
%1 = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1)
store volatile i32 0, ptr %1, align 4, !tbaa !4
br label %2

2:                                                ; preds = %0, %13
%3 = phi i32 [ 0, %0 ], [ %14, %13 ]
br label %4

4:                                                ; preds = %2, %4
%5 = phi i32 [ 0, %2 ], [ %11, %4 ]
%6 = load volatile i32, ptr %1, align 4, !tbaa !4
%7 = getelementptr inbounds [100 x [100 x i8]], ptr @dijkstra_AdjMatrix, i32 0, i32 %3, i32 %5
%8 = load i8, ptr %7, align 1, !tbaa !8
%9 = trunc i32 %6 to i8
%10 = xor i8 %8, %9
store i8 %10, ptr %7, align 1, !tbaa !8
%11 = add nuw nsw i32 %5, 1
%12 = icmp eq i32 %11, 100
br i1 %12, label %13, label %4, !llvm.loop !9

13:                                               ; preds = %4
%14 = add nuw nsw i32 %3, 1
%15 = icmp eq i32 %14, 100
br i1 %15, label %16, label %2, !llvm.loop !11

16:                                               ; preds = %13
store i32 0, ptr @dijkstra_queueCount, align 4, !tbaa !4
store i32 0, ptr @dijkstra_queueNext, align 4, !tbaa !4
store ptr null, ptr @dijkstra_queueHead, align 4, !tbaa !12
store i32 0, ptr @dijkstra_checksum, align 4, !tbaa !4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1)
ret void
}

; Function Attrs: argmemonly mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: argmemonly mustprogress nocallback nofree nosync nounwind willreturn
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nofree norecurse nosync nounwind readonly willreturn
define dso_local i32 @dijkstra_return() local_unnamed_addr #2 {
%1 = load i32, ptr @dijkstra_checksum, align 4, !tbaa !4
%2 = icmp ne i32 %1, 25
%3 = sext i1 %2 to i32
ret i32 %3
}

; Function Attrs: nofree norecurse nosync nounwind
define dso_local i32 @dijkstra_enqueue(i32 noundef %0, i32 noundef %1, i32 noundef %2) local_unnamed_addr #3 {
%4 = load i32, ptr @dijkstra_queueNext, align 4, !tbaa !4
%5 = getelementptr inbounds [1000 x %struct._QITEM], ptr @dijkstra_queueItems, i32 0, i32 %4
%6 = load ptr, ptr @dijkstra_queueHead, align 4, !tbaa !12
%7 = add nsw i32 %4, 1
store i32 %7, ptr @dijkstra_queueNext, align 4, !tbaa !4
%8 = icmp sgt i32 %4, 998
br i1 %8, label %25, label %9

9:                                                ; preds = %3
store i32 %0, ptr %5, align 4, !tbaa !14
%10 = getelementptr inbounds [1000 x %struct._QITEM], ptr @dijkstra_queueItems, i32 0, i32 %4, i32 1
store i32 %1, ptr %10, align 4, !tbaa !16
%11 = getelementptr inbounds [1000 x %struct._QITEM], ptr @dijkstra_queueItems, i32 0, i32 %4, i32 2
store i32 %2, ptr %11, align 4, !tbaa !17
%12 = getelementptr inbounds [1000 x %struct._QITEM], ptr @dijkstra_queueItems, i32 0, i32 %4, i32 3
store ptr null, ptr %12, align 4, !tbaa !18
%13 = icmp eq ptr %6, null
br i1 %13, label %21, label %14

14:                                               ; preds = %9, %14
%15 = phi ptr [ %17, %14 ], [ %6, %9 ]
%16 = getelementptr inbounds %struct._QITEM, ptr %15, i32 0, i32 3
%17 = load ptr, ptr %16, align 4, !tbaa !18
%18 = icmp eq ptr %17, null
br i1 %18, label %19, label %14, !llvm.loop !19

19:                                               ; preds = %14
%20 = getelementptr inbounds %struct._QITEM, ptr %15, i32 0, i32 3
br label %21

21:                                               ; preds = %9, %19
%22 = phi ptr [ %20, %19 ], [ @dijkstra_queueHead, %9 ]
store ptr %5, ptr %22, align 4, !tbaa !12
%23 = load i32, ptr @dijkstra_queueCount, align 4, !tbaa !4
%24 = add nsw i32 %23, 1
store i32 %24, ptr @dijkstra_queueCount, align 4, !tbaa !4
br label %25

25:                                               ; preds = %3, %21
%26 = phi i32 [ 0, %21 ], [ -1, %3 ]
ret i32 %26
}

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
define dso_local void @dijkstra_dequeue(ptr nocapture noundef writeonly %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #4 {
%4 = load ptr, ptr @dijkstra_queueHead, align 4, !tbaa !12
%5 = icmp eq ptr %4, null
br i1 %5, label %16, label %6

6:                                                ; preds = %3
%7 = load i32, ptr %4, align 4, !tbaa !14
store i32 %7, ptr %0, align 4, !tbaa !4
%8 = getelementptr inbounds %struct._QITEM, ptr %4, i32 0, i32 1
%9 = load i32, ptr %8, align 4, !tbaa !16
store i32 %9, ptr %1, align 4, !tbaa !4
%10 = getelementptr inbounds %struct._QITEM, ptr %4, i32 0, i32 2
%11 = load i32, ptr %10, align 4, !tbaa !17
store i32 %11, ptr %2, align 4, !tbaa !4
%12 = getelementptr inbounds %struct._QITEM, ptr %4, i32 0, i32 3
%13 = load ptr, ptr %12, align 4, !tbaa !18
store ptr %13, ptr @dijkstra_queueHead, align 4, !tbaa !12
%14 = load i32, ptr @dijkstra_queueCount, align 4, !tbaa !4
%15 = add nsw i32 %14, -1
store i32 %15, ptr @dijkstra_queueCount, align 4, !tbaa !4
br label %16

16:                                               ; preds = %6, %3
ret void
}

; Function Attrs: mustprogress nofree norecurse nosync nounwind readonly willreturn
define dso_local i32 @dijkstra_qcount() local_unnamed_addr #2 {
%1 = load i32, ptr @dijkstra_queueCount, align 4, !tbaa !4
ret i32 %1
}

; Function Attrs: nofree nosync nounwind
define dso_local i32 @dijkstra_find(i32 noundef %0, i32 noundef %1) local_unnamed_addr #5 {
br label %3

3:                                                ; preds = %2, %3
%4 = phi i32 [ 0, %2 ], [ %7, %3 ]
%5 = getelementptr inbounds [100 x %struct._NODE], ptr @dijkstra_rgnNodes, i32 0, i32 %4
store i32 9999, ptr %5, align 4, !tbaa !20
%6 = getelementptr inbounds [100 x %struct._NODE], ptr @dijkstra_rgnNodes, i32 0, i32 %4, i32 1
store i32 9999, ptr %6, align 4, !tbaa !22
%7 = add nuw nsw i32 %4, 1
%8 = icmp eq i32 %7, 100
br i1 %8, label %9, label %3, !llvm.loop !23

9:                                                ; preds = %3
%10 = icmp eq i32 %0, %1
br i1 %10, label %99, label %11

11:                                               ; preds = %9
%12 = getelementptr inbounds [100 x %struct._NODE], ptr @dijkstra_rgnNodes, i32 0, i32 %0
store i32 0, ptr %12, align 4, !tbaa !20
%13 = getelementptr inbounds [100 x %struct._NODE], ptr @dijkstra_rgnNodes, i32 0, i32 %0, i32 1
store i32 9999, ptr %13, align 4, !tbaa !22
%14 = load i32, ptr @dijkstra_queueNext, align 4, !tbaa !4
%15 = getelementptr inbounds [1000 x %struct._QITEM], ptr @dijkstra_queueItems, i32 0, i32 %14
%16 = load ptr, ptr @dijkstra_queueHead, align 4, !tbaa !12
%17 = add nsw i32 %14, 1
store i32 %17, ptr @dijkstra_queueNext, align 4, !tbaa !4
%18 = icmp sgt i32 %14, 998
br i1 %18, label %99, label %19

19:                                               ; preds = %11
store i32 %0, ptr %15, align 4, !tbaa !14
%20 = getelementptr inbounds [1000 x %struct._QITEM], ptr @dijkstra_queueItems, i32 0, i32 %14, i32 1
store i32 0, ptr %20, align 4, !tbaa !16
%21 = getelementptr inbounds [1000 x %struct._QITEM], ptr @dijkstra_queueItems, i32 0, i32 %14, i32 2
store i32 9999, ptr %21, align 4, !tbaa !17
%22 = getelementptr inbounds [1000 x %struct._QITEM], ptr @dijkstra_queueItems, i32 0, i32 %14, i32 3
store ptr null, ptr %22, align 4, !tbaa !18
%23 = icmp eq ptr %16, null
br i1 %23, label %31, label %24

24:                                               ; preds = %19, %24
%25 = phi ptr [ %27, %24 ], [ %16, %19 ]
%26 = getelementptr inbounds %struct._QITEM, ptr %25, i32 0, i32 3
%27 = load ptr, ptr %26, align 4, !tbaa !18
%28 = icmp eq ptr %27, null
br i1 %28, label %29, label %24, !llvm.loop !19

29:                                               ; preds = %24
%30 = getelementptr inbounds %struct._QITEM, ptr %25, i32 0, i32 3
br label %31

31:                                               ; preds = %29, %19
%32 = phi ptr [ @dijkstra_queueHead, %19 ], [ %30, %29 ]
store ptr %15, ptr %32, align 4, !tbaa !12
%33 = load i32, ptr @dijkstra_queueCount, align 4, !tbaa !4
%34 = add nsw i32 %33, 1
store i32 %34, ptr @dijkstra_queueCount, align 4, !tbaa !4
%35 = icmp sgt i32 %33, -1
br i1 %35, label %38, label %99

36:                                               ; preds = %92
%37 = icmp sgt i32 %93, 0
br i1 %37, label %38, label %99

38:                                               ; preds = %31, %36
%39 = phi i32 [ %93, %36 ], [ %34, %31 ]
%40 = phi i32 [ %94, %36 ], [ %17, %31 ]
%41 = phi i32 [ %55, %36 ], [ 0, %31 ]
%42 = phi i32 [ %54, %36 ], [ 0, %31 ]
%43 = load ptr, ptr @dijkstra_queueHead, align 4, !tbaa !12
%44 = icmp eq ptr %43, null
br i1 %44, label %52, label %45

45:                                               ; preds = %38
%46 = load i32, ptr %43, align 4, !tbaa !14
%47 = getelementptr inbounds %struct._QITEM, ptr %43, i32 0, i32 1
%48 = load i32, ptr %47, align 4, !tbaa !16
%49 = getelementptr inbounds %struct._QITEM, ptr %43, i32 0, i32 3
%50 = load ptr, ptr %49, align 4, !tbaa !18
store ptr %50, ptr @dijkstra_queueHead, align 4, !tbaa !12
%51 = add nsw i32 %39, -1
store i32 %51, ptr @dijkstra_queueCount, align 4, !tbaa !4
br label %52

52:                                               ; preds = %38, %45
%53 = phi i32 [ %39, %38 ], [ %51, %45 ]
%54 = phi i32 [ %42, %38 ], [ %46, %45 ]
%55 = phi i32 [ %41, %38 ], [ %48, %45 ]
br label %56

56:                                               ; preds = %52, %92
%57 = phi i32 [ %53, %52 ], [ %93, %92 ]
%58 = phi i32 [ %40, %52 ], [ %94, %92 ]
%59 = phi i32 [ 0, %52 ], [ %97, %92 ]
%60 = phi i32 [ %40, %52 ], [ %96, %92 ]
%61 = phi i32 [ %53, %52 ], [ %95, %92 ]
%62 = getelementptr inbounds [100 x [100 x i8]], ptr @dijkstra_AdjMatrix, i32 0, i32 %54, i32 %59
%63 = load i8, ptr %62, align 1, !tbaa !8
%64 = zext i8 %63 to i32
%65 = getelementptr inbounds [100 x %struct._NODE], ptr @dijkstra_rgnNodes, i32 0, i32 %59
%66 = load i32, ptr %65, align 4, !tbaa !20
%67 = icmp eq i32 %66, 9999
%68 = add nsw i32 %55, %64
%69 = icmp sgt i32 %66, %68
%70 = select i1 %67, i1 true, i1 %69
br i1 %70, label %71, label %92

71:                                               ; preds = %56
store i32 %68, ptr %65, align 4, !tbaa !20
%72 = getelementptr inbounds [100 x %struct._NODE], ptr @dijkstra_rgnNodes, i32 0, i32 %59, i32 1
store i32 %54, ptr %72, align 4, !tbaa !22
%73 = getelementptr inbounds [1000 x %struct._QITEM], ptr @dijkstra_queueItems, i32 0, i32 %60
%74 = load ptr, ptr @dijkstra_queueHead, align 4, !tbaa !12
%75 = add nsw i32 %60, 1
store i32 %75, ptr @dijkstra_queueNext, align 4, !tbaa !4
%76 = icmp sgt i32 %60, 998
br i1 %76, label %99, label %77

77:                                               ; preds = %71
store i32 %59, ptr %73, align 4, !tbaa !14
%78 = getelementptr inbounds [1000 x %struct._QITEM], ptr @dijkstra_queueItems, i32 0, i32 %60, i32 1
store i32 %68, ptr %78, align 4, !tbaa !16
%79 = getelementptr inbounds [1000 x %struct._QITEM], ptr @dijkstra_queueItems, i32 0, i32 %60, i32 2
store i32 %54, ptr %79, align 4, !tbaa !17
%80 = getelementptr inbounds [1000 x %struct._QITEM], ptr @dijkstra_queueItems, i32 0, i32 %60, i32 3
store ptr null, ptr %80, align 4, !tbaa !18
%81 = icmp eq ptr %74, null
br i1 %81, label %89, label %82

82:                                               ; preds = %77, %82
%83 = phi ptr [ %85, %82 ], [ %74, %77 ]
%84 = getelementptr inbounds %struct._QITEM, ptr %83, i32 0, i32 3
%85 = load ptr, ptr %84, align 4, !tbaa !18
%86 = icmp eq ptr %85, null
br i1 %86, label %87, label %82, !llvm.loop !19

87:                                               ; preds = %82
%88 = getelementptr inbounds %struct._QITEM, ptr %83, i32 0, i32 3
br label %89

89:                                               ; preds = %87, %77
%90 = phi ptr [ @dijkstra_queueHead, %77 ], [ %88, %87 ]
store ptr %73, ptr %90, align 4, !tbaa !12
%91 = add nsw i32 %61, 1
store i32 %91, ptr @dijkstra_queueCount, align 4, !tbaa !4
br label %92

92:                                               ; preds = %56, %89
%93 = phi i32 [ %57, %56 ], [ %91, %89 ]
%94 = phi i32 [ %58, %56 ], [ %75, %89 ]
%95 = phi i32 [ %61, %56 ], [ %91, %89 ]
%96 = phi i32 [ %60, %56 ], [ %75, %89 ]
%97 = add nuw nsw i32 %59, 1
%98 = icmp eq i32 %97, 100
br i1 %98, label %36, label %56, !llvm.loop !24

99:                                               ; preds = %36, %71, %31, %11, %9
%100 = phi i32 [ 0, %9 ], [ -1, %11 ], [ 0, %31 ], [ -1, %71 ], [ 0, %36 ]
ret i32 %100
}

; Function Attrs: nofree nosync nounwind
define dso_local void @dijkstra_main() local_unnamed_addr #5 {
br label %1

1:                                                ; preds = %0, %10
%2 = phi i32 [ 50, %0 ], [ %16, %10 ]
%3 = phi i32 [ 0, %0 ], [ %15, %10 ]
%4 = srem i32 %2, 100
%5 = tail call i32 @dijkstra_find(i32 noundef %3, i32 noundef %4)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %10

7:                                                ; preds = %1
%8 = load i32, ptr @dijkstra_checksum, align 4, !tbaa !4
%9 = add nsw i32 %8, -1
store i32 %9, ptr @dijkstra_checksum, align 4, !tbaa !4
br label %18

10:                                               ; preds = %1
%11 = getelementptr inbounds [100 x %struct._NODE], ptr @dijkstra_rgnNodes, i32 0, i32 %4
%12 = load i32, ptr %11, align 4, !tbaa !20
%13 = load i32, ptr @dijkstra_checksum, align 4, !tbaa !4
%14 = add nsw i32 %13, %12
store i32 %14, ptr @dijkstra_checksum, align 4, !tbaa !4
store i32 0, ptr @dijkstra_queueNext, align 4, !tbaa !4
%15 = add nuw nsw i32 %3, 1
%16 = add nsw i32 %4, 1
%17 = icmp eq i32 %15, 20
br i1 %17, label %18, label %1, !llvm.loop !25

18:                                               ; preds = %10, %7
ret void
}

; Function Attrs: nofree nounwind
define dso_local i32 @main() local_unnamed_addr #0 {
%1 = alloca i32, align 4
call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1)
store volatile i32 0, ptr %1, align 4, !tbaa !4
br label %2

2:                                                ; preds = %13, %0
%3 = phi i32 [ 0, %0 ], [ %14, %13 ]
br label %4

4:                                                ; preds = %4, %2
%5 = phi i32 [ 0, %2 ], [ %11, %4 ]
%6 = load volatile i32, ptr %1, align 4, !tbaa !4
%7 = getelementptr inbounds [100 x [100 x i8]], ptr @dijkstra_AdjMatrix, i32 0, i32 %3, i32 %5
%8 = load i8, ptr %7, align 1, !tbaa !8
%9 = trunc i32 %6 to i8
%10 = xor i8 %8, %9
store i8 %10, ptr %7, align 1, !tbaa !8
%11 = add nuw nsw i32 %5, 1
%12 = icmp eq i32 %11, 100
br i1 %12, label %13, label %4, !llvm.loop !9

13:                                               ; preds = %4
%14 = add nuw nsw i32 %3, 1
%15 = icmp eq i32 %14, 100
br i1 %15, label %16, label %2, !llvm.loop !11

16:                                               ; preds = %13
store i32 0, ptr @dijkstra_queueCount, align 4, !tbaa !4
store i32 0, ptr @dijkstra_queueNext, align 4, !tbaa !4
store ptr null, ptr @dijkstra_queueHead, align 4, !tbaa !12
store i32 0, ptr @dijkstra_checksum, align 4, !tbaa !4
call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1)
br label %17

17:                                               ; preds = %26, %16
%18 = phi i32 [ 50, %16 ], [ %32, %26 ]
%19 = phi i32 [ 0, %16 ], [ %31, %26 ]
%20 = srem i32 %18, 100
%21 = tail call i32 @dijkstra_find(i32 noundef %19, i32 noundef %20)
%22 = icmp eq i32 %21, -1
br i1 %22, label %23, label %26

23:                                               ; preds = %17
%24 = load i32, ptr @dijkstra_checksum, align 4, !tbaa !4
%25 = add nsw i32 %24, -1
store i32 %25, ptr @dijkstra_checksum, align 4, !tbaa !4
br label %34

26:                                               ; preds = %17
%27 = getelementptr inbounds [100 x %struct._NODE], ptr @dijkstra_rgnNodes, i32 0, i32 %20
%28 = load i32, ptr %27, align 4, !tbaa !20
%29 = load i32, ptr @dijkstra_checksum, align 4, !tbaa !4
%30 = add nsw i32 %29, %28
store i32 %30, ptr @dijkstra_checksum, align 4, !tbaa !4
store i32 0, ptr @dijkstra_queueNext, align 4, !tbaa !4
%31 = add nuw nsw i32 %19, 1
%32 = add nsw i32 %20, 1
%33 = icmp eq i32 %31, 20
br i1 %33, label %34, label %17, !llvm.loop !25

34:                                               ; preds = %26, %23
%35 = phi i32 [ %25, %23 ], [ %30, %26 ]
%36 = icmp ne i32 %35, 25
%37 = sext i1 %36 to i32
ret i32 %37
}

attributes #0 = { nofree nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+32bit,+m,+relax,+xcvbi,-save-restore" }
attributes #1 = { argmemonly mustprogress nocallback nofree nosync nounwind willreturn }
attributes #2 = { mustprogress nofree norecurse nosync nounwind readonly willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+32bit,+m,+relax,+xcvbi,-save-restore" }
attributes #3 = { nofree norecurse nosync nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+32bit,+m,+relax,+xcvbi,-save-restore" }
attributes #4 = { mustprogress nofree norecurse nosync nounwind willreturn "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+32bit,+m,+relax,+xcvbi,-save-restore" }
attributes #5 = { nofree nosync nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+32bit,+m,+relax,+xcvbi,-save-restore" }

!llvm.module.flags = !{!0, !1, !2}
!llvm.ident = !{!3}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 1, !"target-abi", !"ilp32"}
!2 = !{i32 1, !"SmallDataLimit", i32 8}
!3 = !{!"clang version 16.0.0 ([email protected]:PhilippvK/corev-llvm-project.git f138c532b40c6bcc9b98245f2769f6b9efab4e80)"}
!4 = !{!5, !5, i64 0}
!5 = !{!"int", !6, i64 0}
!6 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!6, !6, i64 0}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = !{!13, !13, i64 0}
!13 = !{!"any pointer", !6, i64 0}
!14 = !{!15, !5, i64 0}
!15 = !{!"_QITEM", !5, i64 0, !5, i64 4, !5, i64 8, !13, i64 12}
!16 = !{!15, !5, i64 4}
!17 = !{!15, !5, i64 8}
!18 = !{!15, !13, i64 12}
!19 = distinct !{!19, !10}
!20 = !{!21, !5, i64 0}
!21 = !{!"_NODE", !5, i64 0, !5, i64 4}
!22 = !{!21, !5, i64 4}
!23 = distinct !{!23, !10}
!24 = distinct !{!24, !10}
!25 = distinct !{!25, !10}

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