[clang] [llvm] [clang][WebAssembly] support custom module name of import globals (PR #200722)
Changqing Jing via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 8 18:59:20 PDT 2026
Changqing-JING wrote:
Thank you for reply.
Yes, the #201966 works for me.
_What you're using Wasm globals for?_
I'm using immutable import global to do some platform specific branch optimization in Wasm AOT compiler.
For example, in pseudo code
```
import function getOS;
if(getOS() == someOS){
doSomething();
}
```
Fristly, both llvm and binaryen can't optimize this code since OS is unknown at compile time.
For Wasm AOT compiler, the `getOS() == someOS` logically can know at compile time, but AOT compiler itself also don't know what's the return of a custom import function.
So I want to use
```
import immutable global currentOS;
if(currentOS == someOS){
doSomething();
}
```
Then AOT compiler can easily optimize the if branch.
https://github.com/llvm/llvm-project/pull/200722
More information about the cfe-commits
mailing list