[llvm] r360818 - [codeview] Fix SDNode representation of annotation labels
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed May 15 14:46:05 PDT 2019
Author: rnk
Date: Wed May 15 14:46:05 2019
New Revision: 360818
URL: http://llvm.org/viewvc/llvm-project?rev=360818&view=rev
Log:
[codeview] Fix SDNode representation of annotation labels
Before this change, they were erroneously constructed with the EH_LABEL
SDNode opcode, which caused other passes to interact with them in
incorrect ways. See the FIXME about fastisel that this addresses in the
existing test case.
Fixes PR41890
Modified:
llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
llvm/trunk/test/CodeGen/X86/label-annotation.ll
Modified: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h?rev=360818&r1=360817&r2=360818&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h (original)
+++ llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h Wed May 15 14:46:05 2019
@@ -2071,8 +2071,10 @@ class LabelSDNode : public SDNode {
MCSymbol *Label;
- LabelSDNode(unsigned Order, const DebugLoc &dl, MCSymbol *L)
- : SDNode(ISD::EH_LABEL, Order, dl, getSDVTList(MVT::Other)), Label(L) {}
+ LabelSDNode(unsigned Opcode, unsigned Order, const DebugLoc &dl, MCSymbol *L)
+ : SDNode(Opcode, Order, dl, getSDVTList(MVT::Other)), Label(L) {
+ assert(LabelSDNode::classof(this) && "not a label opcode");
+ }
public:
MCSymbol *getLabel() const { return Label; }
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=360818&r1=360817&r2=360818&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Wed May 15 14:46:05 2019
@@ -1073,6 +1073,7 @@ void AsmPrinter::EmitFunctionBody() {
case TargetOpcode::LOCAL_ESCAPE:
emitFrameAlloc(MI);
break;
+ case TargetOpcode::ANNOTATION_LABEL:
case TargetOpcode::EH_LABEL:
case TargetOpcode::GC_LABEL:
OutStreamer->EmitLabel(MI.getOperand(0).getMCSymbol());
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=360818&r1=360817&r2=360818&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Wed May 15 14:46:05 2019
@@ -1792,7 +1792,8 @@ SDValue SelectionDAG::getLabelNode(unsig
if (SDNode *E = FindNodeOrInsertPos(ID, IP))
return SDValue(E, 0);
- auto *N = newSDNode<LabelSDNode>(dl.getIROrder(), dl.getDebugLoc(), Label);
+ auto *N =
+ newSDNode<LabelSDNode>(Opcode, dl.getIROrder(), dl.getDebugLoc(), Label);
createOperands(N, Ops);
CSEMap.InsertNode(N, IP);
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp?rev=360818&r1=360817&r2=360818&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp Wed May 15 14:46:05 2019
@@ -174,6 +174,7 @@ std::string SDNode::getOperationName(con
case ISD::INLINEASM: return "inlineasm";
case ISD::INLINEASM_BR: return "inlineasm_br";
case ISD::EH_LABEL: return "eh_label";
+ case ISD::ANNOTATION_LABEL: return "annotation_label";
case ISD::HANDLENODE: return "handlenode";
// Unary operators
Modified: llvm/trunk/test/CodeGen/X86/label-annotation.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/label-annotation.ll?rev=360818&r1=360817&r2=360818&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/label-annotation.ll (original)
+++ llvm/trunk/test/CodeGen/X86/label-annotation.ll Wed May 15 14:46:05 2019
@@ -1,6 +1,7 @@
-; RUN: llc < %s | FileCheck %s
-; FIXME: fastisel screws up the order here.
-; RUNX: llc -O0 < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-windows-msvc -O0 < %s | FileCheck %s
+; RUN: llc -mtriple=i686-windows-msvc < %s | FileCheck %s
+; RUN: llc -mtriple=i686-windows-msvc -O0 < %s | FileCheck %s
; Source to regenerate:
; $ clang --target=x86_64-windows-msvc -S annotation.c -g -gcodeview -o t.ll \
@@ -11,14 +12,14 @@
; __annotation(L"a1", L"a2");
; g();
; }
-
-; ModuleID = 'annotation.c'
-source_filename = "annotation.c"
-target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
-target triple = "x86_64-pc-windows-msvc19.0.24215"
+; void trapit() {
+; __annotation(L"foo", L"bar");
+; asm volatile ("int $0x2C");
+; __builtin_unreachable();
+; }
; Function Attrs: nounwind uwtable
-define void @f() #0 !dbg !8 {
+define dso_local void @f() #0 !dbg !8 {
entry:
call void @g(), !dbg !11
call void @llvm.codeview.annotation(metadata !12), !dbg !13
@@ -26,48 +27,84 @@ entry:
ret void, !dbg !15
}
-; CHECK-LABEL: f: # @f
-; CHECK: callq g
-; CHECK: .Lannotation0:
-; CHECK: callq g
-; CHECK: retq
+declare dso_local void @g() #1
+
+
+; CHECK-LABEL: {{_?f: # @f}}
+; CHECK: {{call[ql] _?g}}
+; CHECK: {{\.?}}Lannotation0:
+; CHECK: {{call[ql] _?g}}
+; CHECK: {{ret[ql]}}
+
+
+; Function Attrs: inaccessiblememonly noduplicate nounwind
+declare void @llvm.codeview.annotation(metadata) #2
+
+; Function Attrs: nounwind uwtable
+define dso_local void @trapit() #0 !dbg !16 {
+entry:
+ call void @llvm.codeview.annotation(metadata !17), !dbg !18
+ call void asm sideeffect "int $$0x2C", "~{dirflag},~{fpsr},~{flags}"() #3, !dbg !19, !srcloc !20
+ unreachable, !dbg !21
+}
+
+
+; CHECK-LABEL: {{_?trapit: # @trapit}}
+; CHECK: {{\.?}}Lannotation1:
+; CHECK: int $44
+
; CHECK-LABEL: .short 4423 # Record kind: S_GPROC32_ID
; CHECK: .short 4121 # Record kind: S_ANNOTATION
-; CHECK-NEXT: .secrel32 .Lannotation0
-; CHECK-NEXT: .secidx .Lannotation0
+; CHECK-NEXT: .secrel32 {{\.?}}Lannotation0
+; CHECK-NEXT: .secidx {{\.?}}Lannotation0
; CHECK-NEXT: .short 2
; CHECK-NEXT: .asciz "a1"
; CHECK-NEXT: .asciz "a2"
; CHECK-LABEL: .short 4431 # Record kind: S_PROC_ID_END
-declare void @g() #1
-; Function Attrs: nounwind
-declare void @llvm.codeview.annotation(metadata) #2
+; CHECK-LABEL: .short 4423 # Record kind: S_GPROC32_ID
+; CHECK: .short 4121 # Record kind: S_ANNOTATION
+; CHECK-NEXT: .secrel32 {{\.?}}Lannotation1
+; CHECK-NEXT: .secidx {{\.?}}Lannotation1
+; CHECK-NEXT: .short 2
+; CHECK-NEXT: .asciz "foo"
+; CHECK-NEXT: .asciz "bar"
+
+; CHECK-LABEL: .short 4431 # Record kind: S_PROC_ID_END
+
+
-attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "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" "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 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="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 #2 = { nounwind }
+attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "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"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="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"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #2 = { inaccessiblememonly noduplicate nounwind }
+attributes #3 = { nounwind }
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!3, !4, !5, !6}
!llvm.ident = !{!7}
-!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
-!1 = !DIFile(filename: "annotation.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "51164221112d8a5baa55a995027e4ba5")
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0 (git at github.com:llvm/llvm-project.git 7f9a008a2db285aca57bfa0c09858c9527a7aa98)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
+!1 = !DIFile(filename: "t.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild", checksumkind: CSK_MD5, checksum: "066b1dde2a08455e4d345baa8a920b56")
!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 6.0.0 "}
-!8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !2)
+!7 = !{!"clang version 9.0.0 (git at github.com:llvm/llvm-project.git 7f9a008a2db285aca57bfa0c09858c9527a7aa98)"}
+!8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 2, type: !9, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
!9 = !DISubroutineType(types: !10)
!10 = !{null}
-!11 = !DILocation(line: 3, column: 3, scope: !8)
+!11 = !DILocation(line: 3, scope: !8)
!12 = !{!"a1", !"a2"}
-!13 = !DILocation(line: 4, column: 3, scope: !8)
-!14 = !DILocation(line: 5, column: 3, scope: !8)
-!15 = !DILocation(line: 6, column: 1, scope: !8)
+!13 = !DILocation(line: 4, scope: !8)
+!14 = !DILocation(line: 5, scope: !8)
+!15 = !DILocation(line: 6, scope: !8)
+!16 = distinct !DISubprogram(name: "trapit", scope: !1, file: !1, line: 7, type: !9, scopeLine: 7, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
+!17 = !{!"foo", !"bar"}
+!18 = !DILocation(line: 8, scope: !16)
+!19 = !DILocation(line: 9, scope: !16)
+!20 = !{i32 149}
+!21 = !DILocation(line: 10, scope: !16)
More information about the llvm-commits
mailing list