[all-commits] [llvm/llvm-project] a25fd3: [flang] Remove FIRBuilder dependency from optimize...
Mehdi Amini via All-commits
all-commits at lists.llvm.org
Wed Sep 23 09:22:49 PDT 2026
Branch: refs/heads/users/mamini/flang-dialect-builder-dependency
Home: https://github.com/llvm/llvm-project
Commit: a25fd3e961c83677a33d44e8f6807d289937ec08
https://github.com/llvm/llvm-project/commit/a25fd3e961c83677a33d44e8f6807d289937ec08
Author: Mehdi Amini <joker.eph at gmail.com>
Date: 2026-09-23 (Wed, 23 Sep 2026)
Changed paths:
M flang/include/flang/Optimizer/Support/Utils.h
M flang/lib/Optimizer/Builder/IntrinsicCall.cpp
M flang/lib/Optimizer/Builder/Runtime/Numeric.cpp
M flang/lib/Optimizer/Builder/Runtime/Reduction.cpp
M flang/lib/Optimizer/Builder/Runtime/Transformational.cpp
M flang/lib/Optimizer/CodeGen/CodeGen.cpp
Log Message:
-----------
[flang] Remove FIRBuilder dependency from optimizer support utilities
Build 21721 of flang-aarch64-latest-gcc failed while linking the shared
FIRDialect library, even though its main-branch revision only changed TOSA
tests. FIROps.cpp.o had undefined references to
fir::FirOpBuilder::setCommonAttributes(mlir::Operation *) const from
FirOpBuilder::notifyOperationInserted, RewriterBase::ForwardingListener's
notifyOperationInserted, and OpBuilder::createOrFold<fir::ConvertOp>.
The shared-library link uses -z defs, so those references are fatal.
The apparent intermittency follows the worker, rather than the test-only
change: the Linaro worker uses GCC 16.0.1 and failed in builds 21717, 21719,
and 21721, while the Arm worker uses GCC 15.2.0 and passed builds 21716,
21718, and 21720. Build 21719 already reports the same undefined references.
Build 21721 also deleted its build directory before compiling.
FIROps.cpp includes Optimizer/Support/Utils.h, which previously included
FIRBuilder.h. That exposes the inline virtual override
FirOpBuilder::notifyOperationInserted and its call to the out-of-line
setCommonAttributes implementation. Speculative devirtualization can turn
an ordinary virtual listener call into a guarded direct call and inline
that override, introducing a reference to setCommonAttributes without an
explicit use of FirOpBuilder in FIROps.cpp. This is consistent with the
reported call sites and GCC 16's expanded speculative devirtualization.
The implementation belongs to FIRBuilder, whereas FIRDialect does not link
FIRBuilder. Adding that link would create a dependency cycle, since
FIRBuilder already depends on FIRDialect. Remove the unnecessary header
dependency instead, so the optimizer cannot see this derived listener
implementation when compiling FIROps.cpp.
The intrinsic type diagnostic helpers only needed the builder to get an
MLIRContext, which is already available from the type. Drop their builder
parameters, use type.getContext(), and update all callers, including the
now-unused parameters in the intrinsic-name diagnostic helpers. Remove
FIRBuilder.h from Utils.h and avoid the string-literal namespace import it
provided transitively. Include FIRBuilder.h explicitly in CodeGen.cpp,
which directly uses factory helpers declared there.
Validation with Clang 22, Release, assertions, and BUILD_SHARED_LIBS=ON:
- Built and linked FIRDialect and FIRBuilder successfully.
- Compiled all 21 direct translation-unit consumers of Utils.h.
- Compared preprocessing before and after: FIROps.cpp no longer includes
FIRBuilder.h or the FirOpBuilder class definition.
- Checked Ninja dependencies and object symbols: FIROps.cpp.o no longer
depends on FIRBuilder.h and has no FirOpBuilder/setCommonAttributes
symbols.
- Passed git diff --check.
The standalone FIRBuilder build needed acc_gen generated explicitly for
an unrelated missing OpenACC parser header. The exact GCC 16/AArch64 bot
configuration has not been rerun. A separate reduced virtual-call example
on GCC 13 reproduced the unexpected undefined reference with speculation
and linked successfully with -fno-devirtualize-speculatively.
Failure log:
https://lab.llvm.org/buildbot/#/builders/130/builds/21721
GCC 16 optimization changes:
https://gcc.gnu.org/gcc-16/changes.html
Assisted-by: Codex
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list