[SCEV] Fix ScalarEvolution tests under NPM
Many tests use opt's -analyze feature, which does not translate well to
NPM and has better alternatives. The alternative here is to explicitly
add a pass that calls ScalarEvolution::print().
The legacy pass manager RUNs aren't changing, but they are now pinned to
the legacy pass manager. For each legacy pass manager RUN, I added a
corresponding NPM RUN using the 'print<scalar-evolution>' pass. For
compatibility with update_analyze_test_checks.py and existing test
CHECKs, 'print<scalar-evolution>' now prints what -analyze prints per
function.
This was generated by the following Python script and failures were
manually fixed up:
import sys
for i in sys.argv:
with open(i, 'r') as f:
s = f.read()
with open(i, 'w') as f:
for l in s.splitlines():
if "RUN:" in l and ' -analyze ' in l and '\\' not in l:
f.write(l.replace(' -analyze ', ' -analyze -enable-new-pm=0 '))
f.write('\n')
f.write(l.replace(' -analyze ', ' -disable-output ').replace(' -scalar-evolution ', ' "-passes=print<scalar-evolution>" ').replace(" | ", " 2>&1 | "))
f.write('\n')
else:
f.write(l)
There are a couple failures still in ScalarEvolution under NPM, but
those are due to other unrelated naming conflicts.
Reviewed By: asbirlea
Differential Revision: https://reviews.llvm.org/D83798
2020-07-17 02:09:47 +08:00
; RUN: opt -analyze -enable-new-pm=0 -scalar-evolution < %s | FileCheck %s
; RUN: opt -disable-output "-passes=print<scalar-evolution>" < %s 2>&1 | FileCheck %s
2016-06-09 01:48:36 +08:00
; Make sure poison value tracking works in the presence of @llvm.dbg
; intrinsics. Unfortunately, I was not able to reduce this file
; further while still keeping the debug info well formed.
define void @foo ( i32 %n , i32 * %arr ) !dbg !7 {
; CHECK-LABEL: Classifying expressions for: @foo
entry:
%cmp1 = icmp slt i32 0 , %n , !dbg !12
br i1 %cmp1 , label %for.body.lr.ph , label %for.end , !dbg !15
for.body.lr.ph: ; preds = %entry
br label %for.body , !dbg !15
for.body: ; preds = %for.inc, %for.body.lr.ph
%i.02 = phi i32 [ 0 , %for.body.lr.ph ] , [ %inc , %for.inc ]
%add = add nsw i32 %i.02 , 50 , !dbg !16
call void @llvm.dbg.value ( metadata i32 %add , i64 0 , metadata !18 , metadata !19 ) , !dbg !20
%idxprom = sext i32 %add to i64 , !dbg !21
; CHECK: %idxprom = sext i32 %add to i64
; CHECK-NEXT: --> {50,+,1}<nuw><nsw><%for.body>
%arrayidx = getelementptr inbounds i32 , i32 * %arr , i64 %idxprom , !dbg !21
store i32 100 , i32 * %arrayidx , align 4 , !dbg !22
br label %for.inc , !dbg !23
for.inc: ; preds = %for.body
%inc = add nsw i32 %i.02 , 1 , !dbg !24
%cmp = icmp slt i32 %inc , %n , !dbg !12
br i1 %cmp , label %for.body , label %for.cond.for.end_crit_edge , !dbg !15 , !llvm.loop !25
for.cond.for.end_crit_edge: ; preds = %for.inc
br label %for.end , !dbg !15
for.end: ; preds = %for.cond.for.end_crit_edge, %entry
ret void , !dbg !27
}
; Function Attrs: nounwind readnone
declare void @llvm.dbg.value ( metadata , i64 , metadata , metadata )
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !3 , !4 , !5 }
!llvm.ident = ! { !6 }
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C 99 , file: !1 , producer: "clang version 3.9.0 (llvm/trunk 271857)" , isOptimized: false , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !2 )
!1 = !DIFile ( filename: "x.c" , directory: "/Users/sanjoy/Code/clang/build/debug+asserts-x86" )
!2 = ! { }
!3 = ! { i32 2 , !"Dwarf Version" , i32 2 }
!4 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!5 = ! { i32 1 , !"PIC Level" , i32 2 }
!6 = ! { !"clang version 3.9.0 (llvm/trunk 271857)" }
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
In order to set breakpoints on labels and list source code around
labels, we need collect debug information for labels, i.e., label
name, the function label belong, line number in the file, and the
address label located. In order to keep these information in LLVM
IR and to allow backend to generate debug information correctly.
We create a new kind of metadata for labels, DILabel. The format
of DILabel is
!DILabel(scope: !1, name: "foo", file: !2, line: 3)
We hope to keep debug information as much as possible even the
code is optimized. So, we create a new kind of intrinsic for label
metadata to avoid the metadata is eliminated with basic block.
The intrinsic will keep existing if we keep it from optimized out.
The format of the intrinsic is
llvm.dbg.label(metadata !1)
It has only one argument, that is the DILabel metadata. The
intrinsic will follow the label immediately. Backend could get the
label metadata through the intrinsic's parameter.
We also create DIBuilder API for labels to be used by Frontend.
Frontend could use createLabel() to allocate DILabel objects, and use
insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR.
Differential Revision: https://reviews.llvm.org/D45024
Patch by Hsiangkai Wang.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
!7 = distinct !DISubprogram ( name: "foo" , scope: !1 , file: !1 , line: 1 , type: !8 , isLocal: false , isDefinition: true , scopeLine: 1 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !0 , retainedNodes: !2 )
2016-06-09 01:48:36 +08:00
!8 = !DISubroutineType ( types: !9 )
!9 = ! { null , !10 , !11 }
!10 = !DIBasicType ( name: "int" , size: 32 , align: 32 , encoding: D W _ A T E _ s i g n e d )
!11 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !10 , size: 64 , align: 64 )
!12 = !DILocation ( line: 2 , column: 24 , scope: !13 )
!13 = distinct !DILexicalBlock ( scope: !14 , file: !1 , line: 2 , column: 6 )
!14 = distinct !DILexicalBlock ( scope: !7 , file: !1 , line: 2 , column: 6 )
!15 = !DILocation ( line: 2 , column: 6 , scope: !14 )
!16 = !DILocation ( line: 3 , column: 14 , scope: !17 )
!17 = distinct !DILexicalBlock ( scope: !13 , file: !1 , line: 2 , column: 34 )
!18 = !DILocalVariable ( name: "k" , scope: !17 , file: !1 , line: 3 , type: !10 )
!19 = !DIExpression ( )
!20 = !DILocation ( line: 3 , column: 8 , scope: !17 )
!21 = !DILocation ( line: 4 , column: 4 , scope: !17 )
!22 = !DILocation ( line: 4 , column: 11 , scope: !17 )
!23 = !DILocation ( line: 5 , column: 6 , scope: !17 )
!24 = !DILocation ( line: 2 , column: 30 , scope: !13 )
!25 = distinct ! { !25 , !26 }
!26 = !DILocation ( line: 2 , column: 6 , scope: !7 )
!27 = !DILocation ( line: 6 , column: 1 , scope: !7 )