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

clang loop optimizer pragma warns on rasterio.cpp. #11645

Closed
schwehr opened this issue Jan 13, 2025 · 2 comments · Fixed by #11646
Closed

clang loop optimizer pragma warns on rasterio.cpp. #11645

schwehr opened this issue Jan 13, 2025 · 2 comments · Fixed by #11646
Assignees

Comments

@schwehr
Copy link
Member

schwehr commented Jan 13, 2025

What is the bug?

rasterio.cpp triggers a complaint with UBSAN mode with recent clang (like in the last couple weeks), but as this is a custom environment, I don't know if this happens with older clangs. I've seen pass-failed happen a few years ago with non-gdal code.

#if defined(__clang__)
#pragma clang loop vectorize(disable)
#endif
gcore/rasterio.cpp:5954:5: error: loop not vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering [-Werror,-Wpass-failed=transform-warning]
 5954 |     for (size_t i = 0; i < nIters; ++i)
      |     ^
gcore/rasterio.cpp:6049:5: error: loop not vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering [-Werror,-Wpass-failed=transform-warning]
 6049 |     for (size_t i = 0; i < nIters; ++i)
      |     ^
2 errors generated.

Not sure why the loop doesn't unroll.

Steps to reproduce the issue

I don't have great details on how to reproduce. Sorry.

Versions and provenance

Hit this GDAL from head on 2025-01-10.

Additional context

Not sure the best way to disable this in the GDAL code base and is that reasonable to do? Locally, I set -Wno-pass-failed for now and then the UBSAN run goes just fine.

I looked at CPL_NOSANITIZE_UNSIGNED_INT_OVERFLOW and maybe this is correct __attribute__((no_sanitize_undefined))?

I will investigate more.

@schwehr schwehr self-assigned this Jan 13, 2025
@rouault rouault self-assigned this Jan 13, 2025
@rouault
Copy link
Member

rouault commented Jan 13, 2025

Reproduced locally with quite ancient clang.
Easiest fix is to suppress the warning

@rouault
Copy link
Member

rouault commented Jan 13, 2025

Fix in #11646

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

Successfully merging a pull request may close this issue.

2 participants