Issue 134367
Summary StackSafetyLocalAnalysis Assertion failed with ASAN
Labels new issue
Assignees
Reporter van-ema
    While compiling rust standard library with optimizatons and asan I found a similar issue to https://github.com/llvm/llvm-project/issues/87923


```
rustc: /home/ubuntu/rust-misc/llvm-project/llvm/lib/Analysis/StackSafetyAnalysis.cpp:540: void {anonymous}::StackSafetyLocalAnalysis::analyzeAllUses(llvm::Value*, {anonymous}::UseInfo<llvm::GlobalValue>&, const llvm::StackLifetime&): Assertion `isa<Function>(Callee) || isa<GlobalAlias>(Callee)' failed.
error: could not compile `std` (lib)
```

to reproduce run any rust program with 
```
RUSTFLAGS="-C opt-level=3  -Zsanitizer=address" cargo build --target x86_64-unknown-linux-gnu -Zbuild-std
```
issue can be reproduced at any opt level > 0

Rust version: 1.82
llvm: llvmorg-19.1.4

Debugging this I found that assertion `assert(isa<Function>(Callee) || isa<GlobalAlias>(Callee));` fails because of
`@getrandom = extern_weak global i8 at   %13 = tail call noundef i64 @getrandom(ptr noundef nonnull %ptr46, i64 noundef %new_len45, i32 noundef 4) #25, !dbg !1007 in module std.33b5cc56158b1412-cgu.15`

My workaround for now is to not take `GlobalVariable` Callee(s)

```
        const GlobalValue *Callee =
 dyn_cast<GlobalValue>(CB.getCalledOperand()->stripPointerCasts());
	 if (!Callee || isa<GlobalIFunc>(Callee) || isa<GlobalVariable>(Callee)) {
          US.addRange(I, UnknownRange, /*IsSafe=*/false);
 break;
        }
```

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to