[llvm-bugs] [Bug 136457] Fix crash lowering stack guard on OpenBSD/aarch64
Issue 136457 Summary Fix crash lowering stack guard on OpenBSD/aarch64 Labels new issue Assignees Reporter brad0 /cherry-pick c180e249d0013474d502cd779ec65b33cf7e9468 ___ llvm-bugs mailing list llvm-bugs@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs
[llvm-bugs] [Bug 136464] Clang checks impossible cast
Issue 136464 Summary Clang checks impossible cast Labels clang Assignees Reporter vzze ### Issue Clang tries to check if cast of `const char*` is ill-formed even though the context of the cast is reduced to only `int` by `if constexpr` Code ```c++ // main.cc #include #include int main() { using type = std::variant; type a = 12; type b = 42; int res = std::visit([&](auto a1) -> int { return std::visit([&](auto b1) -> int { if constexpr( std::is_same_v, std::decay_t> && std::is_same_v, int> ) return int(a1) + int(b1); else throw "Wrong type!"; }, b); }, a); } ``` Unix Error ``` main.cc:16:24: error: cast from pointer to smaller type 'int' loses information 16 | return int(a1) + int(b1); |^~~ main.cc:11:47: note: while substituting into a lambda _expression_ here 11 | return std::visit([&](auto b1) -> int { | ^ /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/invoke.h:61:14: note: in instantiation of function template specialization 'main(): :(anonymous class)::operator()' requested here 61 | { return std::forward<_Fn>(__f)(std::forward<_Args>(__args)...); } | ^ /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/bits/invoke.h:96:19: note: in instantiation of function template specialization 'std::__ invoke_impl' requested here 96 | return std::__invoke_impl<__type>(__tag{}, std::forward<_Callable>(__fn), | ^ /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/variant:1060:16: note: in instantiation of function template specialization 'std::__invo ke<(lambda at main.cc:10:26), const char *&>' requested here 1060 | return std::__invoke(std::forward<_Visitor>(__visitor), | ^ /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/variant:1820:5: note: in instantiation of member function 'std::__detail::__variant::__g en_vtable_impl (*)((lambda at main.cc:10:26) &&, std::variant &)>, std::integer_sequence>::__visit_invoke' requested here 1820 | _GLIBCXX_VISIT_CASE(1) | ^ /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/variant:1811:4: note: expanded from macro '_GLIBCXX_VISIT_CASE' 1811 | __visit_invoke(std::forward<_Visitor>(__visitor), \ | ^ /usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/14.2.1/../../../../include/c++/14.2.1/variant:1882:18: note: in instantiation of function template specialization 'std::__do_v isit, (lambda at main.cc:10:26), std::variant &>' requested here 1882 | return std::__do_visit<_Tag>( | ^ main.cc:10:20: note: in instantiation of function template specialization 'std::visit<(lambda at main.cc:10:26), std::variant &>' requested here 10 | int res = std::visit([&](auto a1) -> int { |^ 1 error generated. ``` Win11 Error ``` .\main.cc:16:24: warning: cast to smaller integer type 'int' from 'const char *' [-Wpointer-to-int-cast] 16 | return int(a1) + int(b1); | ^~~ .\main.cc:11:47: note: while substituting into a lambda _expression_ here 11 | return std::visit([&](auto b1) -> int { | ^ C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\type_traits:1706:16: note: in instantiation of function template specialization 'main()::(anonymous class)::operator()' requested here 1706 | return static_cast<_Callable&&>(_Obj)(static_cast<_Ty1&&>(_Arg1), static_cast<_Types2&&>(_Args2)...); |^ C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\variant:1422:25: note: in instantiation of function template specialization 'std::invoke<(lambda at ./main.cc:10:26), const char *&>' requested here 1422 | return _STD invoke(static_cast<_Callable&&>(_Obj), | ^ C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\variant:1492:23: note: in instantiation of function template specialization 'std::_Variant_dispatcher>::_Dispatch2 &, false>' requested here 1492 | _STL_STAMP(4, _STL_VISIT_STAMP); | ^ C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.43.34808\include\variant:1546:49: note: in instantiation of function template specialization 'std::_Visit_strategy<1>::_Visit2, std::integer_sequence, std::integer_sequence>, (lambda at ./main.cc:10:26), std::variant &>' requested here 1546 | return _Visit_strategy<_Strategy>::template _Visit2<_Ret, _ListOfIndexVectors>( |
[llvm-bugs] [Bug 136472] Clang errors for out-of-line definition with deducing-this of non-templated type nested within templated type
Issue 136472 Summary Clang errors for out-of-line definition with deducing-this of non-templated type nested within templated type Labels clang Assignees Reporter scrossuk Given this code: ``` template struct Type final { struct Nested { void method(this auto& self); }; }; template void Type::Nested::method(this auto& self) {} ``` Clang reports ([Godbolt](https://godbolt.org/z/9MqhEGPsK)): ``` :11:30: error: an explicit object parameter cannot appear in a non-member function 11 | void Type::Nested::method(this auto& self) {} ``` Note that a work around is to make the nested type also be a template ([Godbolt](https://godbolt.org/z/WWjKe5WPv)): ``` template struct Type final { template struct Nested { void method(this auto& self); }; }; template template void Type::Nested::method(this auto& self) {} ``` ___ llvm-bugs mailing list llvm-bugs@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs
[llvm-bugs] [Bug 136432] Compiler crash, fails to compile
Issue 136432 Summary Compiler crash, fails to compile Labels new issue Assignees Reporter troldal Clang crashes when compiling my code. As instructed in the failure message, here is the backtrace, preprocessed source, and associated run script: [Flash-90296d.zip](https://github.com/user-attachments/files/19821407/Flash-90296d.zip) ___ llvm-bugs mailing list llvm-bugs@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs
[llvm-bugs] [Bug 136473] Missed optimization: switch with GEP inside cannot generate lookup table
Issue 136473 Summary Missed optimization: switch with GEP inside cannot generate lookup table Labels new issue Assignees Reporter oxalica [C godbolt](https://godbolt.org/z/exoPTKKPa) I'm expecting `selector1` to be optimized to `selector2`. But the optimizer cannot treat constant GEP as add in order to hoist the common `s + _` out of switch. [IIUC](https://llvm.org/docs/GetElementPtr.html#how-is-gep-different-from-ptrtoint-arithmetic-and-inttoptr), `getelementptr` carries more (aliasing) information and should be more efficient than direct pointer arithmetic, but it seems to be worse than simple pointer arithmetic in this case. Similar issue: #33633 is about homogeneous struct, while this issue is about heterogeneous struct. I'm not sure if this is considered the same, because in this case, we cannot simply cast the pointer into `[4 x i32]`, a lookup table is necessary. Origin: I run into this issue on Rust [godbolt](https://godbolt.org/z/6s8jbYhEP), where it's hard to do `offset_of` workaround even with `unsafe`, because of the need to attach type-related vtable to each pointer. ```c #include #include #include typedef struct { uint8_t a; uint8_t b; uint16_t c; uint32_t d; uint64_t e; float f; double g; } S; /* indirect jump, with LEA+RET in each branch */ void *selector1(S *s, int i) { switch (i) { case 0: return &s->a; case 1: return &s->b; case 2: return &s->c; case 3: return &s->d; case 4: return &s->e; case 5: return &s->f; case 6: return &s->g; default: return NULL; } } /* indirect load, ADD */ void *selector2(S *s, int i) { size_t off; switch (i) { case 0: off = offsetof(S, a); break; case 1: off = offsetof(S, b); break; case 2: off = offsetof(S, c); break; case 3: off = offsetof(S, d); break; case 4: off = offsetof(S, e); break; case 5: off = offsetof(S, f); break; case 6: off = offsetof(S, g); break; default: return NULL; } return (uint8_t *)s + off; } ``` ___ llvm-bugs mailing list llvm-bugs@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs
[llvm-bugs] [Bug 136425] Widened pointers not optimized back to scalar for vectorized interleaved accesses on RISC-V
Issue 136425 Summary Widened pointers not optimized back to scalar for vectorized interleaved accesses on RISC-V Labels backend:RISC-V, missed-optimization Assignees Reporter lukel97 https://compiler-explorer.com/z/bcnocK139 In the loop f, the loop vectorizer is able to use a scalar address throughout the segmented accesses. In g, where not every segmented field is written back to, it's kept around as a widened vector of pointers, even though we only use the first element of it. `legalizeAndOptimizeInductions` in VPlanTransforms.cpp may not be catching this case. ___ llvm-bugs mailing list llvm-bugs@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs
[llvm-bugs] [Bug 136430] [InstCombine] ninf should not be propagated
Issue 136430 Summary [InstCombine] ninf should not be propagated Labels miscompilation, llvm:instcombine, floating-point Assignees dtcxzyw Reporter dtcxzyw Reproducer: https://alive2.llvm.org/ce/z/cmneUX ``` define half @test_fcmp_select_maxnum(half %x) { #0: %cmp2 = fcmp ogt half %x, 0x5bf8 %sel2 = select nnan ninf nsz i1 %cmp2, half %x, half 0x5bf8 ret half %sel2 } => define half @test_fcmp_select_maxnum(half %x) { #0: %sel2 = fmax ninf nsz half %x, 0x5bf8 ret half %sel2 } Transformation doesn't verify! ERROR: Target is more poisonous than source Example: half %x = #xfc00 (-oo) Source: i1 %cmp2 = #x0 (0) half %sel2 = #x5bf8 (255) Target: half %sel2 = poison Source value: #x5bf8 (255) Target value: poison Summary: 0 correct transformations 1 incorrect transformations 0 failed-to-prove transformations 0 Alive2 errors ``` ___ llvm-bugs mailing list llvm-bugs@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs
[llvm-bugs] [Bug 136428] Clang uses wrong ABI for __atomic_store_16 on Windows
Issue 136428 Summary Clang uses wrong ABI for __atomic_store_16 on Windows Labels clang Assignees Reporter Alcaro ```c++ unsigned __int128 g; extern "C" void k(unsigned __int128* a, unsigned __int128 b, int c); extern "C" void r() { k(&g, 1234, 5); } extern "C" void p() { __atomic_store_n(&g, 1234, __ATOMIC_SEQ_CST); } ``` Expected: Pass the int128 by reference, and place __ATOMIC_SEQ_CST=5 in r8d, for both calls, like GCC. Actual: Clang calls __atomic_store_16 by passing the int128 by value in r8:rdx, and the 5 goes in r9d. https://godbolt.org/z/49Gzso4ax Originally reported at https://github.com/brechtsanders/winlibs_mingw/issues/256 ___ llvm-bugs mailing list llvm-bugs@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs
[llvm-bugs] [Bug 136418] [mlir] error: Dialect `ml_program' not found for custom op 'ml_program.global'
Issue 136418 Summary [mlir] error: Dialect `ml_program' not found for custom op 'ml_program.global' Labels mlir Assignees ryan-holt-1 Reporter vfdff The MR [[mlir][MLProgram] Add MLProgram to MemRef bufferization pass](https://github.com/llvm/llvm-project/pull/75103) has landed for a long time, but I still get the compile error, does I some miss something ? > mlir-translate -mlir-to-llvmir mlp.out.mlir > error: Dialect `ml_program' not found for custom op 'ml_program.global' * test: https://godbolt.org/z/d8MGqPGb9 > (py311-source) root@998ee80b761b:/home/zhongyunde/source/test/simple_mlp# cat mlp.out.mlir ``` module attributes {torch.debug_module_name = "MlpModel"} { ml_program.global private mutable @global_seed(dense<0> : tensor) : tensor } ``` ___ llvm-bugs mailing list llvm-bugs@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs
[llvm-bugs] [Bug 136435] clang_equalCursors not work as expect
Issue 136435 Summary clang_equalCursors not work as expect Labels new issue Assignees Reporter neko-para I'm using my own nodejs binding of libclang to parse my source to generate a simplified ast. ```typescript // dfs logic, using cursors as a stack function parseAnnotate(tu: CTranslationUnit) { const root = tu.cursor const cursors: CCursor[] = [root] tu.cursor.visitChildren((cursor, parent) => { while (cursors.length > 0 && !cursors[0].equal(parent)) { cursors.shift() } if (cursors.length === 0) { console.warn('jump out root', cursor, parent) } cursors.unshift(cursor) console.log(' '.repeat(cursors.length - 2), cursor.spelling, cursor.kindStr) return CXChildVisitResult.Recurse }) } ``` The code above works quite well, but when parsing the code below, the cursors that should be equal become different. ``` _Const_lvalue_cond_oper ClassTemplatePartialSpecialization _Ty1 TemplateTypeParameter _Ty2 TemplateTypeParameter RequiresExpr > Here should be a TemplateRef with parent of RequiresExpr, but my program crashed ```  https://github.com/microsoft/STL/blob/5762e6bcaf7f5f8b5dba0a9aabf0acbd0e335e80/stl/inc/type_traits#L1288 **After dumping the CXCursor data, it shows that the parent.data[0] is non-zero, while cursors[0].data[0] (previously stored one) is zero, causing clang_equalCursors return false.** I think there should be some problem either on my binding code or the way I use libclang, but I'm not sure. ___ llvm-bugs mailing list llvm-bugs@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs