[clang] f1650cf - Revert "[clang] Convert second arg of __builtin_assume_aligned to ConstantExpr (#161314)" (#161719)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 2 12:11:12 PDT 2025
Author: Devon Loehr
Date: 2025-10-02T15:11:07-04:00
New Revision: f1650cf91b01470ce44f47797663d59f00828493
URL: https://github.com/llvm/llvm-project/commit/f1650cf91b01470ce44f47797663d59f00828493
DIFF: https://github.com/llvm/llvm-project/commit/f1650cf91b01470ce44f47797663d59f00828493.diff
LOG: Revert "[clang] Convert second arg of __builtin_assume_aligned to ConstantExpr (#161314)" (#161719)
This reverts commit 8f77621574176387f906b8ceef9e1abb90bf22f6 (#161314).
Reason: Causing crashes when building https://github.com/google/highway.
See the original PR for details.
Added:
Modified:
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaChecking.cpp
clang/test/SemaCXX/builtin-assume-aligned.cpp
Removed:
################################################################################
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 74b0647f38795..145a83af514ed 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -246,8 +246,6 @@ Non-comprehensive list of changes in this release
- ``__builtin_assume_dereferenceable`` now accepts non-constant size operands.
-- Fixed a crash when the second argument to ``__builtin_assume_aligned`` was not constant (#GH161314)
-
New Compiler Flags
------------------
- New option ``-fno-sanitize-debug-trap-reasons`` added to disable emitting trap reasons into the debug info when compiling with trapping UBSan (e.g. ``-fsanitize-trap=undefined``).
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 3cc61b167ba98..7ce3513fe0969 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -5954,9 +5954,6 @@ bool Sema::BuiltinAssumeAligned(CallExpr *TheCall) {
if (Result > Sema::MaximumAlignment)
Diag(TheCall->getBeginLoc(), diag::warn_assume_aligned_too_great)
<< SecondArg->getSourceRange() << Sema::MaximumAlignment;
-
- TheCall->setArg(1,
- ConstantExpr::Create(Context, SecondArg, APValue(Result)));
}
if (NumArgs > 2) {
diff --git a/clang/test/SemaCXX/builtin-assume-aligned.cpp b/clang/test/SemaCXX/builtin-assume-aligned.cpp
index afc11cc694705..48bd8414fc50a 100644
--- a/clang/test/SemaCXX/builtin-assume-aligned.cpp
+++ b/clang/test/SemaCXX/builtin-assume-aligned.cpp
@@ -47,9 +47,3 @@ constexpr void *s1 = __builtin_assume_aligned(x, 32);
constexpr void *s2 = __builtin_assume_aligned(x, 32, 5);
constexpr void *s3 = __builtin_assume_aligned(x, 32, -1);
-
-constexpr int add(int a, int b) {
- return a+b;
-}
-constexpr void *c1 = __builtin_assume_aligned(p, add(1,1));
-constexpr void *c2 = __builtin_assume_aligned(p, add(2,1)); // expected-error {{not a power of 2}}
More information about the cfe-commits
mailing list