[PATCH] D145293: [GlobalOpt] Don't replace the aliasee if it has other references.
DianQK via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 8 06:06:38 PST 2023
DianQK updated this revision to Diff 503342.
DianQK added a comment.
In D145293#4176631 <https://reviews.llvm.org/D145293#4176631>, @MaskRay wrote:
> How does rustc use `llvm.compiler.used` or `llvm.uses`?
I have found at least two cases where rustc is used.
The first is the `sym` keyword used to keep the referenced symbol in the `global_asm` macro, which in this case would be marked as `llvm.compiler.used`.
extern "Rust" {
pub fn foo1();
pub fn foo2();
}
fn bar1() {}
fn bar2() {}
core::arch::global_asm!(".global foo1
foo1: jmp {}
.global foo2
foo2: jmp {}
", sym bar1, sym bar2);
The second is to used declare that the symbol is reserved.
#[used]
fn foo() {}
If we focus only on the first case, https://rust.godbolt.org/z/Ph419hqWv is a minimal example.
Due to the LTO pipeline of `rustc`, this optimized IR will be optimized again, which triggers the current problem, where `bar2` replaces `bar1` and removes `bar1`.
> If you can write an inline asm expression or module-level asm to demonstrate the issue, change the test to reflect the case.
Added.
> Do we have a use case with an internal alias and an aliasee which are not in `llvm.used`/`llvm.compiler.used`? If no, we should add such a test.
I think the `@fa2` in the previous `llvm/test/Transforms/GlobalOpt/alias-used.ll` use case corresponds to this use case.
It looks like a similar problem occurs in MergeFunctions, see Rust #99059 <https://github.com/rust-lang/rust/pull/99059> and D127751 <https://reviews.llvm.org/D127751>.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145293/new/
https://reviews.llvm.org/D145293
Files:
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/test/Transforms/GlobalOpt/X86/alias-used-with-asm.ll
llvm/test/Transforms/GlobalOpt/alias-used-address-space.ll
llvm/test/Transforms/GlobalOpt/alias-used.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145293.503342.patch
Type: text/x-patch
Size: 5829 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230308/3590bdd7/attachment.bin>
More information about the llvm-commits
mailing list