[PATCH] D159485: [DebugInfo][RemoveDIs] Use getStableDebugLoc when picking IRBuilder source locations
Krasimir Georgiev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 15 04:03:02 PDT 2023
krasimir added a comment.
Prepped an IR test case in https://github.com/llvm/llvm-project/pull/66491 based roughly on what rust was doing around the point of the segfault: create a basic block with just a debug call.
Not a rust compiler expert. From what I can gather looking at the wrapping code, rustc uses an utility `LLVMRustPositionBuilderAtStart`: https://github.com/rust-lang/rust/blob/915c8af55006772590d491bea5ba329e357a553a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp#L1520
extern "C" void LLVMRustPositionBuilderAtStart(LLVMBuilderRef B,
LLVMBasicBlockRef BB) {
auto Point = unwrap(BB)->getFirstInsertionPt();
unwrap(B)->SetInsertPoint(unwrap(BB), Point);
}
At the point of the crash, rust is operating on the `start` basic block of a function dump like this:
; Function Attrs: alwaysinline nonlazybind uwtable
define internal noundef nonnull align 8 ptr @"_ZN5alloc5boxed12Box$LT$T$GT$3new17h3257ceec0d2279b7E"(ptr noalias nocapture noundef align 8 dereferenceable(48) %x) unnamed_addr #4 personality ptr @rust_eh_personality !dbg !4808 {
start:
call void @llvm.dbg.declare(metadata ptr %x, metadata !4812, metadata !DIExpression()), !dbg !4813
bb2: ; No predecessors!
cleanup: ; No predecessors!
%0 = landingpad { ptr, i32 }
cleanup
%1 = extractvalue { ptr, i32 } %0, 0
%2 = extractvalue { ptr, i32 } %0, 1
}
I suppose rust has the logic to emit debug info and to put the alloca instruction separately, in a way that the above is later turned into a more "standard" basic block.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D159485/new/
https://reviews.llvm.org/D159485
More information about the llvm-commits
mailing list