[llvm] r334090 - InstCombine: ignore debug instructions during fence combine
Tim Northover via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 6 05:46:02 PDT 2018
Author: tnorthover
Date: Wed Jun 6 05:46:02 2018
New Revision: 334090
URL: http://llvm.org/viewvc/llvm-project?rev=334090&view=rev
Log:
InstCombine: ignore debug instructions during fence combine
We should never get different CodeGen based on whether the code is being
compiled in debug mode so we must skip over @llvm.dbg.value (and similar)
calls.
Should fix at least the worst part of PR37690.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/trunk/test/Transforms/InstCombine/consecutive-fences.ll
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=334090&r1=334089&r2=334090&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Wed Jun 6 05:46:02 2018
@@ -3704,7 +3704,11 @@ Instruction *InstCombiner::visitCallInst
// Fence instruction simplification
Instruction *InstCombiner::visitFenceInst(FenceInst &FI) {
// Remove identical consecutive fences.
- if (auto *NFI = dyn_cast<FenceInst>(FI.getNextNode()))
+ Instruction *Next = FI.getNextNode();
+ while (Next != nullptr && isa<DbgInfoIntrinsic>(Next))
+ Next = Next->getNextNode();
+
+ if (auto *NFI = dyn_cast<FenceInst>(Next))
if (FI.isIdenticalTo(NFI))
return eraseInstFromFunction(FI);
return nullptr;
Modified: llvm/trunk/test/Transforms/InstCombine/consecutive-fences.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/consecutive-fences.ll?rev=334090&r1=334089&r2=334090&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/consecutive-fences.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/consecutive-fences.ll Wed Jun 6 05:46:02 2018
@@ -45,3 +45,29 @@ define void @patatino() {
fence seq_cst
ret void
}
+
+; CHECK-LABEL: define void @debug
+; CHECK-NOT: fence
+; CHECK: call void @llvm.dbg.value
+; CHECK: fence seq_cst
+define void @debug() {
+ fence seq_cst
+ tail call void @llvm.dbg.value(metadata i32 5, metadata !1, metadata !DIExpression()), !dbg !9
+ fence seq_cst
+ ret void
+}
+
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!5, !6, !7, !8}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "Me", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: null, retainedTypes: null, imports: null)
+!1 = !DILocalVariable(name: "", arg: 1, scope: !2, file: null, line: 1, type: null)
+!2 = distinct !DISubprogram(name: "debug", linkageName: "debug", scope: null, file: null, line: 0, type: null, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0)
+!3 = !DIFile(filename: "consecutive-fences.ll", directory: "")
+!5 = !{i32 2, !"Dwarf Version", i32 4}
+!6 = !{i32 2, !"Debug Info Version", i32 3}
+!7 = !{i32 1, !"wchar_size", i32 4}
+!8 = !{i32 7, !"PIC Level", i32 2}
+!9 = !DILocation(line: 0, column: 0, scope: !2)
More information about the llvm-commits
mailing list