When parsing IR, we do some optimizations very early - for example, the
constantFoldCompareGlobalToNull function folds comparisons against
null pointer. If the value has extern_weak linkage or if it is an
llvm.ptrauth wrapper corresponding to a symbol with extern_weak
linkage, the folding is prevented.
When the llvm.ptrauth wrapper was defined after its usage in such
condition, its uses (including the use in the condition) were updated
when the wrapper definition was found, but before its section was
parsed. Since the "llvm.ptrauth" section name indicates that the value
is an llvm.ptrauth wrapper, not having it parsed before updating usages
made the folding code think that this is not an llvm.ptrauth wrapper,
which led to undesired folding.
In b13997b111abfd9adcc9c5c2fdb25163f91bac3a, we move the code updating uses of the global value after the
code parsing its section name.
When parsing IR, we do some optimizations very early - for example, the
constantFoldCompareGlobalToNull
function folds comparisons against null pointer. If the value hasextern_weak
linkage or if it is an llvm.ptrauth wrapper corresponding to a symbol withextern_weak
linkage, the folding is prevented.When the llvm.ptrauth wrapper was defined after its usage in such condition, its uses (including the use in the condition) were updated when the wrapper definition was found, but before its section was parsed. Since the "llvm.ptrauth" section name indicates that the value is an llvm.ptrauth wrapper, not having it parsed before updating usages made the folding code think that this is not an llvm.ptrauth wrapper, which led to undesired folding.
In b13997b111abfd9adcc9c5c2fdb25163f91bac3a, we move the code updating uses of the global value after the code parsing its section name.