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