[LLVMbugs] [Bug 23458] New: Missing debug info on phi crashes vectorizer diagnostics

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri May 8 14:51:35 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=23458

            Bug ID: 23458
           Summary: Missing debug info on phi crashes vectorizer
                    diagnostics
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: jonathan at codesourcery.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Expected results:

Print a pair of diagnostic remarks explaining that the loop can't be vectorized
because sum isn't a reduction (it would be if I had passed -ffast-math).

Actual results:

$ cat sum_array.c
float sum_array(float * In, int Len) {
  float sum = 0;
  for (int i = 0; i < Len*8; i++) {
    sum += In[i];
  }
  return sum;
}
$ clang sum_array.c -O3 -Rpass=loop-vectorize -Rpass-missed=loop-vectorize
-Rpass-analysis=loop-vectorize -c
Assertion failed: (L != nullptr && "debug location is invalid"), function
getLocation, file <snip>/lib/IR/DiagnosticInfo.cpp, line 139.

$ lldb <snip>
<snip>
(lldb) run
Process 85893 launched: '<snip>/bin/clang-3.7' (x86_64)
Assertion failed: (L != nullptr && "debug location is invalid"), function
getLocation, file
/Users/Shared/Jenkins/Home/jobs/llvm-project/workspace/lib/IR/DiagnosticInfo.cpp,
line 139.
Process 85893 stopped
* thread #1: tid = 0x9e82ed, 0x00007fff8a3be282
libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread',
stop reason = signal SIGABRT
    frame #0: 0x00007fff8a3be282 libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill:
->  0x7fff8a3be282 <+10>: jae    0x7fff8a3be28c            ; <+20>
    0x7fff8a3be284 <+12>: movq   %rax, %rdi
    0x7fff8a3be287 <+15>: jmp    0x7fff8a3b9ca3            ; cerror_nocancel
    0x7fff8a3be28c <+20>: retq 
(lldb) bt
* thread #1: tid = 0x9e82ed, 0x00007fff8a3be282
libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread',
stop reason = signal SIGABRT
    frame #0: 0x00007fff8a3be282 libsystem_kernel.dylib`__pthread_kill + 10
    frame #1: 0x00007fff91e404c3 libsystem_pthread.dylib`pthread_kill + 90
    frame #2: 0x0000000101d8d74b clang-3.7`raise(sig=6) + 27 at Signals.inc:536
    frame #3: 0x0000000101d8d802 clang-3.7`abort + 18 at Signals.inc:553
    frame #4: 0x0000000101d8d7e1
clang-3.7`__assert_rtn(func=0x00000001049f71c0, file=0x00000001049f71cc,
line=139, expr=0x00000001049f721d) + 129 at Signals.inc:549
    frame #5: 0x00000001014e1247
clang-3.7`llvm::DiagnosticInfoOptimizationBase::getLocation(this=0x00007fff5fbf9ef8,
Filename=0x00007fff5fbf9b80, Line=0x00007fff5fbf9b7c,
Column=0x00007fff5fbf9b78) const + 135 at DiagnosticInfo.cpp:139
    frame #6: 0x0000000102873d56
clang-3.7`clang::BackendConsumer::EmitOptimizationMessage(this=0x000000010ac15870,
D=0x00007fff5fbf9ef8, DiagID=466) + 214 at CodeGenAction.cpp:437
    frame #7: 0x000000010287434d
clang-3.7`clang::BackendConsumer::OptimizationRemarkHandler(this=0x000000010ac15870,
D=0x00007fff5fbf9ef8) + 173 at CodeGenAction.cpp:494
    frame #8: 0x000000010287477b
clang-3.7`clang::BackendConsumer::DiagnosticHandlerImpl(this=0x000000010ac15870,
DI=0x00007fff5fbf9ef8) + 523 at CodeGenAction.cpp:548
    frame #9: 0x000000010287a238
clang-3.7`clang::BackendConsumer::DiagnosticHandler(DI=0x00007fff5fbf9ef8,
Context=0x000000010ac15870) + 40 at CodeGenAction.cpp:230
    frame #10: 0x0000000101624b54
clang-3.7`llvm::LLVMContext::diagnose(this=0x000000010ac0cf70,
DI=0x00007fff5fbf9ef8) + 116 at LLVMContext.cpp:195
    frame #11: 0x00000001014e1750
clang-3.7`llvm::emitOptimizationRemarkAnalysis(Ctx=0x000000010ac0cf70,
PassName=0x0000000104a67484, Fn=0x000000010ac16930, DLoc=0x00007fff5fbf9fa8,
Msg=0x00007fff5fbf9f88) + 80 at DiagnosticInfo.cpp:191
  * frame #12: 0x0000000100ef2a87
clang-3.7`llvm::LoopAccessReport::emitAnalysis(Message=0x00007fff5fbfa1b0,
TheFunction=0x000000010ac16930, TheLoop=0x000000010ad18ae0,
PassName=0x0000000104a67484) + 167 at LoopAccessAnalysis.cpp:72
    frame #13: 0x0000000101eb17ff clang-3.7`(anonymous
namespace)::LoopVectorizationLegality::emitAnalysis(this=0x00007fff5fbfa9a8,
Message=0x00007fff5fbfa1b0) + 47 at LoopVectorize.cpp:772
    frame #14: 0x0000000101eb2629 clang-3.7`(anonymous
namespace)::LoopVectorizationLegality::canVectorizeInstrs(this=0x00007fff5fbfa9a8)
+ 2089 at LoopVectorize.cpp:3552
    frame #15: 0x0000000101e9b964 clang-3.7`(anonymous
namespace)::LoopVectorizationLegality::canVectorize(this=0x00007fff5fbfa9a8) +
1076 at LoopVectorize.cpp:3392
    frame #16: 0x0000000101e9a769 clang-3.7`(anonymous
namespace)::LoopVectorize::processLoop(this=0x000000010ac39740,
L=0x000000010ad18ae0) + 2249 at LoopVectorize.cpp:1346
    frame #17: 0x0000000101e99d00 clang-3.7`(anonymous
namespace)::LoopVectorize::runOnFunction(this=0x000000010ac39740,
F=0x000000010ac16930) + 848 at LoopVectorize.cpp:1231
    frame #18: 0x00000001016440fd
clang-3.7`llvm::FPPassManager::runOnFunction(this=0x000000010ac37980,
F=0x000000010ac16930) + 413 at LegacyPassManager.cpp:1537
    frame #19: 0x0000000101644408
clang-3.7`llvm::FPPassManager::runOnModule(this=0x000000010ac37980,
M=0x000000010ac15cb0) + 104 at LegacyPassManager.cpp:1557
    frame #20: 0x0000000101644e03 clang-3.7`(anonymous
namespace)::MPPassManager::runOnModule(this=0x000000010ac22100,
M=0x000000010ac15cb0) + 1395 at LegacyPassManager.cpp:1615
    frame #21: 0x00000001016446be
clang-3.7`llvm::legacy::PassManagerImpl::run(this=0x000000010ac21d80,
M=0x000000010ac15cb0) + 302 at LegacyPassManager.cpp:1722
    frame #22: 0x0000000101645581
clang-3.7`llvm::legacy::PassManager::run(this=0x000000010ac1b1d0,
M=0x000000010ac15cb0) + 33 at LegacyPassManager.cpp:1755
    frame #23: 0x0000000102624c74 clang-3.7`(anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(this=0x00007fff5fbfb9d0,
Action=Backend_EmitObj, OS=0x000000010ac154b0) + 1508 at BackendUtil.cpp:646
    frame #24: 0x00000001026244a2
clang-3.7`clang::EmitBackendOutput(Diags=0x000000010b00da00,
CGOpts=0x000000010b00d450, TOpts=0x000000010ac0c0b0, LOpts=0x000000010ac0bfa0,
TDesc=(Data = "e-m:o-i64:64-f80:128-n8:16:32:64-S128", Length = 37),
M=0x000000010ac15cb0, Action=Backend_EmitObj, OS=0x000000010ac154b0) + 114 at
BackendUtil.cpp:663
    frame #25: 0x000000010287958f
clang-3.7`clang::BackendConsumer::HandleTranslationUnit(this=0x000000010ac15870,
C=0x000000010b036a00) + 1375 at CodeGenAction.cpp:179
    frame #26: 0x00000001033c1ccf
clang-3.7`clang::ParseAST(S=0x000000010b058c00, PrintStats=false,
SkipFunctionBodies=false) + 1263 at ParseAST.cpp:151
    frame #27: 0x000000010220ca8a
clang-3.7`clang::ASTFrontendAction::ExecuteAction(this=0x000000010ac0cf00) +
522 at FrontendAction.cpp:536
    frame #28: 0x0000000102877603
clang-3.7`clang::CodeGenAction::ExecuteAction(this=0x000000010ac0cf00) + 3987
at CodeGenAction.cpp:737
    frame #29: 0x000000010220c000
clang-3.7`clang::FrontendAction::Execute(this=0x000000010ac0cf00) + 112 at
FrontendAction.cpp:439
    frame #30: 0x0000000102197cdf
clang-3.7`clang::CompilerInstance::ExecuteAction(this=0x000000010ac0be60,
Act=0x000000010ac0cf00) + 1023 at CompilerInstance.cpp:814
    frame #31: 0x0000000102280860
clang-3.7`clang::ExecuteCompilerInvocation(Clang=0x000000010ac0be60) + 3200 at
ExecuteCompilerInvocation.cpp:222
    frame #32: 0x000000010000ff69 clang-3.7`cc1_main(Argv=ArrayRef<const char
*> at 0x00007fff5fbfd0f8, Argv0=0x00007fff5fbff728,
MainAddr=0x0000000100001bd0) + 2473 at cc1_main.cpp:110
    frame #33: 0x00000001000032f3 clang-3.7`ExecuteCC1Tool(argv=ArrayRef<const
char *> at 0x00007fff5fbfdbb8, Tool=(Data = "", Length = 0)) + 163 at
driver.cpp:369
    frame #34: 0x000000010000217c clang-3.7`main(argc_=53,
argv_=0x00007fff5fbff418) + 1244 at driver.cpp:415
    frame #35: 0x00007fff8d01a5c9 libdyld.dylib`start + 1
    frame #36: 0x00007fff8d01a5c9 libdyld.dylib`start + 1
(lldb) f 12
frame #12: 0x0000000100ef2a87
clang-3.7`llvm::LoopAccessReport::emitAnalysis(Message=0x00007fff5fbfa1b0,
TheFunction=0x000000010ac16930, TheLoop=0x000000010ad18ae0,
PassName=0x0000000104a67484) + 167 at LoopAccessAnalysis.cpp:72
   69        DebugLoc DL = TheLoop->getStartLoc();
   70        if (const Instruction *I = Message.getInstr())
   71          DL = I->getDebugLoc();
-> 72        emitOptimizationRemarkAnalysis(TheFunction->getContext(),
PassName,
   73                                       *TheFunction, DL, Message.str());
   74      }
   75      
(lldb) print I->dump()
error: cannot use arrow operator on a type
error: 1 errors parsing expression
(lldb) print Message.getInstr()->dump()
  %sum.07 = phi float [ 0.000000e+00, %for.body.lr.ph ], [ %add, %for.body ]
(lldb) print Message.getInstr()->getModule()->dump()
; ModuleID = './sum_array.c'
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.10.0"

; Function Attrs: nounwind readonly ssp uwtable
define float @sum_array(float* nocapture readonly %In, i32 %Len) #0 {
entry:
  %cmp6 = icmp sgt i32 %Len, 0, !dbg !3
  br i1 %cmp6, label %for.body.lr.ph, label %for.cond.cleanup, !dbg !8

for.body.lr.ph:                                   ; preds = %entry
  %mul = shl nsw i32 %Len, 3, !dbg !9
  %0 = sext i32 %mul to i64, !dbg !8
  br label %for.body, !dbg !8

for.cond.cleanup.loopexit:                        ; preds = %for.body
  %add.lcssa = phi float [ %add, %for.body ]
  br label %for.cond.cleanup

for.cond.cleanup:                                 ; preds =
%for.cond.cleanup.loopexit, %entry
  %sum.0.lcssa = phi float [ 0.000000e+00, %entry ], [ %add.lcssa,
%for.cond.cleanup.loopexit ]
  ret float %sum.0.lcssa, !dbg !10

for.body:                                         ; preds = %for.body.lr.ph,
%for.body
  %indvars.iv = phi i64 [ 0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]
  %sum.07 = phi float [ 0.000000e+00, %for.body.lr.ph ], [ %add, %for.body ]
  %arrayidx = getelementptr inbounds float, float* %In, i64 %indvars.iv, !dbg
!11
  %1 = load float, float* %arrayidx, align 4, !dbg !11, !tbaa !12
  %add = fadd float %sum.07, %1, !dbg !16
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1, !dbg !8
  %cmp = icmp slt i64 %indvars.iv.next, %0, !dbg !3
  br i1 %cmp, label %for.body, label %for.cond.cleanup.loopexit, !dbg !8
}

; Function Attrs: nounwind
declare void @llvm.lifetime.start(i64, i8* nocapture) #1

; Function Attrs: nounwind
declare void @llvm.lifetime.end(i64, i8* nocapture) #1

attributes #0 = { nounwind readonly ssp uwtable "less-precise-fpmad"="false"
"no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"
"no-infs-fp-math"="false" "no-nans-fp-math"="false"
"stack-protector-buffer-size"="8" "target-cpu"="core2"
"target-features"="+ssse3,+cx16,+sse,+sse2,+sse3" "unsafe-fp-math"="false"
"use-soft-float"="false" }
attributes #1 = { nounwind }

!llvm.module.flags = !{!0, !1}
!llvm.ident = !{!2}

!0 = !{i32 2, !"Debug Info Version", i32 3}
!1 = !{i32 1, !"PIC Level", i32 2}
!2 = !{!"clang version 3.7.0 (/Users/jroelofs/git/clang
a8ea585c7be49956cf28c1829414192ed43e9eda) (/Users/jroelofs/git/llvm
aedc9c7f8c9a420dd5a8e4c0ee3398c77b6df46e)"}
!3 = !DILocation(line: 3, column: 21, scope: !4)
!4 = !DISubprogram(name: "sum_array", scope: !5, file: !5, line: 1, type: !6,
isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped,
isOptimized: true, function: float (float*, i32)* @sum_array, variables: !7)
!5 = !DIFile(filename: "./sum_array.c", directory: "<snip>")
!6 = !DISubroutineType(types: !7)
!7 = !{}
!8 = !DILocation(line: 3, column: 3, scope: !4)
!9 = !DILocation(line: 3, column: 26, scope: !4)
!10 = !DILocation(line: 6, column: 3, scope: !4)
!11 = !DILocation(line: 4, column: 12, scope: !4)
!12 = !{!13, !13, i64 0}
!13 = !{!"float", !14, i64 0}
!14 = !{!"omnipotent char", !15, i64 0}
!15 = !{!"Simple C/C++ TBAA"}
!16 = !DILocation(line: 4, column: 9, scope: !4)


Another tidbit: when I pass -save-temps, the crash goes away, and no
diagnostics are printed (which is also unexpected).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150508/d9d3ff32/attachment.html>


More information about the llvm-bugs mailing list