<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - SROA does not maintain the llvm.dbg.declare intrinsics well"
   href="https://bugs.llvm.org/show_bug.cgi?id=49872">49872</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>SROA does not maintain the llvm.dbg.declare intrinsics well
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>chenzheng1030@hotmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>```

define dso_local void @s1([1 x i8] %arg) local_unnamed_addr #0 !dbg !5 {
s1_entry:
  %_param_arg = alloca [1 x i8], align 4
  %arg.fca.0.extract = extractvalue [1 x i8] %arg, 0
  %arg.fca.0.gep = getelementptr inbounds [1 x i8], [1 x i8]* %_param_arg, i64
0, i64 0
  store i8 %arg.fca.0.extract, i8* %arg.fca.0.gep, align 4
  call void @llvm.dbg.declare(metadata [1 x i8]* %_param_arg, metadata !10,
metadata !DIExpression()), !dbg !11
  %_dconcat_res_conv_ = getelementptr inbounds [1 x i8], [1 x i8]* %_param_arg,
i64 0, i64 0, !dbg !12
  store i8 122, i8* %_dconcat_res_conv_, align 1, !dbg !12
  ret void, !dbg !13
}

declare void @llvm.dbg.declare(metadata, metadata, metadata) #5

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

!0 = !{i32 2, !"Dwarf Version", i32 3}
!1 = !{i32 2, !"Debug Info Version", i32 3}
!2 = distinct !DICompileUnit(language: DW_LANG_Fortran95, file: !3,
isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4,
splitDebugInlining: false)
!3 = !DIFile(filename: "1.f", directory: ".")
!4 = !{}
!5 = distinct !DISubprogram(name: "s1", linkageName: "s1", scope: !3, file: !3,
line: 1, type: !6, scopeLine: 1, flags: DIFlagPrototyped, spFlags:
DISPFlagDefinition, unit: !2, retainedNodes: !4)
!6 = !DISubroutineType(types: !7)
!7 = !{!8, !9}
!8 = !DIBasicType(tag: DW_TAG_unspecified_type, name: "void")
!9 = !DIStringType(name: "char string", size: 8)
!10 = !DILocalVariable(name: "arg", arg: 1, scope: !5, file: !3, type: !9)
!11 = !DILocation(line: 0, scope: !5)
!12 = !DILocation(line: 4, scope: !5)
!13 = !DILocation(line: 5, scope: !5)
!14 = distinct !DISubprogram(name: "p", linkageName: "main", scope: !3, file:
!3, line: 7, type: !15, scopeLine: 7, flags: DIFlagPrototyped, spFlags:
DISPFlagDefinition, unit: !2, retainedNodes: !4)
!15 = !DISubroutineType(types: !16)
!16 = !{!17}
!17 = !DIBasicType(name: "INTEGER", size: 32, encoding: DW_ATE_signed)
!18 = !DILocation(line: 8, scope: !14)
```

Compiling on PowerPC, we get:
```
$ clang 1.ll -O2 

clang-13: include/llvm/Support/Casting.h:269: typename llvm::cast_retty<X,
Y*>::ret_type llvm::cast(Y*) [with X = llvm::DIBasicType; Y = const
llvm::DIType; typename llvm::cast_retty<X, Y*>::ret_type = const
llvm::DIBasicType*]: Assertion `isa<X>(Val) && "cast<Ty>() argument of
incompatible type!"' failed.
PLEASE submit a bug report to <a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
...
 #8 0x00003fffa185b6c4 __assert_fail
(/opt/at12.0/lib64/power8/libc.so.6+0x3b6c4)
 #9 0x000000001404f104 llvm::DebugHandlerBase::isUnsignedDIType(llvm::DIType
const*) 
#10 0x0000000014092b80 llvm::DwarfUnit::addConstantValue(llvm::DIE&, unsigned
long, llvm::DIType const*) 
#11 0x00000000140f8e74
llvm::DwarfCompileUnit::constructVariableDIEImpl(llvm::DbgVariable const&,
bool) 
#12 0x00000000140f91e0
llvm::DwarfCompileUnit::constructVariableDIE(llvm::DbgVariable&, bool) 
```</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>