[llvm] [X86] For minsize memset/memcpy, use byte or double-word accesses (PR #87003)

via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 7 06:25:15 PDT 2024


zmodem wrote:

We're hitting an assert after this change:

```
$ cat /tmp/bug.ll
target triple = "i686-pc-windows-msvc"

declare void @llvm.memset.p0.i32(ptr nocapture writeonly, i8, i32, i1 immarg)

define dso_local void @foo(ptr %0) {
  call void @llvm.memset.p0.i32(ptr noundef nonnull align 4 dereferenceable(90) %0, i8 -1, i32 90, i1 false)
  ret void
}

$ build/bin/llc /tmp/bug.ll
llc: /work/llvm-project/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:7736: SDValue getMemsetValue(SDValue, EVT, SelectionDAG &, const SDLoc &): Assertion `C->getAPIntValue().getBitWidth() == 8' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: build/bin/llc /tmp/bug.ll
1.      Running pass 'Function Pass Manager' on module '/tmp/bug.ll'.
2.      Running pass 'X86 DAG->DAG Instruction Selection' on function '@foo'
 #0 0x00005557413cadb8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (build/bin/llc+0x367adb8)
 #1 0x00005557413c896e llvm::sys::RunSignalHandlers() (build/bin/llc+0x367896e)
 #2 0x00005557413cb448 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f5003c591a0 (/lib/x86_64-linux-gnu/libc.so.6+0x3d1a0)
 #4 0x00007f5003ca70ec __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #5 0x00007f5003c59102 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #6 0x00007f5003c424f2 abort ./stdlib/abort.c:81:7
 #7 0x00007f5003c42415 _nl_load_domain ./intl/loadmsgcat.c:1177:9
 #8 0x00007f5003c51d32 (/lib/x86_64-linux-gnu/libc.so.6+0x35d32)
 #9 0x00005557411b5e69 getMemsetValue(llvm::SDValue, llvm::EVT, llvm::SelectionDAG&, llvm::SDLoc const&) SelectionDAG.cpp:0:0
#10 0x0000555741193faa getMemsetStores(llvm::SelectionDAG&, llvm::SDLoc const&, llvm::SDValue, llvm::SDValue, llvm::SDValue, unsigned long, llvm::Align, bool, bool, llvm::MachinePointerInfo, llvm::AAMDNodes const&) SelectionDAG.cpp:0:0
#11 0x0000555741192f43 llvm::SelectionDAG::getMemset(llvm::SDValue, llvm::SDLoc const&, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::Align, bool, bool, llvm::CallInst const*, llvm::MachinePointerInfo, llvm::AAMDNodes const&) (build/bin/llc+0x3442f43)
#12 0x000055573fe2fff6 llvm::X86SelectionDAGInfo::EmitTargetCodeForMemset(llvm::SelectionDAG&, llvm::SDLoc const&, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::Align, bool, bool, llvm::MachinePointerInfo) const (build/bin/llc+0x20dfff6)
#13 0x000055574119301d llvm::SelectionDAG::getMemset(llvm::SDValue, llvm::SDLoc const&, llvm::SDValue, llvm::SDValue, llvm::SDValue, llvm::Align, bool, bool, llvm::CallInst const*, llvm::MachinePointerInfo, llvm::AAMDNodes const&) (build/bin/llc+0x344301d)
#14 0x000055574113bb51 llvm::SelectionDAGBuilder::visitIntrinsicCall(llvm::CallInst const&, unsigned int) (build/bin/llc+0x33ebb51)
#15 0x0000555741107770 llvm::SelectionDAGBuilder::visit(llvm::Instruction const&) (build/bin/llc+0x33b7770)
#16 0x00005557411c7715 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, true>, llvm::ilist_iterator_w_bits<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void, true, llvm::BasicBlock>, false, true>, bool&) (build/bin/llc+0x3477715)
#17 0x00005557411c69cd llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (build/bin/llc+0x34769cd)
#18 0x00005557411c3e41 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (build/bin/llc+0x3473e41)
#19 0x00005557411c1706 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (build/bin/llc+0x3471706)
#20 0x0000555740557da6 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (build/bin/llc+0x2807da6)
#21 0x0000555740a9ee69 llvm::FPPassManager::runOnFunction(llvm::Function&) (build/bin/llc+0x2d4ee69)
#22 0x0000555740aa7362 llvm::FPPassManager::runOnModule(llvm::Module&) (build/bin/llc+0x2d57362)
#23 0x0000555740a9f93c llvm::legacy::PassManagerImpl::run(llvm::Module&) (build/bin/llc+0x2d4f93c)
#24 0x000055573e8901c7 main (build/bin/llc+0xb401c7)
#25 0x00007f5003c43b8a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#26 0x00007f5003c43c45 call_init ./csu/../csu/libc-start.c:128:20
#27 0x00007f5003c43c45 __libc_start_main ./csu/../csu/libc-start.c:347:5
#28 0x000055573e889ec1 _start (build/bin/llc+0xb39ec1)
Aborted
```

I'll revert until this gets fixed.

https://github.com/llvm/llvm-project/pull/87003


More information about the llvm-commits mailing list