New user self-registration is disabled due to spam. For an account please email bugs-admin@lists.llvm.org with your e-mail address and full name.

Bug 24199 - Crash in llvm::MachineTraceMetrics::Ensemble::computeCrossBlockCriticalPath
Summary: Crash in llvm::MachineTraceMetrics::Ensemble::computeCrossBlockCriticalPath
Status: RESOLVED FIXED
Alias: None
Product: new-bugs
Classification: Unclassified
Component: new bugs (show other bugs)
Version: trunk
Hardware: PC All
: P normal
Assignee: Sanjay Patel
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-21 11:25 PDT by Robert Lougher
Modified: 2015-07-24 10:49 PDT (History)
2 users (show)

See Also:
Fixed By Commit(s):


Attachments
Test case (676 bytes, text/plain)
2015-07-21 11:25 PDT, Robert Lougher
Details
Crash stacktrace (3.67 KB, text/plain)
2015-07-21 11:28 PDT, Robert Lougher
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Lougher 2015-07-21 11:25:48 PDT
Created attachment 14622 [details]
Test case

The attached reduced test case (test.cpp) causes a crash in
llvm::MachineTraceMetrics::Ensemble::computeCrossBlockCriticalPath.

Compile with:

clang test.cpp -c -ffast-math -O3 -g

Stack trace attached.

Manually bisecting indicates that it started with r241515:

--------------------
[x86] extend machine combiner reassociation optimization to SSE scalar adds

Extend the reassociation optimization of http://reviews.llvm.org/rL240361 (D10460)
to SSE scalar FP SP adds in addition to AVX scalar FP SP adds.

With the 'switch' in place, we can trivially add other opcodes and test cases in
future patches.

Differential Revision: http://reviews.llvm.org/D10975
--------------------
Comment 1 Robert Lougher 2015-07-21 11:28:43 PDT
Created attachment 14623 [details]
Crash stacktrace
Comment 2 Sanjay Patel 2015-07-21 12:04:24 PDT
Thanks, Robert. I suspect my change uncovered some latent bug here...very interesting that it only fails with debug info included.
Comment 3 Sanjay Patel 2015-07-21 17:38:23 PDT
Reduced test case that fails with "llc -enable-unsafe-fp-math" targeting x86-64:

%struct.A = type { float, float }

declare void @bar(float)
declare void @foo(%struct.A*)

define void @fn() {
entry:
  %i = alloca %struct.A, align 8
  %tobool = icmp ne i32 undef, 0
  br i1 undef, label %if.end, label %if.then

if.then:
  br label %if.end

if.end:
  %h = phi float [ 0.0, %if.then ], [ 4.0, %entry ]
  call void @foo(%struct.A* nonnull undef)
  tail call void @llvm.dbg.value(metadata %struct.A* undef, i64 0, metadata !5, metadata !4), !dbg !6
  tail call void @llvm.dbg.value(metadata float %h, i64 0, metadata !5, metadata !4), !dbg !6
  %n0 = load float, float* undef, align 4
  %mul = fmul fast float %n0, %h
  %add = fadd fast float %mul, 1.0
  tail call void @llvm.dbg.value(metadata %struct.A* undef, i64 0, metadata !5, metadata !4), !dbg !6
  tail call void @llvm.dbg.value(metadata float %add, i64 0, metadata !5, metadata !4), !dbg !6
  %add.i = fadd fast float %add, %n0
  store float %add.i, float* undef, align 4
  %n1 = bitcast %struct.A* %i to i8*
  call void @llvm.lifetime.start(i64 16, i8* %n1)
  %n2 = load <2 x float>, <2 x float>* undef, align 8
  %conv = uitofp i1 %tobool to float
  %bitcast = extractelement <2 x float> %n2, i32 0
  %factor = fmul fast float %bitcast, 2.0
  %add3 = fadd fast float %factor, %conv
  call void @bar(float %add3)
  ret void
}

declare void @llvm.lifetime.start(i64, i8* nocapture)
declare void @llvm.dbg.value(metadata, i64, metadata, metadata)

!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2}

!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, isOptimized: true, runtimeVersion: 0, emissionKind: 1)
!1 = !DIFile(filename: "24199.cpp", directory: "/bin")
!2 = !{i32 2, !"Debug Info Version", i32 3}
!3 = !DISubprogram(linkageName: "foo", file: !1, line: 18, isLocal: false, isDefinition: true, scopeLine: 18, function: void (%struct.A*)* @foo)
!4 = !DIExpression()
!5 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "this", arg: 1, scope: !3, flags: DIFlagArtificial | DIFlagObjectPointer)
!6 = !DILocation(line: 0, scope: !3)
Comment 4 Sanjay Patel 2015-07-22 14:30:59 PDT
Patch posted for review:
http://reviews.llvm.org/D11423
Comment 5 Sanjay Patel 2015-07-24 10:49:48 PDT
http://reviews.llvm.org/rL243057