Fangqing Du via llvm-dev
2019-Apr-23 23:13 UTC
[llvm-dev] DebugLoc info is invalid after pass 'simplifycfg'
Hi all, I'm not sure it's a bug or not. After pass 'simplifycfg', some DebugLoc info is changed, and become invalid. I use the bugpoint to reduce the case, and paste it here: ************************************************************************************************** target datalayout "e-m:e-i64:64-i128:128-i256:256-i512:512-i1024:1024-i2048:2048-i4096:4096-n8:16:32:64-S128-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" target triple = "x86_64-linux-none" ; Function Attrs: nounwind define internal fastcc float @_Z12generic_fmaxIfET_S0_S0_(float %x, float %y) unnamed_addr !dbg !3 { entry: br i1 undef, label %if.then9, label %if.else17, !dbg !7 if.then9: ; preds = %entry %call10 = call fastcc i32 @_Z13generic_isnanIfEiT_(float %y), !dbg !8 unreachable if.else17: ; preds = %entry %call18 = call fastcc i32 @_Z13generic_isnanIfEiT_(float %y), !dbg !9 unreachable } ; Function Attrs: nounwind declare dso_local fastcc i32 @_Z13generic_isnanIfEiT_(float) unnamed_addr !llvm.dbg.cu = !{!0} !llvm.module.flags = !{!2} !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 7.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly) !1 = !DIFile(filename: "test.cpp", directory: ".") !2 = !{i32 2, !"Debug Info Version", i32 3} !3 = distinct !DISubprogram(name: "generic_fmax<float>", scope: !4, file: !4, line: 19, type: !5, isLocal: false, isDefinition: true, scopeLine: 20, flags: DIFlagPrototyped, isOptimized: false, unit: !0) !4 = !DIFile(filename: "test.h", directory: ".") !5 = !DISubroutineType(types: !6) !6 = !{} !7 = !DILocation(line: 27, column: 13, scope: !3) !8 = !DILocation(line: 28, column: 5, scope: !3) !9 = !DILocation(line: 34, column: 13, scope: !3) ************************************************************************************************** And after pass 'simplifycfg', the DebugLoc info attached to the call instruction will be changed into '*!7 = !DILocation(line: 0, scope: !3)*', which is invalid. *after:* ************************************************************************************************** target datalayout "e-m:e-i64:64-i128:128-i256:256-i512:512-i1024:1024-i2048:2048-i4096:4096-n8:16:32:64-S128-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024" target triple = "x86_64-linux-none" define internal fastcc float @_Z12generic_fmaxIfET_S0_S0_(float %x, float %y) unnamed_addr !dbg !3 { entry: %call10 = call fastcc i32 @_Z13generic_isnanIfEiT_(float %y), !dbg !7 unreachable } declare dso_local fastcc i32 @_Z13generic_isnanIfEiT_(float) unnamed_addr !llvm.dbg.cu = !{!0} !llvm.module.flags = !{!2} !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 7.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly) !1 = !DIFile(filename: "test.cpp", directory: ".") !2 = !{i32 2, !"Debug Info Version", i32 3} !3 = distinct !DISubprogram(name: "generic_fmax<float>", scope: !4, file: !4, line: 19, type: !5, isLocal: false, isDefinition: true, scopeLine: 20, flags: DIFlagPrototyped, isOptimized: false, unit: !0) !4 = !DIFile(filename: "test.h", directory: ".") !5 = !DISubroutineType(types: !6) !6 = !{} !7 = !DILocation(line: 0, scope: !3) ************************************************************************************************** So can we just keep the original DebugLoc info for the call instruction? Thanks, Fangqing Xilinx Inc. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190423/7951ef39/attachment.html>
Jeremy Morse via llvm-dev
2019-Apr-24 10:38 UTC
[llvm-dev] DebugLoc info is invalid after pass 'simplifycfg'
Hi Fangqing, On Wed, Apr 24, 2019 at 12:14 AM Fangqing Du via llvm-dev <llvm-dev at lists.llvm.org> wrote:> I'm not sure it's a bug or not. > After pass 'simplifycfg', some DebugLoc info is changed, and become invalid. > I use the bugpoint to reduce the case, and paste it here:[...]> And after pass 'simplifycfg', the DebugLoc info attached to the call instruction will be changed into '!7 = !DILocation(line: 0, scope: !3)', which is invalid.The use of a zero line number here is deliberate, as implemented by getMergedLocation [0]. It signifies that the location is compiler generated, and doesn't correspond to a specific line number in the original program.> So can we just keep the original DebugLoc info for the call instruction?SimplifyCFG is merging two call instructions into one -- however they have two different DebugLocs, so we would have to pick one of them. If a debugger then breaks on that call instruction, the line number will suggest to the developer that the branch condition was either true or false, which would be misleading because the call instruction now executes regardless of the branch condition. Using a zero line number avoids misleading the developer; it isn't ideal, but avoids mistruths. [0] https://github.com/llvm/llvm-project/blob/4e6b8579221c67b83901bcc621d330e7e99a9294/llvm/lib/IR/DebugInfoMetadata.cpp#L75 -- Thanks, Jeremy