The answer is a bit out of date. I believe -disable-llvm-optzns is deprecated/removed. You can do this with the driver using something like this:
clang -O2 -Xclang -disable-llvm-passes -S -emit-llvm
Readthedocs
the-ravi-programming-language.readthedocs.io › en › stable › llvm-tbaa.html
LLVM Type Based Alias Analysis — Ravi Programming Language 0.1 documentation
The TBAA nodes hang off a root node. So we create that next: llvm::MDNode *tbaa_root; // Do what Clang does tbaa_root = mdbuilder.createTBAARoot("Simple C / C++ TBAA");
LLVM
llvm.org › doxygen › TypeBasedAliasAnalysis_8cpp_source.html
LLVM: lib/Analysis/TypeBasedAliasAnalysis.cpp Source File
Check the first operand of the tbaa tag node, if it is a MDNode, we treat it as struct-path aware TBA...
support new struct path tbaa in MLIR LLVM Dialect
I'm currently working on implementing support for TBAA ( llvm/clangir#1076 ) in Clang IR and have noticed that the LLVM Dialect does not accommodate the new format of TBAA. To address this, I’v... More on github.com
Proper way to give TBAA (type based alias analysis) information using MLIR LLVM dialect
Hello, this question is bit between topics of MLIR and LLVM, but since’ I’m working with MLIR currently, I set the category to ‘MLIR’. I’m working on my own dialect that can be lowered directly to MLIR LLVM dialect, and I want to attach TBAA metadata to help LLVM compiler optimize ... More on discourse.llvm.org
Regression in impact of `-new-struct-path-tbaa` on strict-alias analysis
Up until clang 17, -new-struct-path-tbaa used to be able to deduce that t1.a and t2.b do not alias. in clang 18 it no longer does In this godbolt https://godbolt.org/z/MGG98Gfra it can be seen that clang17 is able to vectorize the two assigments into one, but clang18 isn't. More on github.com
TBAA: `-new-struct-path-tbaa `status - IR & Optimizations - LLVM Discussion Forums
-new-struct-path-tbaa is work from ~6Y ago (although I think the discussion started ~10Y ago ) authored by @kosarev with fixes from ~1Y ago by @brunodf. It creates !tbaa metadata for structs and members where it wasn’t available before - in particular improving the optimizations for ... More on discourse.llvm.org
Top answer 1 of 2
2
The answer is a bit out of date. I believe -disable-llvm-optzns is deprecated/removed. You can do this with the driver using something like this:
clang -O2 -Xclang -disable-llvm-passes -S -emit-llvm
2 of 2
1
I don't suggest it for production use, but you can do something like this:
clang -cc1 -O1 -no-struct-path-tbaa -disable-llvm-optzns foo.cpp -emit-llvm -o -
to take a look at the TBAA metadata (remove the -no-struct-path-tbaa if you want to look at that as well).
Otherwise you could modify clang pretty easily to always turn on TBAA metadata.
GitHub
github.com › llvm › llvm-project › issues › 119699
support new struct path tbaa in MLIR LLVM Dialect · Issue #119699 · llvm/llvm-project
December 12, 2024 - I'm currently working on implementing support for TBAA ( llvm/clangir#1076 ) in Clang IR and have noticed that the LLVM Dialect does not accommodate the new format of TBAA. To address this, I’v...
Author llvm
GitHub
github.com › llvm › llvm-project › pull › 116596
[TBAA] Don't emit pointer tbaa for unnamed structs or unions. by fhahn · Pull Request #116596 · llvm/llvm-project
There are 2 pending PRs with bug fixes for special cases uncovered during some of my testing: * llvm#116991 * llvm#116596 ... Support for more precise TBAA metadata has been added a while ago (behind the -fpointer-tbaa flag). The more precise TBAA metadata allows treating accesses of different pointer types as no-alias.
Author llvm
LLVM Discussion Forums
discourse.llvm.org › mlir
Proper way to give TBAA (type based alias analysis) information using MLIR LLVM dialect - MLIR - LLVM Discussion Forums
April 18, 2024 - Hello, this question is bit between topics of MLIR and LLVM, but since’ I’m working with MLIR currently, I set the category to ‘MLIR’. I’m working on my own dialect that can be lowered directly to MLIR LLVM dialect, and I want to attach TBAA metadata to help LLVM compiler optimize the code with type aliases.
LLVM
llvm.org › devmtg › 2012-11 › Gohman-AliasAnalysis.pdf pdf
Alias Analysis in LLVM
LLVM's Alias Anslysis API · Location, Location, Location · Pointer · Size · TBAA tag · Sizes are given in address units (bytes usually) alias · - 2 Locations · getModRefInfo and getModRefBehavior · pointsToConstantMemory · AliasAnalysis.h basics · NoAlias = can reorder* MustAlias ...
Google Groups
groups.google.com › g › llvm-dev › c › WYwghQfM_FY
[llvm-dev] [RFC] Design of a TBAA sanitizer
At EuroLLVM, Chandler and I chatted about the design for a potential TBAA sanitizer. Here's my attempt to summarize: C/C++ have type-based aliasing rules, and LLVM's optimizer can exploit these given TBAA metadata added by Clang. Roughly, a pointer of given type cannot be used to access an ...
GitHub
github.com › llvm › llvm-project › issues › 95661
Regression in impact of `-new-struct-path-tbaa` on strict-alias analysis · Issue #95661 · llvm/llvm-project
June 15, 2024 - struct Wrapper { int t; }; struct T { Wrapper a, b; }; void g(T& t1, const T& t2 ) { t1.a = t2.a; t1.b = t2.b; } Up until clang 17, -new-struct-path-tbaa used to be able to deduce that t1.a and t2.b do not alias. in clang 18 it no longer...
Author llvm
Cornell Computer Science
cs.cornell.edu › courses › cs6120 › 2022sp › blog › type-alias
CS 6120: Type-based Alias Analysis
March 22, 2022 - The simplicity, speed, and accuracy of TBAA has allowed it to stick around in many modern compilers. LLVM has several different alias analyses, including an implementation of TBAA. The compiler frontend must include type annotations that can then be used for alias based optimization within ...
LLVM
reviews.llvm.org › D122573
⚙ D122573 [TBAA] Emit distinct TBAA tags for pointers with different depths,types.
March 28, 2022 - This patch extends Clang's TBAA generation code to emit distinct tags for incompatible pointer types · Pointers with different element types are incompatible if the pointee types are also incompatible (modulo sugar/modifiers)
LLVM Discussion Forums
discourse.llvm.org › ir & optimizations
TBAA: `-new-struct-path-tbaa `status - IR & Optimizations - LLVM Discussion Forums
May 3, 2023 - -new-struct-path-tbaa is work from ~6Y ago (although I think the discussion started ~10Y ago ) authored by @kosarev with fixes from ~1Y ago by @brunodf. It creates !tbaa metadata for structs and members where it wasn’t available before - in particular improving the optimizations for strong-typedefs, making them essentially zero-cost abstractions as they are advertised to be.
GitHub
github.com › llvm-mirror › llvm › blob › master › lib › Analysis › TypeBasedAliasAnalysis.cpp
llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp at master · llvm-mirror/llvm
April 23, 2020 - // http://llvm.org/docs/AliasAnalysis.html#OtherItfs). // // With struct-path aware TBAA, the MDNodes attached to an instruction using · // "!tbaa" are called path tag nodes. // // The path tag node has 4 fields with the last field being optional.
Author llvm-mirror
LLVM
llvm.org › doxygen › classllvm_1_1TBAAVerifier.html
LLVM: llvm::TBAAVerifier Class Reference
Visit an instruction, or a TBAA node itself as part of a metadata, and return true if it is valid, return false if an invalid TBAA is attached. Definition at line 8189 of file Verifier.cpp. References CheckTBAA, llvm::dyn_cast_or_null(), llvm::mdconst::dyn_extract_or_null(), llvm::MDNode::getNumOperands(), llvm::MDNode::getOperand(), I, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::Invalid, llvm::isa(), isNewFormatTBAATypeNode(), IsRootTBAANode(), and llvm::Offset.
GitHub
github.com › llvm-mirror › clang › blob › master › test › CodeGen › tbaa.cpp
clang/test/CodeGen/tbaa.cpp at master · llvm-mirror/clang
April 23, 2020 - // RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -no-struct-path-tbaa -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s
Author llvm-mirror
GitHub
github.com › llvm › llvm-project › issues › 130958
[Clang] Missed case of TBAA with different derived classes with a common base class · Issue #130958 · llvm/llvm-project
March 12, 2025 - TBAAType-Based Alias Analysis / Strict AliasingType-Based Alias Analysis / Strict Aliasingclang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.missed-optimization
Author llvm
LLVM Discussion Forums
discourse.llvm.org › ir & optimizations
Type Based Alias Analysis giving incorrect aliasing information with enhanced TBAA format - IR & Optimizations - LLVM Discussion Forums
June 7, 2024 - Type Based Alias Analysis emits metadata nodes in the frontend, and an analysis pass in the middle-end does access tag matching to determine if two pointers alias or not. TBAA metadata is only attached to Load and Store Instructions.
Stefansf
stefansf.de › stefan sf › blog
Type-Based Alias Analysis in C
The language C has several constraints which allow compiler vendors to implement optimizations in order to emit fast code. One of such an optimization is based on type-based alias analysis (TBAA for short) which itself makes use of the strict aliasing rules. Aliasing refers to the property ...
LLVM Discussion Forums
discourse.llvm.org › ir & optimizations
TBAA metadata generation for coroutine frame slot access - IR & Optimizations - LLVM Discussion Forums
January 18, 2026 - I’ve just posted the PR: LLVM, Coroutines: Introduce TBAA metadata for frame object by yonillasky · Pull Request #176543 · llvm/llvm-project · GitHub To demonstrate why this is a problem, I can show a simple C++ coroutine “benchmark” example, where the lack of TBAA prevents “reloads” from being hoisted out of a tight loop.