[llvm] [StackSafetyAnalysis] Don't call getTruncateOrZeroExtend for pointers of different sizes (PR #79804)

Florian Mayer via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 09:10:59 PST 2024


fmayer wrote:

> When trying to fix _that_ it turns out that StackSafetyAnalysis assumes that all accesses it doesn't visit are "safe". For example, in
> 
> ```llvm
> define void @indirect(ptr %p) {
> entry:
>   %a = alloca i8
>   store ptr %a, ptr %p
>   %a2 = load ptr, ptr %p
>   store i64 0, ptr %a2
>   ret void
> }
> ```
> 
> the last store is considered "safe" even though it obviously isn't. Apparently the reason why this doesn't miscompile everything is that asan will only use stackAccessIsSafe() if findAllocaForValue() also succeeds.

Why is this surprising? `stackAccessIsSafe` talks about stack access, if `findAllocaForValue` doesn't succeed it isn't necessarily a stack access, so using `stackAccessIsSafe` doesn't make sense.

https://github.com/llvm/llvm-project/pull/79804


More information about the llvm-commits mailing list