Comments (8)
unnamed_addr
allows LLVM to merge multiple functions if they have the same body after optimizations. This will result in their address comparing equal.
from rust.
So there's no impact on icmp
semantics?
Apart from unnamed_addr we also have our own multiple-codegen-unit issue, where the same function can have more than one address. That could be considered as making a choice at fn-item-to-fn-ptr coercion time. The possible concern here is having the AllocId we generate there move into different codegen units or crates so they don't end up being the same address. But that's already the case I think? const C: fn() = myfunc;
is evaluated once but we just use the AllocId
everywhere and each crate will do with that whatever it wants. Even without GVN I think this means that that const can have different integer values in different crates?
from rust.
Cc @oli-obk for the last question
from rust.
So there's no impact on
icmp
semantics?
The icmp may evaluate to either true or false, but it will do so consistently. That is, for unnamed_addr symbols, LLVM will not fold "icmp eq s1, s2" to false in cases it normally could, in case s1 and s2 end up being merged later.
from rust.
const C: fn() = myfunc; is evaluated once
it is evaluated per-crate. For constants we only cache within the current crate.
but we just use the AllocId everywhere and each crate will do with that whatever it wants.
yea, that's why it doesn't matter, each crate generates its own AllocId
per function pointer anyway. And we do generate multiple different AllocId
s for the same function pointer... sometimes. See
Even without GVN I think this means that that const can have different integer values in different crates?
what integer values?
from rust.
@nikic thanks!
yea, that's why it doesn't matter, each crate generates its own AllocId per function pointer anyway.
If we have const C: fn() = myfunc;
in one crate then that's a single AllocId
, right?
But OTOH AllocId
is a per-rustc-invocation identifier and they get re-assigned when rlibs get loaded... right? So the question is somewhat moot anyway.
what integer values?
The underlying address, after compilation.
So probably the GVN issue is about something like
const C: fn() = myfunc;
let x = C;
let y = x; // definitely the same address as x
becoming
const C: fn() = myfunc;
let x = C;
let y = C; // maybe a different address than x?
I think we want to be sure that C
is the same address when it is used multiple times in the same function. But what has to happen to make that true?
from rust.
But what has to happen to make that true?
It's already true if LLVM makes it true. We swap the alloc id for its Instance in codegen. So whatever happens there is relevant.
To also deduplicate AllocIds, we need to remove
and always run the else arm.from rust.
Related Issues (20)
- ICE: `No HirID for DefId(...)` with feature `generic_assert` HOT 2
- Nonsensical suggested type using chumsky select! (E0284) HOT 4
- Confusing error message on using `step_by` and `take` on infinite iterator
- ICE: kcfi: `expected item, found (root_crate)` HOT 1
- ICE: kcfi: `unexpected parent of trait or impl item or item not found: ForeignMod` HOT 1
- ICE: kcfi: `cannot get associated-item of DefKey..` HOT 3
- patterns: wrong tracking issue? HOT 20
- Tracking Issue for pattern types HOT 1
- Async closure internal compiler error HOT 2
- ICE: `unexpected bound var resolution for HirId(...): None` HOT 1
- rustdoc doesn't support reading from STDIN via the fake path `-` (dash)
- Rustdoc incorrectly fires `redundant_explicit_link` warning HOT 3
- ICE: kcfi: `args not compatible with generics for Foo::Bar`
- ICE: kcfi: `encode_region: unexpected ''static'`
- RUST_BACKTRACE=full panic causes infinite loop on aarch64-pc-windows-msvc HOT 3
- Test failure when enabling vendoring HOT 1
- ICE: `Unsigned value 0x100 does not fit in 8 bits` HOT 3
- Macro hygienics don't prevent const cycles HOT 7
- ICE: `Size::sub: 0 - 1 would result in negative size` HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.