https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120729

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
So the code checks _all_ paths through the CFG, visited_flag_phis only prunes
backedges during the recursion of of processing one path.  To be unlucky
one has to have a very deep back-to-back PHI def chain, with each two args
you then get 2^N exponential number of paths to check.

I have a patch to limit the search, but then you get a diagnostic:

/home/harald/llvm-project/main/llvm/utils/TableGen/X86RecognizableInstr.cpp: In
static member function ‘static llvm::X86Disassembler::OperandType
llvm::X86Disassembler::RecognizableInstr::typeFromString(llvm::StringRef, bool,
uint8_t)’:
/home/harald/llvm-project/main/llvm/utils/TableGen/X86RecognizableInstr.cpp:1171:12:
warning: ‘*(unsigned int*)((char*)&Switch +
offsetof(llvm::StringSwitch<llvm::X86Disassembler::OperandType,
llvm::X86Disassembler::OperandType>,llvm::StringSwitch<llvm::X86Disassembler::OperandType,
llvm::X86Disassembler::OperandType>::Result.std::optional<llvm::X86Disassembler::OperandType>::<unnamed>.std::_Optional_base<llvm::X86Disassembler::OperandType,
true, true>::<unnamed>))’ may be used uninitialized [-Wmaybe-uninitialized]
/home/harald/llvm-project/main/llvm/utils/TableGen/X86RecognizableInstr.cpp:1026:29:
note: ‘*(unsigned int*)((char*)&Switch +
offsetof(llvm::StringSwitch<llvm::X86Disassembler::OperandType,
llvm::X86Disassembler::OperandType>,llvm::StringSwitch<llvm::X86Disassembler::OperandType,
llvm::X86Disassembler::OperandType>::Result.std::optional<llvm::X86Disassembler::OperandType>::<unnamed>.std::_Optional_base<llvm::X86Disassembler::OperandType,
true, true>::<unnamed>))’ was declared here

Note with GCC 15+ we might simply have optimized enough to avoid this.  Even
with a very very large amount of work (10000000 pruned path elements allowed)
we diagnose this.  With an -O0 compiler uninit analysis the takes 30%
of the compile-time.

Reply via email to