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

Fix load64_aligned #71391

Merged
merged 1 commit into from
Nov 6, 2023
Merged

Fix load64_aligned #71391

merged 1 commit into from
Nov 6, 2023

Conversation

gchatelet
Copy link
Contributor

Fix #64758 load64_aligned was missing a case for alignment == 6.

@llvmbot
Copy link
Collaborator

llvmbot commented Nov 6, 2023

@llvm/pr-subscribers-libc

Author: Guillaume Chatelet (gchatelet)

Changes

Fix #64758 load64_aligned was missing a case for alignment == 6.


Full diff: https://github.com/llvm/llvm-project/pull/71391.diff

1 Files Affected:

  • (modified) libc/src/string/memory_utils/generic/aligned_access.h (+4-2)
diff --git a/libc/src/string/memory_utils/generic/aligned_access.h b/libc/src/string/memory_utils/generic/aligned_access.h
index 4238167e54d644d..65bc63f6cbe5571 100644
--- a/libc/src/string/memory_utils/generic/aligned_access.h
+++ b/libc/src/string/memory_utils/generic/aligned_access.h
@@ -28,7 +28,7 @@ namespace LIBC_NAMESPACE {
     return load32_aligned<uint32_t>(ptr, offset);
   else if (alignment == 2)
     return load32_aligned<uint16_t, uint16_t>(ptr, offset);
-  else
+  else // 1, 3
     return load32_aligned<uint8_t, uint16_t, uint8_t>(ptr, offset);
 }
 
@@ -38,9 +38,11 @@ namespace LIBC_NAMESPACE {
     return load64_aligned<uint64_t>(ptr, offset);
   else if (alignment == 4)
     return load64_aligned<uint32_t, uint32_t>(ptr, offset);
+  else if (alignment == 6)
+    return load64_aligned<uint16_t, uint32_t, uint16_t>(ptr, offset);
   else if (alignment == 2)
     return load64_aligned<uint16_t, uint16_t, uint16_t, uint16_t>(ptr, offset);
-  else
+  else // 1, 3, 5, 7
     return load64_aligned<uint8_t, uint16_t, uint16_t, uint16_t, uint8_t>(
         ptr, offset);
 }

@gchatelet
Copy link
Contributor Author

Thx for the quick review @lntue !

@gchatelet gchatelet merged commit bdac972 into llvm:main Nov 6, 2023
4 checks passed
@gchatelet gchatelet deleted the fix_64758 branch November 6, 2023 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[libc] UB in llvm-project/libc/src/string/memory_utils/utils.h:assume_aligned
3 participants