[llvm-bugs] [Bug 35609] New: clang -emit-llvm produces illegal output (not accepted by opt)

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Dec 10 09:01:06 PST 2017


https://bugs.llvm.org/show_bug.cgi?id=35609

            Bug ID: 35609
           Summary: clang -emit-llvm produces illegal output (not accepted
                    by opt)
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: post+llvm at ralfj.de
                CC: llvm-bugs at lists.llvm.org

## Steps to reproduce:

Compile the following program with `clang -emit-llvm`:

```
void test(void (*f)()) {
}
```

Try to run the resulting IR through `opt`.

## Expected behavior:

`opt` should accept the IR generated by clang.

## Actual behavior:

`opt` rejects the IR as being invalid:
```
opt-6.0: cpp-6.ll:6:25: error: expected type
define void @test(void (*)())(void ()*) #0 !dbg !7 {
                        ^
```

For reference, the IR is
```
; ModuleID =
'/tmp/compiler-explorer-compiler1171110-53-upsl4.lwnj7/example.cpp'
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: noinline nounwind optnone uwtable
define void @test(void (*)())(void ()*) #0 !dbg !7 {
  %2 = alloca void ()*, align 8
  store void ()* %0, void ()** %2, align 8
  call void @llvm.dbg.declare(metadata void ()** %2, metadata !13, metadata
!DIExpression()), !dbg !14
  ret void, !dbg !15
}

; Function Attrs: nounwind readnone speculatable
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1

attributes #0 = { noinline nounwind optnone uwtable
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false"
"less-precise-fpmad"="false" "no-frame-pointer-elim"="true"
"no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false"
"no-jump-tables"="false" "no-nans-fp-math"="false"
"no-signed-zeros-fp-math"="false" "no-trapping-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" }
attributes #1 = { nounwind readnone speculatable }

!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5}
!llvm.ident = !{!6}

!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer:
"clang version 6.0.0 (trunk 320285)", isOptimized: false, runtimeVersion: 0,
emissionKind: FullDebug, enums: !2)
!1 = !DIFile(filename:
"/tmp/compiler-explorer-compiler1171110-53-upsl4.lwnj7/example.cpp", directory:
"/compiler-explorer")
!2 = !{}
!3 = !{i32 2, !"Dwarf Version", i32 4}
!4 = !{i32 2, !"Debug Info Version", i32 3}
!5 = !{i32 1, !"wchar_size", i32 4}
!6 = !{!"clang version 6.0.0 (trunk 320285)"}
!7 = distinct !DISubprogram(name: "test", linkageName: "test(void (*)())",
scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true,
scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables:
!2)
!8 = !DISubroutineType(types: !9)
!9 = !{null, !10}
!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)
!11 = !DISubroutineType(types: !12)
!12 = !{null}
!13 = !DILocalVariable(name: "f", arg: 1, scope: !7, file: !1, line: 1, type:
!10)
!14 = !DILocation(line: 1, column: 18, scope: !7)
!15 = !DILocation(line: 2, column: 1, scope: !7)
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171210/a877783c/attachment.html>


More information about the llvm-bugs mailing list