[clang] [WIP] [clang] Align cleanup structs to prevent SIGBUS on sparc32 (PR #152866)

Rainer Orth via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 11 00:03:26 PDT 2025


rorth wrote:

I've run a `sparc-sun-solaris2.11` 2-stage `Debug` build with this patch.  The build itself went well (with the exception of an unrelated failure to link `libomp.so`), but test results are still terrible with 455 failures.  But it's still massive improvement compared to before.

However, when trying an `i386-pc-solaris2.11` `Debug` build, I ran into a build failure due to this patch:
```
FAILED: tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGBuiltin.cpp.o
[...]
In file included from /vol/llvm/src/llvm-project/local/clang/lib/CodeGen/CGBuiltin.cpp:13:
In file included from /vol/llvm/src/llvm-project/local/clang/lib/CodeGen/CGBuiltin.h:12:
/vol/llvm/src/llvm-project/local/clang/lib/CodeGen/CodeGenFunction.h:951:24: error: static assertion failed due to requirement 'alignof((anonymous namespace)::CallObjCArcUse) == alignof(clang::CodeGen::RawAddress)': Cleanup will be allocated on misaligned address
  951 |                       (alignof(T) == alignof(RawAddress)),
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/vol/llvm/src/llvm-project/local/clang/lib/CodeGen/CodeGenFunction.h:924:14: note: in instantiation of function template specialization 'clang::CodeGen::CodeGenFunction::pushCleanupAfterFullExprWithActiveFlag<(anonymous namespace)::CallObjCArcUse, llvm::Value *>' requested here
  924 |       return pushCleanupAfterFullExprWithActiveFlag<T>(
      |              ^
/vol/llvm/src/llvm-project/local/clang/lib/CodeGen/CGBuiltin.cpp:2269:13: note: in instantiation of function template specialization 'clang::CodeGen::CodeGenFunction::pushCleanupAfterFullExpr<(anonymous namespace)::CallObjCArcUse, llvm::Value *>' requested here
 2269 |             pushCleanupAfterFullExpr<CallObjCArcUse>(Cleanup, ArgVal);
      |             ^
/vol/llvm/src/llvm-project/local/clang/lib/CodeGen/CodeGenFunction.h:951:35: note: expression evaluates to '8 == 4'
  951 |                       (alignof(T) == alignof(RawAddress)),
      |                        ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/vol/llvm/src/llvm-project/local/clang/lib/CodeGen/CodeGenFunction.h:951:24: error: static assertion failed due to requirement 'alignof(clang::CodeGen::EHScopeStack::ConditionalCleanup<(anonymous namespace)::CallObjCArcUse, llvm::Value *>) == alignof(clang::CodeGen::RawAddress)': Cleanup will be allocated on misaligned address
  951 |                       (alignof(T) == alignof(RawAddress)),
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/vol/llvm/src/llvm-project/local/clang/lib/CodeGen/CodeGenFunction.h:935:5: note: in instantiation of function template specialization 'clang::CodeGen::CodeGenFunction::pushCleanupAfterFullExprWithActiveFlag<clang::CodeGen::EHScopeStack::ConditionalCleanup<(anonymous namespace)::CallObjCArcUse, llvm::Value *>, std::tuple<llvm::PointerIntPair<llvm::Value *, 1, bool>>>' requested here
  935 |     pushCleanupAfterFullExprWithActiveFlag<CleanupType>(Kind, ActiveFlag,
      |     ^
/vol/llvm/src/llvm-project/local/clang/lib/CodeGen/CGBuiltin.cpp:2269:13: note: in instantiation of function template specialization 'clang::CodeGen::CodeGenFunction::pushCleanupAfterFullExpr<(anonymous namespace)::CallObjCArcUse, llvm::Value *>' requested here
 2269 |             pushCleanupAfterFullExpr<CallObjCArcUse>(Cleanup, ArgVal);
      |             ^
/vol/llvm/src/llvm-project/local/clang/lib/CodeGen/CodeGenFunction.h:951:35: note: expression evaluates to '8 == 4' 
  951 |                       (alignof(T) == alignof(RawAddress)), 
      |                        ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
```

Besides, I think it would be clearer to use `alignas(uint64_t)` instead of a magic constant.

https://github.com/llvm/llvm-project/pull/152866


More information about the cfe-commits mailing list