Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLVM ERROR: Instruction Combining did not reach a fixpoint after 1 iterations #65107

Closed
chfast opened this issue Aug 30, 2023 · 6 comments
Closed

Comments

@chfast
Copy link
Member

chfast commented Aug 30, 2023

define i1 @f(i16 %0) {
  br label %BB1

BB1:                                              ; preds = %BB1, %BB
  %C = icmp ult i16 256, %0
  br i1 true, label %BB1, label %BB2

BB2:                                              ; preds = %BB1
  ret i1 %C
}

https://godbolt.org/z/h7o9sbEKP

LLVM ERROR: Instruction Combining did not reach a fixpoint after 1 iterations
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes instcombine <source>
 #0 0x00000000034a5a58 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x34a5a58)
 #1 0x00000000034a318c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f8a50d47420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f8a5080a00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f8a507e9859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00000000007834af (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x7834af)
 #6 0x000000000300c8d8 combineInstructionsOverFunction(llvm::Function&, llvm::InstructionWorklist&, llvm::AAResults*, llvm::AssumptionCache&, llvm::TargetLibraryInfo&, llvm::TargetTransformInfo&, llvm::DominatorTree&, llvm::OptimizationRemarkEmitter&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, unsigned int, bool, llvm::LoopInfo*) InstructionCombining.cpp:0:0
 #7 0x000000000300cf4a llvm::InstCombinePass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x300cf4a)
 #8 0x00000000036ba32e llvm::detail::PassModel<llvm::Function, llvm::InstCombinePass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x36ba32e)
 #9 0x0000000000d3fd8d llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xd3fd8d)
#10 0x0000000002e0ebde llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2e0ebde)
#11 0x0000000000d247de llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0xd247de)
#12 0x0000000002e0cbdc llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2e0cbdc)
#13 0x000000000088448a llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x88448a)
#14 0x000000000078e621 main (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x78e621)
#15 0x00007f8a507eb083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#16 0x000000000087980e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x87980e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
@arpilipe
Copy link
Contributor

arpilipe commented Sep 5, 2023

According to our autotriage this is a regression caused/triggered by 72ec2c0 commit.

@nikic, could you please take a look?

@ParkHanbum
Copy link
Contributor

after 1st running combining :

define i1 @f(i16 %0) {
  br label %BB1

BB1:                                              ; preds = %BB1, %1
  br i1 true, label %BB1, label %BB2

BB2:                                              ; preds = %BB1
  %C = icmp ugt i16 %0, 256
  ret i1 %C
}

try to remove %C = icmp ugt i16 %0, 256 in prepareWorklist.

    std::tie(NumDeadInstInBB, NumDeadDbgInstInBB) =
        removeAllNonTerminatorAndEHPadInstructions(&BB);
Breakpoint 9, llvm::removeAllNonTerminatorAndEHPadInstructions (BB=0x55555cc7fba0) at /home/m/llvm-origin/llvm/lib/Transforms/Utils/Local.cpp:2800
2800	    Inst->eraseFromParent();
(gdb) p Inst->dump()
  %C = icmp ugt i16 %0, 256
(gdb) p Inst->getParent()->dump()

BB2:                                              ; preds = %BB1
  %C = icmp ugt i16 %0, 256
  ret i1 poison

after this, prepareWorklist return true

    MadeIRChange |= NumDeadInstInBB + NumDeadDbgInstInBB > 0;
    NumDeadInst += NumDeadInstInBB;

MadeChangeInThisIteration setted to true make it reach to report_fatal_error

    IC.MaxArraySizeForCombine = MaxArraySize;
    bool MadeChangeInThisIteration = IC.prepareWorklist(F, RPOT);
    MadeChangeInThisIteration |= IC.run();
    if (!MadeChangeInThisIteration)
      break;

    MadeIRChange = true;
    if (Iteration > Opts.MaxIterations) {
      report_fatal_error(
          "Instruction Combining did not reach a fixpoint after " +
          Twine(Opts.MaxIterations) + " iterations");

so, it print LLVM ERROR as final result

@ParkHanbum
Copy link
Contributor

ParkHanbum commented Jan 13, 2024

can I try to this issue?
any advices is welcome.

@EugeneZelenko
Copy link
Contributor

@ParkHanbum: Just prepare pull request and mention it on this page.

@ParkHanbum
Copy link
Contributor

@EugeneZelenko got it

@nikic
Copy link
Contributor

nikic commented Jan 13, 2024

@ParkHanbum In

void InstCombinerImpl::handleUnreachableFrom(
and inside removeAllNonTerminatorAndEHPadInstructions, replace operands in the terminator instruction with poison.

ParkHanbum added a commit to ParkHanbum/llvm-project that referenced this issue Jan 19, 2024
…it to poison (llvm#65107)

Instructions in unreachable basic blocks are removed, but terminators
are not. In this case, even instructions that are only referenced by
a terminator, such as a return instruction, cannot be processed
properly.

This patch changes the operand of a return instruction in an
unreachable basic block to poison if it refers to the instruction,
allowing the instruction to be properly processed.
ParkHanbum added a commit to ParkHanbum/llvm-project that referenced this issue Jan 30, 2024
…on (llvm#65107)

Instructions in unreachable basic blocks are removed, but terminators
are not. In this case, even instructions that are only referenced by
a terminator, such as a return instruction, cannot be processed
properly.

This patch changes the operand of terminator instruction in an
unreachable basic block to poison if it refers to the instruction,
allowing the instruction to be properly processed.
ParkHanbum added a commit to ParkHanbum/llvm-project that referenced this issue Jan 30, 2024
…on (llvm#65107)

Instructions in unreachable basic blocks are removed, but terminators
are not. In this case, even instructions that are only referenced by
a terminator, such as a return instruction, cannot be processed
properly.

This patch changes the operand of terminator instruction in an
unreachable basic block to poison if it refers to the instruction,
allowing the instruction to be properly processed.
ParkHanbum added a commit to ParkHanbum/llvm-project that referenced this issue Feb 3, 2024
…on (llvm#65107)

Instructions in unreachable basic blocks are removed, but terminators
are not. In this case, even instructions that are only referenced by
a terminator, such as a return instruction, cannot be processed
properly.

This patch changes the operand of terminator instruction in an
unreachable basic block to poison if it refers to the instruction,
allowing the instruction to be properly processed.
ParkHanbum added a commit to ParkHanbum/llvm-project that referenced this issue Feb 14, 2024
…on (llvm#65107)

Instructions in unreachable basic blocks are removed, but terminators
are not. In this case, even instructions that are only referenced by
a terminator, such as a return instruction, cannot be processed
properly.

This patch changes the operand of terminator instruction in an
unreachable basic block to poison if it refers to the instruction,
allowing the instruction to be properly processed.
ParkHanbum added a commit to ParkHanbum/llvm-project that referenced this issue Feb 14, 2024
…on (llvm#65107)

Instructions in unreachable basic blocks are removed, but terminators
are not. In this case, even instructions that are only referenced by
a terminator, such as a return instruction, cannot be processed
properly.

This patch changes the operand of terminator instruction in an
unreachable basic block to poison if it refers to the instruction,
allowing the instruction to be properly processed.
ParkHanbum added a commit to ParkHanbum/llvm-project that referenced this issue Feb 16, 2024
…on (llvm#65107)

Instructions in unreachable basic blocks are removed, but terminators
are not. In this case, even instructions that are only referenced by
a terminator, such as a return instruction, cannot be processed
properly.

This patch changes the operand of terminator instruction in an
unreachable basic block to poison if it refers to the instruction,
allowing the instruction to be properly processed.
ParkHanbum added a commit to ParkHanbum/llvm-project that referenced this issue Feb 19, 2024
…on (llvm#65107)

Instructions in unreachable basic blocks are removed, but terminators
are not. In this case, even instructions that are only referenced by
a terminator, such as a return instruction, cannot be processed
properly.

This patch changes the operand of terminator instruction in an
unreachable basic block to poison if it refers to the instruction,
allowing the instruction to be properly processed.
ParkHanbum added a commit to ParkHanbum/llvm-project that referenced this issue Feb 19, 2024
…on (llvm#65107)

Instructions in unreachable basic blocks are removed, but terminators
are not. In this case, even instructions that are only referenced by
a terminator, such as a return instruction, cannot be processed
properly.

This patch changes the operand of terminator instruction in an
unreachable basic block to poison if it refers to the instruction,
allowing the instruction to be properly processed.
ParkHanbum added a commit to ParkHanbum/llvm-project that referenced this issue Feb 20, 2024
…on (llvm#65107)

Instructions in unreachable basic blocks are removed, but terminators
are not. In this case, even instructions that are only referenced by
a terminator, such as a return instruction, cannot be processed
properly.

This patch changes the operand of terminator instruction in an
unreachable basic block to poison if it refers to the instruction,
allowing the instruction to be properly processed.
@nikic nikic closed this as completed in 6cdf596 Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants