[PATCH] D16263: [CodeGenPrepare] Also consider metadata uses
Keno Fischer via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 16 15:07:20 PST 2016
loladiro created this revision.
loladiro added reviewers: aprantl, qcolombet.
loladiro added a subscriber: llvm-commits.
loladiro set the repository for this revision to rL LLVM.
When promoting extensions to wider types, CodeGenPrepare checks whether there is only the one use, and if so does not insert a corresponding trunc instruction to compensate for the extension. However, in doing so it does not consider any uses in debug info. This is undesirable, because that way the wrong size will be passed to a dbg.* intrinsic, which is incorrect IR (and I'm in the process of adding a Verifier check for).
Repository:
rL LLVM
http://reviews.llvm.org/D16263
Files:
lib/CodeGen/CodeGenPrepare.cpp
test/CodeGen/X86/metadata-trunc.ll
Index: test/CodeGen/X86/metadata-trunc.ll
===================================================================
--- /dev/null
+++ test/CodeGen/X86/metadata-trunc.ll
@@ -0,0 +1,34 @@
+; RUN: opt -codegenprepare %s -S | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
+define void @isLegalUTF8Sequence() {
+entry:
+ %0 = load i8, i8* undef, align 1, !tbaa !9
+ %conv = sext i8 %0 to i32
+ %add = add nsw i32 %conv, 1, !dbg !16
+; CHECK-NOT: tail call void @llvm.dbg.value(metadata i64
+; CHECK: tail call void @llvm.dbg.value(metadata i32
+ tail call void @llvm.dbg.value(metadata i32 %add, i64 0, metadata !13, metadata !15), !dbg !16
+ %conv1 = sext i32 %add to i64
+ ret void
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!8}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0 (https://github.com/llvm-mirror/clang 89dda3855cda574f355e6defa1d77bdae5053994) (llvm/trunk 257826)", isOptimized: true, runtimeVersion: 0, emissionKind: 1, subprograms: !5)
+!1 = !DIFile(filename: "none", directory: ".")
+!5 = !{!6}
+!6 = distinct !DISubprogram(name: "isLegalUTF8Sequence", scope: !1, file: !1, line: 386, type: !7, isLocal: false, isDefinition: true, scopeLine: 386, flags: DIFlagPrototyped, isOptimized: true)
+!7 = distinct !DISubroutineType(types: null)
+!8 = !{i32 2, !"Debug Info Version", i32 3}
+!9 = !{!10, !10, i64 0}
+!10 = !{!"omnipotent char", !11, i64 0}
+!11 = !{!"Simple C/C++ TBAA"}
+!13 = !DILocalVariable(name: "length", scope: !6, file: !1, line: 387, type: !14)
+!14 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!15 = !DIExpression()
+!16 = !DILocation(line: 387, column: 9, scope: !6)
Index: lib/CodeGen/CodeGenPrepare.cpp
===================================================================
--- lib/CodeGen/CodeGenPrepare.cpp
+++ lib/CodeGen/CodeGenPrepare.cpp
@@ -2956,7 +2956,7 @@
// get through it and this method should not be called.
Instruction *ExtOpnd = cast<Instruction>(Ext->getOperand(0));
CreatedInstsCost = 0;
- if (!ExtOpnd->hasOneUse()) {
+ if (!ExtOpnd->hasOneUse() || ExtOpnd->isUsedByMetadata()) {
// ExtOpnd will be promoted.
// All its uses, but Ext, will need to use a truncated value of the
// promoted version.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16263.45084.patch
Type: text/x-patch
Size: 2401 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160116/a692e89a/attachment.bin>
More information about the llvm-commits
mailing list