Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid C generation #217

Open
xTachyon opened this issue Oct 22, 2024 · 3 comments
Open

Invalid C generation #217

xTachyon opened this issue Oct 22, 2024 · 3 comments

Comments

@xTachyon
Copy link

I was playing with llvm-cbe, and with this input file transformed with llvm-cbe, I get the following first error:

/home/tachyon/.cargo/registry/src/index.crates.io-6f17d22bba15001f/adler-1.0.2/src/algo.rs: In function_ZN5adler4algo32__EC_LT_EC_impl_EC_u20_EC_adler_OC__OC_Adler32_EC_GT_EC_7compute17h715de753f96090aaE’:
/home/tachyon/.cargo/registry/src/index.crates.io-6f17d22bba15001f/adler-1.0.2/src/algo.rs:89:51: error: ‘struct l_struct_algo_KD__KD_U32X4has no member namedarray89 |         b_vec.0[1] += MOD - a_vec.0[1];
      |

And without #lines:

main.cbe.c: In function_ZN5adler4algo32__EC_LT_EC_impl_EC_u20_EC_adler_OC__OC_Adler32_EC_GT_EC_7compute17h715de753f96090aaE’:
main.cbe.c:1085:51: error: ‘struct l_struct_algo_KD__KD_U32X4has no member namedarray1085 |   llvm_cbe__79 = *(uint32_t*)(((&(&llvm_cbe_a_vec)->array[((int64_t)1)])));
      | 

The line in cause:

llvm_cbe__79 = *(uint32_t*)(((&(&llvm_cbe_a_vec)->array[((int64_t)1)])));

And the struct:

struct l_struct_algo_KD__KD_U32X4 {
  struct l_array_4_uint32_t field0;
};

I tried miniming the input as much as I could, but I don't know how I'd do it more.

@zlfn
Copy link
Contributor

zlfn commented Oct 22, 2024

I think llvm-cbe does not support vector type ([4 x i32]) of LLVM-IR so well.

If you are using Rust, disable vectorization is a not perfect solution, but it likely help.

@xTachyon
Copy link
Author

I'm not sure this is a vector type. I think these are the instructions:

%"algo::U32X4" = type { [4 x i32] }
...
%a_vec = alloca %"algo::U32X4", align 4
...
%41 = getelementptr inbounds [4 x i32], ptr %a_vec, i64 0, i64 1, !dbg !554
%_79 = load i32, ptr %41, align 4, !dbg !554, !noundef !34

Accoding to the manual, these are arrays. Vector types have <>, not [].

That being said, the function seems to contain vector types. Maybe that's what it confuses it?

And yes, this is Rust, but neither no-vectorize-loops nor no-vectorize-slp seem to change anything, probably because this is unoptimized code, and those opts never ran.

@vtjnash
Copy link
Member

vtjnash commented Oct 22, 2024

There are some issues people have observed with GEP emission (getting the type wrong and/or forgetting casts) which seems like what you are seeing. PRs welcome

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants