[llvm] [LangRef] Try to formalize the definition of "odr" in LLVM IR. (PR #92619)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Fri May 17 17:51:52 PDT 2024
================
@@ -290,13 +290,17 @@ linkage:
symbol is weak until linked, if not linked, the symbol becomes null
instead of being an undefined reference.
``linkonce_odr``, ``weak_odr``
- Some languages allow differing globals to be merged, such as two
- functions with different semantics. Other languages, such as
- ``C++``, ensure that only equivalent globals are ever merged (the
- "one definition rule" --- "ODR"). Such languages can use the
- ``linkonce_odr`` and ``weak_odr`` linkage types to indicate that the
- global will only be merged with equivalent globals. These linkage
- types are otherwise the same as their non-``odr`` versions.
+ The ``odr`` suffix indicates that all globals defined with the given name
+ are equivalent, along the lines of the C++ "one definition rule" ("ODR").
+ Informally, this means we can inline functions and fold loads of constants.
+
+ Formally, use the following definition: when an ``odr`` function is
+ called, one of the definitions is non-deterministically chosen to run. For
+ ``odr`` variables, if the value any byte is not equal in all initializers,
----------------
MaskRay wrote:
typo: if any byte in the value?
https://github.com/llvm/llvm-project/pull/92619
More information about the llvm-commits
mailing list