Issue 240237
Summary pr58365.c failed on MSP430 with -O1
Labels new issue
Assignees
Reporter hongjia
    clang version 23.1.6 (https://github.com/llvm/llvm-project.git c47d7823685a0e7048795e0cd2d58ad35e454ee9)

Target: msp430

test source file: llvm-test-suite/SingleSource/Regression/C/gcc-c-torture/execute/pr58365.c

``` C
/* PR rtl-optimization/58365 */

extern void abort (void);

struct S
{
  volatile int a;
  int b, c, d, e;
} f;
static struct S g, h;
int i = 1;

char
foo (void)
{
  return i;
}

static struct S
bar (void)
{
  if (foo ())
    return f;
  return g;
}

int
main ()
{
 h = bar ();
  f.b = 1;
  if (h.b != 0)
    abort ();
  return 0;
}
```

error message:

```
hjcao@desktop:~/data/temp/clang$ ~/build/llvm/bin/clang -target msp430 -c -O1 t.c
clang: /home/hjcao/data/temp/llvm-project/llvm/lib/CodeGen/TargetLoweringBase.cpp:1978: virtual llvm::EVT llvm::TargetLoweringBase::getSetCCResultType(const llvm::DataLayout&, llvm::LLVMContext&, llvm::EVT) const: Assertion `!VT.isVector() && "No default SetCC type for vectors!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0.	Program arguments: /home/hjcao/build/llvm/bin/clang -target msp430 -c -O1 t.c
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module 't.c'.
4.	Running pass 'MSP430 DAG->DAG Pattern Instruction Selection' on function '@main'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  clang     0x00005603e4971846 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 57
1  clang 0x00005603e4971d0e
2  clang     0x00005603e496efe9 llvm::sys::RunSignalHandlers() + 143
3  clang     0x00005603e4970fe9 llvm::sys::CleanupOnSignal(unsigned long) + 142
4  clang 0x00005603e489876f
5  clang     0x00005603e4898c07
6  libc.so.6 0x00007fd4e85346b0
7  libc.so.6 0x00007fd4e858ad0c
8  libc.so.6 0x00007fd4e8534582 gsignal + 18
9  libc.so.6 0x00007fd4e851c507 abort + 36
10 libc.so.6 0x00007fd4e851d540
11 libc.so.6 0x00007fd4e852cc61 __assert_fail + 177
12 clang     0x00005603e3b400b0 llvm::TargetLoweringBase::getSetCCResultType(llvm::DataLayout const&, llvm::LLVMContext&, llvm::EVT) const + 92
13 clang 0x00005603e7ad4af8
14 clang     0x00005603e7b0b610
15 clang 0x00005603e7b01bab
16 clang     0x00005603e7a911a1
17 clang 0x00005603e7a950e1 llvm::SelectionDAG::LegalizeTypes() + 59
18 clang 0x00005603e78cc876 llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 1784
19 clang     0x00005603e78cbdcc 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&) + 458
20 clang     0x00005603e78d1c4a llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 7254
...
```

A vector type of <5xi16> is generated (by the SROA pass) in the IR and the back-end cannot handle this properly:

```
; Function Attrs: nofree nounwind
define dso_local noundef i16 @main() local_unnamed_addr #1 {
entry:
  %tmp.sroa.0 = alloca <5 x i16>, align 16
 call void @llvm.lifetime.start.p0(ptr nonnull %tmp.sroa.0)
  tail call void @llvm.experimental.noalias.scope.decl(metadata !8)
  %0 = load i16, ptr @i, align 2, !tbaa !7, !noalias !8
  %1 = and i16 %0, 255
  %tobool.not.i = icmp eq i16 %1, 0
  %tmp.sroa.0.0.copyload1 = load <5 x i16>, ptr @f, align 16
  %storemerge = select i1 %tobool.not.i, <5 x i16> zeroinitializer, <5 x i16> %tmp.sroa.0.0.copyload1
  store <5 x i16> %storemerge, ptr %tmp.sroa.0, align 16
  %tmp.sroa.0.0.tmp.sroa.0.0.copyload = load volatile <5 x i16>, ptr %tmp.sroa.0, align 16
  store volatile <5 x i16> %tmp.sroa.0.0.tmp.sroa.0.0.copyload, ptr @h, align 16
  call void @llvm.lifetime.end.p0(ptr nonnull %tmp.sroa.0)
  store i16 1, ptr getelementptr inbounds nuw (i8, ptr @f, i16 2), align 2, !tbaa !11
  %2 = load i16, ptr getelementptr inbounds nuw (i8, ptr @h, i16 2), align 2, !tbaa !11
  %cmp.not = icmp eq i16 %2, 0
  br i1 %cmp.not, label %if.end, label %if.then

if.then:                                          ; preds = %entry
  tail call void @abort() #5
  unreachable

if.end: ; preds = %entry
  ret i16 0
}
```

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to