2016-06-21 04:53:40 +08:00
|
|
|
; RUN: opt < %s -sample-profile -sample-profile-file=%S/Inputs/inline-act.prof
|
|
|
|
|
|
|
|
; Sample profile should have non-empty ACT passed to inliner
|
|
|
|
|
|
|
|
; int t;
|
|
|
|
; bool foo(int value) {
|
|
|
|
; switch(value) {
|
|
|
|
; case 0:
|
|
|
|
; case 1:
|
|
|
|
; case 3:
|
|
|
|
; return true;
|
|
|
|
; default:
|
|
|
|
; return false;
|
|
|
|
; }
|
|
|
|
; }
|
|
|
|
; void bar(int i) {
|
|
|
|
; if (foo(i))
|
|
|
|
; t *= 2;
|
|
|
|
; }
|
|
|
|
|
|
|
|
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
|
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
|
|
|
|
@t = global i32 0, align 4
|
|
|
|
|
|
|
|
; Function Attrs: nounwind uwtable
|
|
|
|
define zeroext i1 @_Z3fooi(i32) #0 {
|
|
|
|
%switch.tableidx = sub i32 %0, 0
|
|
|
|
%2 = icmp ult i32 %switch.tableidx, 4
|
|
|
|
br i1 %2, label %switch.lookup, label %3
|
|
|
|
|
|
|
|
switch.lookup: ; preds = %1
|
|
|
|
%switch.cast = trunc i32 %switch.tableidx to i4
|
|
|
|
%switch.shiftamt = mul i4 %switch.cast, 1
|
|
|
|
%switch.downshift = lshr i4 -5, %switch.shiftamt
|
|
|
|
%switch.masked = trunc i4 %switch.downshift to i1
|
|
|
|
ret i1 %switch.masked
|
|
|
|
|
|
|
|
; <label>:3: ; preds = %1
|
|
|
|
ret i1 false
|
|
|
|
}
|
|
|
|
|
|
|
|
; Function Attrs: nounwind uwtable
|
|
|
|
define void @_Z3bari(i32) #0 !dbg !9 {
|
|
|
|
%2 = call zeroext i1 @_Z3fooi(i32 %0), !dbg !10
|
|
|
|
br i1 %2, label %3, label %6, !dbg !10
|
|
|
|
|
|
|
|
; <label>:3: ; preds = %1
|
|
|
|
%4 = load i32, i32* @t, align 4
|
|
|
|
%5 = shl nsw i32 %4, 1
|
|
|
|
store i32 %5, i32* @t, align 4
|
|
|
|
br label %6
|
|
|
|
|
|
|
|
; <label>:6: ; preds = %3, %1
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
|
|
|
|
|
|
|
!llvm.dbg.cu = !{!0}
|
|
|
|
!llvm.module.flags = !{!3}
|
|
|
|
!llvm.ident = !{!4}
|
|
|
|
|
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 272227) (llvm/trunk 272226)", isOptimized: true, runtimeVersion: 0, emissionKind: NoDebug, enums: !2)
|
|
|
|
!1 = !DIFile(filename: "test.cc", directory: "./")
|
|
|
|
!2 = !{}
|
|
|
|
!3 = !{i32 2, !"Debug Info Version", i32 3}
|
|
|
|
!4 = !{!"clang version 3.9.0 (trunk 272227) (llvm/trunk 272226)"}
|
|
|
|
!6 = !DISubroutineType(types: !2)
|
[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
|
|
|
!9 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 14, type: !6, isLocal: false, isDefinition: true, scopeLine: 14, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2)
|
2016-06-21 04:53:40 +08:00
|
|
|
!10 = !DILocation(line: 15, column: 7, scope: !9)
|
|
|
|
!11 = !DILocation(line: 16, column: 7, scope: !9)
|