<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [Matrix] matrix builtin asserts in 32 bit mode."
   href="https://bugs.llvm.org/show_bug.cgi?id=51304">51304</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[Matrix] matrix builtin asserts in 32 bit mode.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>erich.keane@intel.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Matrix builtins __builtin_matrix_column_major_load and
__builtin_matrix_column_major_store are defined to use size_t as their
parameters.

However, at least in the case of __builtin_matrix_column_major_load, the llvm
intrinsic takes an i64 as its second parameter (and it appears the 3rd
parameter to __builtin_matrix_column_major_store).

HOWEVER, on 32 bit systems (or via -m32), the size of size_t is 32 bits! 
Therefore, when we emit the call to the intrinsic, we pass it as a 32 bit
value, which causes a Calling a function with a bad signature assertion.

See reproducer/crash dump below. 

I ALSO note that the intrinsics take the rest of their size_t parameters as
'llvm_i32_ty', despite being size_t.  So there is likely some level of
consistency that needs to happen here.



bash-4.2$ cat temp.cpp
int main() {
  int a;
  __builtin_matrix_column_major_load(&a, 5, 6, 7);
}
bash-4.2$ ./bin/clang -cc1 temp.cpp temp.cpp -fenable-matrix -triple
i386-unknown-linux-gnu -emit-llvm -o -
clang:
/iusers/ekeane1/workspaces/llvm-project/llvm/lib/IR/Instructions.cpp:498: void
llvm::CallInst::init(llvm::FunctionType*, llvm::Value*,
llvm::ArrayRef<llvm::Value*>,
llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, const llvm::Twine&):
Assertion `(i >= FTy->getNumParams() || FTy->getParamType(i) ==
Args[i]->getType()) && "Calling a function with a bad signature!"' failed.
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: ./bin/clang -cc1 temp.cpp temp.cpp -fenable-matrix
-triple i386-unknown-linux-gnu -emit-llvm -o -
1.      <eof> parser at end of file
2.      temp.cpp:1:5: LLVM IR generation of declaration 'main'
3.      temp.cpp:1:5: Generating code for declaration 'main'
 #0 0x000000000566cc9b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/iusers/ekeane1/workspaces/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:22
 #1 0x000000000566cd52 PrintStackTraceSignalHandler(void*)
/iusers/ekeane1/workspaces/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:1
 #2 0x000000000566ad0f llvm::sys::RunSignalHandlers()
/iusers/ekeane1/workspaces/llvm-project/llvm/lib/Support/Signals.cpp:97:20
 #3 0x000000000566c6e3 SignalHandler(int)
/iusers/ekeane1/workspaces/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #4 0x00007f3f4ef125e0 __restore_rt sigaction.c:0:0
 #5 0x00007f3f4da8b1f7 raise (/lib64/libc.so.6+0x351f7)
 #6 0x00007f3f4da8c8e8 abort (/lib64/libc.so.6+0x368e8)
 #7 0x00007f3f4da84266 __assert_fail_base (/lib64/libc.so.6+0x2e266)
 #8 0x00007f3f4da84312 (/lib64/libc.so.6+0x2e312)
 #9 0x0000000004b39317 llvm::CallInst::init(llvm::FunctionType*, llvm::Value*,
llvm::ArrayRef<llvm::Value*>,
llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, llvm::Twine const&)
/iusers/ekeane1/workspaces/llvm-project/llvm/lib/IR/Instructions.cpp:496:5
#10 0x000000000285d1c4 llvm::CallInst::CallInst(llvm::FunctionType*,
llvm::Value*, llvm::ArrayRef<llvm::Value*>,
llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, llvm::Twine const&,
llvm::Instruction*)
/iusers/ekeane1/workspaces/llvm-project/llvm/include/llvm/IR/Instructions.h:1731:7
#11 0x000000000285d015 llvm::CallInst::Create(llvm::FunctionType*,
llvm::Value*, llvm::ArrayRef<llvm::Value*>,
llvm::ArrayRef<llvm::OperandBundleDefT<llvm::Value*> >, llvm::Twine const&,
llvm::Instruction*)
/iusers/ekeane1/workspaces/llvm-project/llvm/include/llvm/IR/Instructions.h:1539:64
#12 0x0000000002863a74 llvm::IRBuilderBase::CreateCall(llvm::FunctionType*,
llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&, llvm::MDNode*)
/iusers/ekeane1/workspaces/llvm-project/llvm/include/llvm/IR/IRBuilder.h:2394:36
#13 0x0000000005ee3c88
llvm::MatrixBuilder<clang::CodeGen::CGBuilderTy>::CreateColumnMajorLoad(llvm::Value*,
llvm::Align, llvm::Value*, bool, unsigned int, unsigned int, llvm::Twine
const&)
/iusers/ekeane1/workspaces/llvm-project/llvm/include/llvm/IR/MatrixBuilder.h:82:15
#14 0x0000000005dcf04a
clang::CodeGen::CodeGenFunction::EmitBuiltinExpr(clang::GlobalDecl, unsigned
int, clang::CallExpr const*, clang::CodeGen::ReturnValueSlot)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/CodeGen/CGBuiltin.cpp:3125:45
#15 0x0000000005f93d90
clang::CodeGen::CodeGenFunction::EmitCallExpr(clang::CallExpr const*,
clang::CodeGen::ReturnValueSlot)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/CodeGen/CGExpr.cpp:4861:42
#16 0x0000000005fc8f54 (anonymous
namespace)::ScalarExprEmitter::VisitCallExpr(clang::CallExpr const*)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:576:34
#17 0x0000000005fe18b4 clang::StmtVisitorBase<std::add_pointer, (anonymous
namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*)
/iusers/ekeane1/workspaces/llvm-project/build/tools/clang/include/clang/AST/StmtNodes.inc:857:1
#18 0x0000000005fc82ee (anonymous
namespace)::ScalarExprEmitter::Visit(clang::Expr*)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:412:57
#19 0x0000000005fdee82
clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/CodeGen/CGExprScalar.cpp:4811:35
#20 0x0000000005f792e2 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr
const*, clang::CodeGen::AggValueSlot, bool)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/CodeGen/CGExpr.cpp:219:55
#21 0x0000000005f7926b
clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/CodeGen/CGExpr.cpp:204:63
#22 0x0000000005afd65d clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt
const*, llvm::ArrayRef<clang::Attr const*>)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/CodeGen/CGStmt.cpp:122:56
#23 0x0000000005afe809
clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/CodeGen/CGStmt.cpp:461:3
#24 0x0000000005ba6fce
clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1193:36
#25 0x0000000005ba7bfc
clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1367:21
#26 0x0000000005bd1ce5
clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:4861:3
#27 0x0000000005bcb163
clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3230:47
#28 0x0000000005bca1f8
clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2983:5
#29 0x0000000005bd5bde
clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:5701:37
#30 0x0000000006cbcfb4 (anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp:169:7
#31 0x0000000006cb66d8
clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:217:11
#32 0x000000000863277a clang::ParseAST(clang::Sema&, bool, bool)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Parse/ParseAST.cpp:162:20
#33 0x000000000634d239 clang::ASTFrontendAction::ExecuteAction()
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1058:11
#34 0x0000000006cb3fe7 clang::CodeGenAction::ExecuteAction()
/iusers/ekeane1/workspaces/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1045:5
#35 0x000000000634cb65 clang::FrontendAction::Execute()
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Frontend/FrontendAction.cpp:955:38
#36 0x0000000006296617
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:974:42
#37 0x00000000064cd838
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/iusers/ekeane1/workspaces/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:38
#38 0x0000000002681316 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*)
/iusers/ekeane1/workspaces/llvm-project/clang/tools/driver/cc1_main.cpp:246:40
#39 0x0000000002676655 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
/iusers/ekeane1/workspaces/llvm-project/clang/tools/driver/driver.cpp:338:20
#40 0x0000000002676c73 main
/iusers/ekeane1/workspaces/llvm-project/clang/tools/driver/driver.cpp:409:26
#41 0x00007f3f4da77c05 __libc_start_main (/lib64/libc.so.6+0x21c05)
#42 0x0000000002674ec9 _start (./bin/clang+0x2674ec9)
Aborted (core dumped)</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>