Skip to content

29 featcompiler optimisation in tree frontend optnone injection clean diagnostics in compiler wrapper#30

Merged
SizzleUnrlsd merged 9 commits intomainfrom
29-featcompiler-optimisation-in-tree-frontend-optnone-injection-clean-diagnostics-in-compiler-wrapper
Feb 8, 2026
Merged

29 featcompiler optimisation in tree frontend optnone injection clean diagnostics in compiler wrapper#30
SizzleUnrlsd merged 9 commits intomainfrom
29-featcompiler-optimisation-in-tree-frontend-optnone-injection-clean-diagnostics-in-compiler-wrapper

Conversation

@SizzleUnrlsd
Copy link
Contributor

1. Frontend OptNone (dedicated architecture)

New module:

•	optnone_action.hpp
•	optnone_action.cpp

Role: an ASTConsumer that adds OptimizeNoneAttr + NoInlineAttr to user functions (i.e., those not coming from system headers).
Executed before codegen (via HandleTopLevelDecl + HandleInlineFunctionDefinition).


2. Pipeline integration

compiler.cpp
The custom OptNoneAction<...> wraps Clang actions (EmitLLVMOnly, EmitLLVM, etc.).
A helper ensures the module is consumed before the action is destroyed (UAF fix).


3. Configuration flag

New CLI flag:

•	--ct-optnone / --ct-no-optnone

Added to config:

•	config.hpp
•	config.cpp

CLI documentation:

•	help.cc

4. Warnings handling and compatibility

Detect conflict --ct-optnone + -disable-O0-optnone → clear warning.
In ToMemory, remove -c and -disable-O0-optnone to avoid “unused” warnings.

Fixed bugs

•	ASAN use-after-free: CodeGenAction destroyed the LLVMContext before the module was used.

Fix via a helper that keeps the action alive during module->print(...).
• Attributes not visible: initially injected too late (HandleTranslationUnit), fixed by acting before codegen.

Final result

•	The --ct-optnone flag forces optnone/noinline on user functions.
•	It works even if the automatic -O0 optnone is disabled.
•	No more useless warnings when compiling in-memory.

@SizzleUnrlsd SizzleUnrlsd merged commit 1bc23b2 into main Feb 8, 2026
4 checks passed
@SizzleUnrlsd SizzleUnrlsd deleted the 29-featcompiler-optimisation-in-tree-frontend-optnone-injection-clean-diagnostics-in-compiler-wrapper branch February 8, 2026 00:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(compiler-optimisation): in-tree frontend optnone injection + clean diagnostics in compiler wrapper

1 participant