[clang] [OpenACC] Sema changes for +*&|^ reduction combiner recipes (PR #162740)

Thurston Dang via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 10 16:06:48 PDT 2025


thurstond wrote:

When I ran the buildbot script, I did reproduce the scary `libc++abi: Pure virtual function called!` message:
```
******************** TEST 'Clang :: SemaOpenACC/loop-construct-reduction-clause.cpp' FAILED ********************
Exit Code: 134

Command Output (stderr):
--
/home/thurston/buildbot_repro/llvm_build_hwasan/bin/clang -cc1 -internal-isystem /home/thurston/buildbot_repro/llvm_build_hwasan/lib/clang/22/include -nostdsysteminc /home/thurston/llvm-project/clang/test/SemaOpenACC/loop-construct-reduction-clause.cpp -fopenacc -verify # RUN: at line 1
+ /home/thurston/buildbot_repro/llvm_build_hwasan/bin/clang -cc1 -internal-isystem /home/thurston/buildbot_repro/llvm_build_hwasan/lib/clang/22/include -nostdsysteminc /home/thurston/llvm-project/clang/test/SemaOpenACC/loop-construct-reduction-clause.cpp -fopenacc -verify
libc++abi: Pure virtual function called!
/home/thurston/buildbot_repro/llvm_build_hwasan/tools/clang/test/SemaOpenACC/Output/loop-construct-reduction-clause.cpp.script: line 1: 1815580 Aborted                 /home/thurston/buildbot_repro/llvm_build_hwasan/bin/clang -cc1 -internal-isystem /home/thurston/buildbot_repro/llvm_build_hwasan/lib/clang/22/include -nostdsysteminc /home/thurston/llvm-project/clang/test/SemaOpenACC/loop-construct-reduction-clause.cpp -fopenacc -verify

--
```
but when I tried running the test command, all I get are memory leaks (which are still worth fixing, but doesn't explain the "pure virtual function" error):

```
Direct leak of 120 byte(s) in 1 object(s) allocated from:
    #0 0xc7425bb0c970 in malloc /home/thurston/llvm-project/compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp:147:3
    #1 0xc74262a23140 in safe_malloc /home/thurston/llvm-project/llvm/include/llvm/Support/MemAlloc.h:26:18
    #2 0xc74262a23140 in llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long) /home/thurston/llvm-project/llvm/lib/Support/SmallVector.cpp:151:15
    #3 0xc742681d4be0 in grow_pod /home/thurston/llvm-project/llvm/include/llvm/ADT/SmallVector.h:139:11
    #4 0xc742681d4be0 in grow /home/thurston/llvm-project/llvm/include/llvm/ADT/SmallVector.h:525:41
    #5 0xc742681d4be0 in llvm::SmallVectorImpl<clang::OpenACCReductionRecipe::CombinerRecipe>::operator=(llvm::SmallVectorImpl<clang::OpenACCReductionRecipe::CombinerRecipe> const&) /home/thurston/llvm-project/llvm/include/llvm/ADT/SmallVector.h:1036:11
    #6 0xc7426a5ed960 in SmallVector /home/thurston/llvm-project/llvm/include/llvm/ADT/SmallVector.h:1238:27
    #7 0xc7426a5ed960 in OpenACCReductionRecipe /home/thurston/llvm-project/clang/include/clang/AST/OpenACCClause.h:1281:8
    #8 0xc7426a5ed960 in __uninitialized_copy<clang::OpenACCReductionRecipe, const clang::OpenACCReductionRecipe *, const clang::OpenACCReductionRecipe *, clang::OpenACCReductionRecipe *, std::__1::__always_false> /home/thurston/buildbot_repro/libcxx_install_hwasan/include/c++/v1/__memory/uninitialized_algorithms.h:66:56
    #9 0xc7426a5ed960 in uninitialized_copy<const clang::OpenACCReductionRecipe *, clang::OpenACCReductionRecipe *> /home/thurston/buildbot_repro/libcxx_install_hwasan/include/c++/v1/__memory/uninitialized_algorithms.h:76:19
    #10 0xc7426a5ed960 in uninitialized_copy<llvm::ArrayRef<clang::OpenACCReductionRecipe> &, clang::OpenACCReductionRecipe *> /home/thurston/llvm-project/llvm/include/llvm/ADT/STLExtras.h:2056:10
    #11 0xc7426a5ed960 in clang::OpenACCReductionClause::OpenACCReductionClause(clang::SourceLocation, clang::SourceLocation, clang::OpenACCReductionOperator, llvm::ArrayRef<clang::Expr*>, llvm::ArrayRef<clang::OpenACCReductionRecipe>, clang::SourceLocation) /home/thurston/llvm-project/clang/include/clang/AST/OpenACCClause.h:1328:5
    #12 0xc7426a5ed3f0 in clang::OpenACCReductionClause::Create(clang::ASTContext const&, clang::SourceLocation, clang::SourceLocation, clang::OpenACCReductionOperator, llvm::ArrayRef<clang::Expr*>, llvm::ArrayRef<clang::OpenACCReductionRecipe>, clang::SourceLocation) /home/thurston/llvm-project/clang/lib/AST/OpenACCClause.cpp:514:20
    #13 0xc742689f1254 in clang::SemaOpenACC::CheckReductionClause(llvm::ArrayRef<clang::OpenACCClause const*>, clang::OpenACCDirectiveKind, clang::SourceLocation, clang::SourceLocation, clang::OpenACCReductionOperator, llvm::ArrayRef<clang::Expr*>, llvm::ArrayRef<clang::OpenACCReductionRecipe>, clang::SourceLocation) /home/thurston/llvm-project/clang/lib/Sema/SemaOpenACCClause.cpp:2228:15
    #14 0xc74269143240 in VisitReductionClause /home/thurston/llvm-project/clang/lib/Sema/TreeTransform.h:12394:40
    #15 0xc74269143240 in Visit /home/thurston/llvm-project/clang/include/clang/Basic/OpenACCClauses.def:65:1
    #16 0xc74269143240 in TransformOpenACCClause /home/thurston/llvm-project/clang/lib/Sema/TreeTransform.h:12491:13
    #17 0xc74269143240 in clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformOpenACCClauseList(clang::OpenACCDirectiveKind, llvm::ArrayRef<clang::OpenACCClause const*>) /home/thurston/llvm-project/clang/lib/Sema/TreeTransform.h:12502:57
    #18 0xc742691276d8 in clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformOpenACCLoopConstruct(clang::OpenACCLoopConstruct*) /home/thurston/llvm-project/clang/lib/Sema/TreeTransform.h:12542:20
    #19 0xc742690f1224 in clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) /home/thurston/llvm-project/clang/lib/Sema/TreeTransform.h:8028:38
    #20 0xc74269128a88 in clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformOpenACCComputeConstruct(clang::OpenACCComputeConstruct*) /home/thurston/llvm-project/clang/lib/Sema/TreeTransform.h:12526:38
    #21 0xc742690f1224 in clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) /home/thurston/llvm-project/clang/lib/Sema/TreeTransform.h:8028:38
    #22 0xc742690bb578 in clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) /home/thurston/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:4418:23
    #23 0xc7426919cef4 in clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) /home/thurston/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:5892:14
    #24 0xc742691a6180 in clang::Sema::PerformPendingInstantiations(bool, bool) /home/thurston/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:7150:9
    #25 0xc74267e60b80 in clang::Sema::ActOnEndOfTranslationUnitFragment(clang::TUFragmentKind) /home/thurston/llvm-project/clang/lib/Sema/Sema.cpp:1221:5
    #26 0xc74267e618d8 in clang::Sema::ActOnEndOfTranslationUnit() /home/thurston/llvm-project/clang/lib/Sema/Sema.cpp:1245:5
    #27 0xc74267af9644 in clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) /home/thurston/llvm-project/clang/lib/Parse/Parser.cpp:712:13
    #28 0xc74267ad9ef8 in clang::ParseAST(clang::Sema&, bool, bool) /home/thurston/llvm-project/clang/lib/Parse/ParseAST.cpp:170:20
    #29 0xc742647cbef0 in clang::FrontendAction::Execute() /home/thurston/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1311:3
    #30 0xc74264687a18 in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/thurston/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1008:33

Direct leak of 120 byte(s) in 1 object(s) allocated from:
    #0 0xc7425bb0c970 in malloc /home/thurston/llvm-project/compiler-rt/lib/hwasan/hwasan_allocation_functions.cpp:147:3
    #1 0xc74262a23140 in safe_malloc /home/thurston/llvm-project/llvm/include/llvm/Support/MemAlloc.h:26:18
    #2 0xc74262a23140 in llvm::SmallVectorBase<unsigned int>::grow_pod(void*, unsigned long, unsigned long) /home/thurston/llvm-project/llvm/lib/Support/SmallVector.cpp:151:15
    #3 0xc742681d4be0 in grow_pod /home/thurston/llvm-project/llvm/include/llvm/ADT/SmallVector.h:139:11
    #4 0xc742681d4be0 in grow /home/thurston/llvm-project/llvm/include/llvm/ADT/SmallVector.h:525:41
    #5 0xc742681d4be0 in llvm::SmallVectorImpl<clang::OpenACCReductionRecipe::CombinerRecipe>::operator=(llvm::SmallVectorImpl<clang::OpenACCReductionRecipe::CombinerRecipe> const&) /home/thurston/llvm-project/llvm/include/llvm/ADT/SmallVector.h:1036:11
    #6 0xc7426a5ed960 in SmallVector /home/thurston/llvm-project/llvm/include/llvm/ADT/SmallVector.h:1238:27
    #7 0xc7426a5ed960 in OpenACCReductionRecipe /home/thurston/llvm-project/clang/include/clang/AST/OpenACCClause.h:1281:8
    #8 0xc7426a5ed960 in __uninitialized_copy<clang::OpenACCReductionRecipe, const clang::OpenACCReductionRecipe *, const clang::OpenACCReductionRecipe *, clang::OpenACCReductionRecipe *, std::__1::__always_false> /home/thurston/buildbot_repro/libcxx_install_hwasan/include/c++/v1/__memory/uninitialized_algorithms.h:66:56
    #9 0xc7426a5ed960 in uninitialized_copy<const clang::OpenACCReductionRecipe *, clang::OpenACCReductionRecipe *> /home/thurston/buildbot_repro/libcxx_install_hwasan/include/c++/v1/__memory/uninitialized_algorithms.h:76:19
    #10 0xc7426a5ed960 in uninitialized_copy<llvm::ArrayRef<clang::OpenACCReductionRecipe> &, clang::OpenACCReductionRecipe *> /home/thurston/llvm-project/llvm/include/llvm/ADT/STLExtras.h:2056:10
    #11 0xc7426a5ed960 in clang::OpenACCReductionClause::OpenACCReductionClause(clang::SourceLocation, clang::SourceLocation, clang::OpenACCReductionOperator, llvm::ArrayRef<clang::Expr*>, llvm::ArrayRef<clang::OpenACCReductionRecipe>, clang::SourceLocation) /home/thurston/llvm-project/clang/include/clang/AST/OpenACCClause.h:1328:5
    #12 0xc7426a5ed3f0 in clang::OpenACCReductionClause::Create(clang::ASTContext const&, clang::SourceLocation, clang::SourceLocation, clang::OpenACCReductionOperator, llvm::ArrayRef<clang::Expr*>, llvm::ArrayRef<clang::OpenACCReductionRecipe>, clang::SourceLocation) /home/thurston/llvm-project/clang/lib/AST/OpenACCClause.cpp:514:20
    #13 0xc742689f1254 in clang::SemaOpenACC::CheckReductionClause(llvm::ArrayRef<clang::OpenACCClause const*>, clang::OpenACCDirectiveKind, clang::SourceLocation, clang::SourceLocation, clang::OpenACCReductionOperator, llvm::ArrayRef<clang::Expr*>, llvm::ArrayRef<clang::OpenACCReductionRecipe>, clang::SourceLocation) /home/thurston/llvm-project/clang/lib/Sema/SemaOpenACCClause.cpp:2228:15
    #14 0xc74268a136ac in (anonymous namespace)::SemaOpenACCClauseVisitor::VisitReductionClause(clang::SemaOpenACC::OpenACCParsedClause&) /home/thurston/llvm-project/clang/lib/Sema/SemaOpenACCClause.cpp:1789:18
    #15 0xc742689eb0c8 in Visit /home/thurston/llvm-project/clang/include/clang/Basic/OpenACCClauses.def:65:1
    #16 0xc742689eb0c8 in clang::SemaOpenACC::ActOnClause(llvm::ArrayRef<clang::OpenACCClause const*>, clang::SemaOpenACC::OpenACCParsedClause&) /home/thurston/llvm-project/clang/lib/Sema/SemaOpenACCClause.cpp:1911:35
    #17 0xc74267d3ac80 in clang::Parser::ParseOpenACCClauseParams(llvm::ArrayRef<clang::OpenACCClause const*>, clang::OpenACCDirectiveKind, clang::OpenACCClauseKind, clang::SourceLocation) /home/thurston/llvm-project/clang/lib/Parse/ParseOpenACC.cpp:1266:25
    #18 0xc74267d35244 in clang::Parser::ParseOpenACCClauseList(clang::OpenACCDirectiveKind) /home/thurston/llvm-project/clang/lib/Parse/ParseOpenACC.cpp:747:39
    #19 0xc74267d436ac in clang::Parser::ParseOpenACCDirective() /home/thurston/llvm-project/clang/lib/Parse/ParseOpenACC.cpp:1576:23
    #20 0xc74267d44c58 in clang::Parser::ParseOpenACCDirectiveStmt() /home/thurston/llvm-project/clang/lib/Parse/ParseOpenACC.cpp:1671:39
    #21 0xc74267ca3ea8 in clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::LabelDecl*) /home/thurston/llvm-project/clang/lib/Parse/ParseStmt.cpp:466:12
    #22 0xc74267ca14e0 in clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::LabelDecl*) /home/thurston/llvm-project/clang/lib/Parse/ParseStmt.cpp:77:20
    #23 0xc74267cbb3c0 in clang::Parser::ParseCompoundStatementBody(bool) /home/thurston/llvm-project/clang/lib/Parse/ParseStmt.cpp:1168:11
    #24 0xc74267cc1788 in operator() /home/thurston/llvm-project/clang/lib/Parse/ParseStmt.cpp:968:9
    #25 0xc74267cc1788 in void llvm::function_ref<void ()>::callback_fn<clang::Parser::ParseCompoundStatement(bool, unsigned int)::$_0>(long) /home/thurston/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:46:12
    #26 0xc7426407ae58 in operator() /home/thurston/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:69:12
    #27 0xc7426407ae58 in runWithSufficientStackSpace /home/thurston/llvm-project/clang/include/clang/Basic/Stack.h:49:7
    #28 0xc7426407ae58 in clang::StackExhaustionHandler::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) /home/thurston/llvm-project/clang/lib/Basic/StackExhaustionHandler.cpp:20:3
    #29 0xc74267ca5158 in ParseCompoundStatement /home/thurston/llvm-project/clang/lib/Parse/ParseStmt.cpp:967:16
    #30 0xc74267ca5158 in ParseCompoundStatement /home/thurston/llvm-project/clang/lib/Parse/ParseStmt.cpp:953:10
    #31 0xc74267ca5158 in clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::LabelDecl*) /home/thurston/llvm-project/clang/lib/Parse/ParseStmt.cpp:275:12
    #32 0xc74267ca14e0 in clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::LabelDecl*) /home/thurston/llvm-project/clang/lib/Parse/ParseStmt.cpp:77:20
    #33 0xc74267ca10ec in clang::Parser::ParseStatement(clang::SourceLocation*, clang::Parser::ParsedStmtContext, clang::LabelDecl*) /home/thurston/llvm-project/clang/lib/Parse/ParseStmt.cpp:48:11

SUMMARY: HWAddressSanitizer: 240 byte(s) leaked in 2 allocation(s).
```

(The x86 ASan bot [https://lab.llvm.org/buildbot/#/builders/52/builds/11843] is also able to reproduce the leaks.)

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


More information about the cfe-commits mailing list