access-softek / llvm-project

Other
0 stars 0 forks source link

[AArch64][PAC] Do not fold ptrauth wrappers corresponding to `extern_weak` #59

Closed kovdan01 closed 10 months ago

kovdan01 commented 10 months ago

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.

asl commented 10 months ago

Tagging @ahmedbougacha