LTO Global alias evaluation failing

Hi, I’m trying to create an alias of a global variable inside an LTO pass, for a given global variable definition: @a = internal global i32 1, align 4

I do not get any error if I try to generate a simple alias like,
@a.alias = internal alias i32, inttoptr (i64 ptrtoint (i32* @a to i64)) to i32*)
which automatically translates to
@a.alias = internal alias i32, i32* @a

but when I try to generate a more complex alias, like
@a.alias = internal alias i32, inttoptr (i64 or (i64 ptrtoint (i32* @a to i64), i64 12) to i32*)
it fails with an error,
“ld.gold: fatal error: LLVM gold plugin: <unknown>:0: expression could not be evaluated”

This is inspired from how global aliases are generated in hardware address sanitizer llvm-project/HWAddressSanitizer.cpp at main · llvm/llvm-project · GitHub
(Also cc-ing hw-asan people in case they know something already about this, @vitalybuka)

Is it not possible to do such evaluation on global variable’s address for creating aliases at LTO? I’ve not tried running it as a non-LTO pass to see if LTO is the reason for the failure.

Many thanks,
Reshabh

Found, we only support add and sub for evaluating non-constant operands. llvm-project/MCExpr.cpp at main · llvm/llvm-project · GitHub

Only add and sub is supported as they are used for handling offsets in relocatable symbols, I also can not think of a useful for supporting OR wrt offsets.

PS: Also found that this is independent of LTO