2021-06-28 23:16:11 +08:00
; XFAIL: *
2021-06-17 23:35:17 +08:00
; RUN: opt %s -dce -S | FileCheck %s
; Tests the salvaging of GEP instructions, specifically struct indexing and
; non-constant array indexing.
%struct.S = type { i32 , i32 }
; CHECK: call void @llvm.dbg.value(metadata !DIArgList(%struct.S* %ptr, i64 %offset),
; CHECK-SAME: ![[VAR_OFFSET_PTR:[0-9]+]],
; CHECK-SAME: !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_constu, 8, DW_OP_mul, DW_OP_plus, DW_OP_plus_uconst, 4, DW_OP_stack_value))
; CHECK: ![[VAR_OFFSET_PTR]] = !DILocalVariable(name: "offset_ptr"
define void @"?foo@@YAXPEAUS@@_J@Z" ( %struct.S * %ptr , i64 %offset ) !dbg !8 {
entry:
call void @llvm.dbg.value ( metadata i64 %offset , metadata !20 , metadata !DIExpression ( ) ) , !dbg !24
call void @llvm.dbg.value ( metadata %struct.S * %ptr , metadata !21 , metadata !DIExpression ( ) ) , !dbg !24
%arrayidx = getelementptr inbounds %struct.S , %struct.S * %ptr , i64 %offset , !dbg !25
%b = getelementptr inbounds %struct.S , %struct.S * %arrayidx , i32 0 , i32 1 , !dbg !25
call void @llvm.dbg.value ( metadata i32 * %b , metadata !22 , metadata !DIExpression ( ) ) , !dbg !24
ret void , !dbg !26
}
declare void @llvm.dbg.value ( metadata , metadata , metadata )
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !3 , !4 , !5 , !6 }
!llvm.ident = ! { !7 }
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s _ 14 , file: !1 , producer: "clang version 11.0.0" , isOptimized: true , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !2 , nameTableKind: N one )
!1 = !DIFile ( filename: "salvage-gep.cpp" , directory: "/" )
!2 = ! { }
!3 = ! { i32 2 , !"CodeView" , i32 1 }
!4 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!5 = ! { i32 1 , !"wchar_size" , i32 2 }
!6 = ! { i32 7 , !"PIC Level" , i32 2 }
!7 = ! { !"clang version 11.0.0" }
!8 = distinct !DISubprogram ( name: "foo" , linkageName: "?foo@@YAXPEAUS@@_J@Z" , scope: !9 , file: !9 , line: 7 , type: !10 , scopeLine: 7 , flags: D I F l a g P r o t o t y p e d , spFlags: D I S P F l a g D e f i n i t i o n | D I S P F l a g O p t i m i z e d , unit: !0 , retainedNodes: !19 )
!9 = !DIFile ( filename: ".\\salvage-gep.cpp" , directory: "/" )
!10 = !DISubroutineType ( types: !11 )
!11 = ! { null , !12 , !18 }
!12 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !13 , size: 64 )
!13 = distinct !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "S" , file: !9 , line: 2 , size: 64 , flags: D I F l a g T y p e P a s s B y V a l u e , elements: !14 , identifier: ".?AUS@@" )
!14 = ! { !15 , !17 }
!15 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "a" , scope: !13 , file: !9 , line: 3 , baseType: !16 , size: 32 )
!16 = !DIBasicType ( name: "int" , size: 32 , encoding: D W _ A T E _ s i g n e d )
!17 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "b" , scope: !13 , file: !9 , line: 4 , baseType: !16 , size: 32 , offset: 32 )
!18 = !DIBasicType ( name: "long long int" , size: 64 , encoding: D W _ A T E _ s i g n e d )
!19 = ! { !20 , !21 , !22 }
!20 = !DILocalVariable ( name: "offset" , arg: 2 , scope: !8 , file: !9 , line: 7 , type: !18 )
!21 = !DILocalVariable ( name: "ptr" , arg: 1 , scope: !8 , file: !9 , line: 7 , type: !12 )
!22 = !DILocalVariable ( name: "offset_ptr" , scope: !8 , file: !9 , line: 8 , type: !23 )
!23 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !16 , size: 64 )
!24 = !DILocation ( line: 0 , scope: !8 )
!25 = !DILocation ( line: 8 , scope: !8 )
!26 = !DILocation ( line: 9 , scope: !8 )