DescriptionSimplifyAllocas: search through more bitcasts to find alloca for llvm.dbg.declare.
The webp/snes9x build was generating more intermediate
bitcasts than expected, so the fixup for making
llvm.dbg.declare's first argument be an alloca was
sometimes failing to find the alloca. I.e., some earlier
pass like instcombine was already violating the contract
that llvm.dbg.declare's first argument be an alloca or a
function argument.
Try to be more resilient and loop through more casts if
needed.
Technically llvm.dbg.declare's first argument doesn't
*have* to be an alloca:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-June/086647.html
However, ReplacePtrsWithInts does not handle converting
llvm.dbg.declare parameters which are bitcasts, and ends
up erasing the bitcasts. This causes us to drop debug
info. An alternative is to fix up ReplacePtrsWithInts
(TODO), but we need to make that work with DCE.
That is, the conversions inserted by ReplacePtrsWithInts
must not be used solely by llvm.dbg.declare, otherwise
DCE will delete those conversions and leave us with
a null argument to llvm.dbg.declare.
Example program state prior to SimplifyAllocas:
; Function Attrs: nounwind readonly
define internal fastcc i32 @png_sig_cmp(i8* readonly %sig, i32 %start, i32 %num_to_check) #3 {
entry:
%png_signature = alloca i64, align 8, !dbg !68085
%tmpcast = bitcast i64* %png_signature to [8 x i8]*, !dbg !68085
call void @llvm.dbg.declare(metadata [8 x i8]* %tmpcast, metadata !68092, metadata !45244), !dbg !68085
store i64 727905341920923785, i64* %png_signature, align 8, !dbg !68085
%cmp = icmp ugt i32 %num_to_check, 8, !dbg !68093
br i1 %cmp, label %if.end3, label %if.else, !dbg !68095
// ...
if.end6:
// ...
%gep_int6 = ptrtoint [8 x i8]* %tmpcast to i32, !dbg !68108
// ...
BUG= https://code.google.com/p/nativeclient/issues/detail?id=4203
R=dschuff@chromium.org
Committed: https://chromium.googlesource.com/native_client/pnacl-llvm/+/7aaca4671623197b185445558109f20f883d66fa
Patch Set 1 #
Total comments: 2
Patch Set 2 : report_fatal_error #
Messages
Total messages: 10 (1 generated)
|