{"action":"created","issue":{"url":"https://api.github.com/repos/RadeonOpenCompute/hcc/issues/869","repository_url":"https://api.github.com/repos/RadeonOpenCompute/hcc","labels_url":"https://api.github.com/repos/RadeonOpenCompute/hcc/issues/869/labels{/name}","comments_url":"https://api.github.com/repos/RadeonOpenCompute/hcc/issues/869/comments","events_url":"https://api.github.com/repos/RadeonOpenCompute/hcc/issues/869/events","html_url":"https://github.com/RadeonOpenCompute/hcc/issues/869","id":360675911,"node_id":"MDU6SXNzdWUzNjA2NzU5MTE=","number":869,"title":"Compiler crash when using std::exp in kernel and compiling with -Ofast flag","user":{"login":"misos1","id":30872003,"node_id":"MDQ6VXNlcjMwODcyMDAz","avatar_url":"https://avatars0.githubusercontent.com/u/30872003?v=4","gravatar_id":"","url":"https://api.github.com/users/misos1","html_url":"https://github.com/misos1","followers_url":"https://api.github.com/users/misos1/followers","following_url":"https://api.github.com/users/misos1/following{/other_user}","gists_url":"https://api.github.com/users/misos1/gists{/gist_id}","starred_url":"https://api.github.com/users/misos1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/misos1/subscriptions","organizations_url":"https://api.github.com/users/misos1/orgs","repos_url":"https://api.github.com/users/misos1/repos","events_url":"https://api.github.com/users/misos1/events{/privacy}","received_events_url":"https://api.github.com/users/misos1/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-09-16T20:36:11Z","updated_at":"2018-10-19T22:17:37Z","closed_at":null,"author_association":"NONE","body":"Yes I know that I should use exp from fast_math or precise_math but compiler should not crash but either print some errors or successfully compile if std::exp is intended to work in kernel. Also exp without namespace prefix is working.\r\n\r\nSome functions cannot be used in both kernel and host code for example on host I can use __builtin_popcount but in kernel I must use hc::__popcount_u32_b32 which I cannot use on host.\r\n``` c++\r\nhc::array_view<int> result(1);\r\nparallel_for_each(hc::extent<1>(1), [=](hc::index<1> i) [[hc]]\r\n{\r\n\tresult[0] = std::exp(result[0]);\r\n});\r\n```\r\n```\r\nhcc main.cpp `hcc-config --cxxflags` -Ofast\r\n```\r\n```\r\n#0 0x00000000014db59a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/opt/rocm/hcc/bin/llc+0x14db59a)\r\n#1 0x00000000014d967e llvm::sys::RunSignalHandlers() (/opt/rocm/hcc/bin/llc+0x14d967e)\r\n#2 0x00000000014d97cc SignalHandler(int) (/opt/rocm/hcc/bin/llc+0x14d97cc)\r\n#3 0x00007f62d4f05150 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x13150)\r\n#4 0x0000000000717991 llvm::SITargetLowering::LowerCall(llvm::TargetLowering::CallLoweringInfo&, llvm::SmallVectorImpl<llvm::SDValue>&) const (/opt/rocm/hcc/bin/llc+0x717991)\r\n#5 0x000000000134672e llvm::TargetLowering::LowerCallTo(llvm::TargetLowering::CallLoweringInfo&) const (/opt/rocm/hcc/bin/llc+0x134672e)\r\n#6 0x00000000012fe0c4 (anonymous namespace)::SelectionDAGLegalize::ExpandLibCall(llvm::RTLIB::Libcall, llvm::SDNode*, bool) (/opt/rocm/hcc/bin/llc+0x12fe0c4)\r\n#7 0x00000000012fe382 (anonymous namespace)::SelectionDAGLegalize::ExpandFPLibCall(llvm::SDNode*, llvm::RTLIB::Libcall, llvm::RTLIB::Libcall, llvm::RTLIB::Libcall, llvm::RTLIB::Libcall, llvm::RTLIB::Libcall) (/opt/rocm/hcc/bin/llc+0x12fe382)\r\n#8 0x000000000130673b (anonymous namespace)::SelectionDAGLegalize::ConvertNodeToLibcall(llvm::SDNode*) (/opt/rocm/hcc/bin/llc+0x130673b)\r\n#9 0x00000000013082e7 (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) (/opt/rocm/hcc/bin/llc+0x13082e7)\r\n#10 0x000000000130bdc8 llvm::SelectionDAG::Legalize() (/opt/rocm/hcc/bin/llc+0x130bdc8)\r\n#11 0x00000000013bb327 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/rocm/hcc/bin/llc+0x13bb327)\r\n#12 0x00000000013c0dfc llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/rocm/hcc/bin/llc+0x13c0dfc)\r\n#13 0x00000000013c2f82 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/rocm/hcc/bin/llc+0x13c2f82)\r\n#14 0x0000000000cce181 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/opt/rocm/hcc/bin/llc+0xcce181)\r\n#15 0x0000000000fafaca llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/rocm/hcc/bin/llc+0xfafaca)\r\n#16 0x0000000000a64e9e (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) (/opt/rocm/hcc/bin/llc+0xa64e9e)\r\n#17 0x0000000000faf684 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/rocm/hcc/bin/llc+0xfaf684)\r\n#18 0x000000000065d7b3 compileModule(char**, llvm::LLVMContext&) [clone .constprop.398] (/opt/rocm/hcc/bin/llc+0x65d7b3)\r\n#19 0x0000000000603325 main (/opt/rocm/hcc/bin/llc+0x603325)\r\n#20 0x00007f62d3bf61c1 __libc_start_main /build/glibc-itYbWN/glibc-2.26/csu/../csu/libc-start.c:342:0\r\n#21 0x0000000000652779 _start (/opt/rocm/hcc/bin/llc+0x652779)\r\n```\r\nAlso I am getting this in each compilation with hcc (whether successful or not):\r\n```\r\nobjdump: /usr/lib/x86_64-linux-gnu/libm.a: File format not recognized\r\n```\r\nIn this file is:\r\n```\r\n/* GNU ld script\r\n*/\r\nOUTPUT_FORMAT(elf64-x86-64)\r\nGROUP ( /usr/lib/x86_64-linux-gnu/libm-2.26.a /usr/lib/x86_64-linux-gnu/libmvec.a )\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/RadeonOpenCompute/hcc/issues/comments/431515440","html_url":"https://github.com/RadeonOpenCompute/hcc/issues/869#issuecomment-431515440","issue_url":"https://api.github.com/repos/RadeonOpenCompute/hcc/issues/869","id":431515440,"node_id":"MDEyOklzc3VlQ29tbWVudDQzMTUxNTQ0MA==","user":{"login":"david-salinas","id":17931364,"node_id":"MDQ6VXNlcjE3OTMxMzY0","avatar_url":"https://avatars1.githubusercontent.com/u/17931364?v=4","gravatar_id":"","url":"https://api.github.com/users/david-salinas","html_url":"https://github.com/david-salinas","followers_url":"https://api.github.com/users/david-salinas/followers","following_url":"https://api.github.com/users/david-salinas/following{/other_user}","gists_url":"https://api.github.com/users/david-salinas/gists{/gist_id}","starred_url":"https://api.github.com/users/david-salinas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/david-salinas/subscriptions","organizations_url":"https://api.github.com/users/david-salinas/orgs","repos_url":"https://api.github.com/users/david-salinas/repos","events_url":"https://api.github.com/users/david-salinas/events{/privacy}","received_events_url":"https://api.github.com/users/david-salinas/received_events","type":"User","site_admin":false},"created_at":"2018-10-19T22:17:37Z","updated_at":"2018-10-19T22:17:37Z","author_association":"COLLABORATOR","body":"@misos1 std:: functions are not guaranteed to work in a parallel_for_each unless they are constexpr.  In this case exp() is not constexpr.  "}}
{"actor":{"display_login":"david-salinas"}}