Cpp front-end Polygeist complex type operation conversion fail

I apply Polygeist(GitHub - llvm/Polygeist: C/C++ frontend for MLIR. Also features polyhedral optimizations, parallel optimizations, and more!) as mlir front-end, I run a couple of input case, however the program quit with diagnostic error.Here is the input snippet code.and console output information:

#include <complex.h>
#include <math.h>


int main(void)
{
    double a = 1;
    double b = 1;
    std::complex<double> cm(a, b);
    std::complex<double> cm2(a, b);
    std::complex<double> cm3 = cm + cm2;

}

console dumped error information:

cgeist: /home/shichen/Polygeist/tools/cgeist/Lib/ValueCategory.cc:44: mlir::Value ValueCategory::getValue(mlir::Location, mlir::OpBuilder&) const: Assertion `mt.getShape().size() == 1 && "must have shape 1"' 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/cgeist test.cpp --function=main -S
1.      <eof> parser at end of file
 #0 0x000055c9afb6128a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (../build/bin/cgeist+0x268728a)
 #1 0x000055c9afb616a6 PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #2 0x000055c9afb5eaf3 llvm::sys::RunSignalHandlers() (../build/bin/cgeist+0x2684af3)
 #3 0x000055c9afb60b22 SignalHandler(int) Signals.cpp:0:0
 #4 0x00007f4c7b1dc520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #5 0x00007f4c7b2309fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #6 0x00007f4c7b1dc476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #7 0x00007f4c7b1c27f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #8 0x00007f4c7b1c271b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #9 0x00007f4c7b1d3e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#10 0x000055c9adee1654 ValueCategory::getValue(mlir::Location, mlir::OpBuilder&) const /home/shichen/Polygeist/tools/cgeist/Lib/ValueCategory.cc:45:52
#11 0x000055c9add6d9b2 MLIRScanner::VisitBinaryOperator(clang::BinaryOperator*) /home/shichen/Polygeist/tools/cgeist/Lib/clang-mlir.cc:3056:0
#12 0x000055c9addfe47d clang::StmtVisitorBase<std::add_pointer, MLIRScanner, ValueCategory>::VisitCompoundAssignOperator(clang::CompoundAssignOperator*) /home/shichen/Polygeist/llvm-project/build/tools/clang/include/clang/AST/StmtNodes.inc:794:0
#13 0x000055c9addfd0e9 clang::StmtVisitorBase<std::add_pointer, MLIRScanner, ValueCategory>::VisitBinAddAssign(clang::CompoundAssignOperator*) /home/shichen/Polygeist/llvm-project/clang/include/clang/AST/StmtVisitor.h:149:0
#14 0x000055c9addc41ca clang::StmtVisitorBase<std::add_pointer, MLIRScanner, ValueCategory>::Visit(clang::Stmt*) /home/shichen/Polygeist/llvm-project/clang/include/clang/AST/StmtVisitor.h:76:0
#15 0x000055c9ade9fae8 MLIRScanner::VisitCompoundStmt(clang::CompoundStmt*) /home/shichen/Polygeist/tools/cgeist/Lib/CGStmt.cc:1043:3
#16 0x000055c9addc4529 clang::StmtVisitorBase<std::add_pointer, MLIRScanner, ValueCategory>::Visit(clang::Stmt*) /home/shichen/Polygeist/llvm-project/build/tools/clang/include/clang/AST/StmtNodes.inc:74:0
#17 0x000055c9add5a348 MLIRScanner::init(mlir::func::FuncOp, clang::FunctionDecl const*) /home/shichen/Polygeist/tools/cgeist/Lib/clang-mlir.cc:457:0
#18 0x000055c9add7daa4 MLIRASTConsumer::run() /home/shichen/Polygeist/tools/cgeist/Lib/clang-mlir.cc:5232:0
#19 0x000055c9add7ea14 MLIRASTConsumer::HandleTranslationUnit(clang::ASTContext&) /home/shichen/Polygeist/tools/cgeist/Lib/clang-mlir.cc:5386:0
#20 0x000055c9b8d535c5 clang::ParseAST(clang::Sema&, bool, bool) (../build/bin/cgeist+0xb8795c5)
#21 0x000055c9b2795b26 clang::ASTFrontendAction::ExecuteAction() (../build/bin/cgeist+0x52bbb26)
#22 0x000055c9b27953d0 clang::FrontendAction::Execute() (../build/bin/cgeist+0x52bb3d0)
#23 0x000055c9add83ad6 parseMLIR(char const*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>, mlir::OwningOpRef<mlir::ModuleOp>&, llvm::Triple&, llvm::DataLayout&, llvm::Triple&, llvm::DataLayout&) /home/shichen/Polygeist/tools/cgeist/Lib/clang-mlir.cc:6120:0
#24 0x000055c9add8525c main /home/shichen/Polygeist/tools/cgeist/driver.cc:574:0
#25 0x00007f4c7b1c3d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#26 0x00007f4c7b1c3e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#27 0x000055c9add56725 _start (../build/bin/cgeist+0x87c725)

And I check the Polygesit repo, it’s quite clear complex arithmetic is supported for C/C++ frontend, I heavily suspect format of complex addition operation in input main function is primary reason for deteriorating futher parse pass

I suspect complex arithmetic is supported for C _Complex type, not C++ std::complex type. I see you submitted an issue Complex Arithemetic · Issue #367 · llvm/Polygeist · GitHub. Let’s please keep discussion in one place, preferably that issue.

:ok_hand:! Thank you so much for your help :smiling_face_with_three_hearts: Let’s keep futher discussion on Github platform :grin:

The update issue in following link Complex Arithemetic · Issue #367 · llvm/Polygeist · GitHub