[PATCH] D41435: [InstCombine] Add debug location to new caller.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 20 03:43:59 PST 2017


fhahn created this revision.
fhahn added reviewers: rnk, aprantl, majnemer.
Herald added a subscriber: JDevlieghere.

We already add attributes, calling convention and tail call info, so I
think it would make sense to also preserve the debug location.


https://reviews.llvm.org/D41435

Files:
  lib/Transforms/InstCombine/InstCombineCalls.cpp
  test/Transforms/InstCombine/2011-09-03-Trampoline.ll


Index: test/Transforms/InstCombine/2011-09-03-Trampoline.ll
===================================================================
--- test/Transforms/InstCombine/2011-09-03-Trampoline.ll
+++ test/Transforms/InstCombine/2011-09-03-Trampoline.ll
@@ -5,18 +5,18 @@
 declare i32 @f(i8 * nest, i32)
 
 ; Most common case
-define i32 @test0(i32 %n) {
+define i32 @test0(i32 %n) !dbg !4 {
   %alloca = alloca [10 x i8], align 16
   %gep = getelementptr [10 x i8], [10 x i8]* %alloca, i32 0, i32 0
   call void @llvm.init.trampoline(i8* %gep, i8* bitcast (i32 (i8*, i32)* @f to i8*),
                                   i8* null)
   %tramp = call i8* @llvm.adjust.trampoline(i8* %gep)
   %function = bitcast i8* %tramp to i32(i32)*
-  %ret = call i32 %function(i32 %n)
+  %ret = call i32 %function(i32 %n), !dbg !10
   ret i32 %ret
 
-; CHECK: define i32 @test0(i32 %n) {
-; CHECK: %ret = call i32 @f(i8* nest null, i32 %n)
+; CHECK: define i32 @test0(i32 %n) !dbg !4 {
+; CHECK: %ret = call i32 @f(i8* nest null, i32 %n), !dbg !10
 }
 
 define i32 @test1(i32 %n, i8* %trampmem) {
@@ -85,3 +85,18 @@
 ; CHECK: %ret1 = call i32 @f(i8* nest null, i32 %n)
 ; CHECK: %ret2 = call i32 @f(i8* nest null, i32 %n)
 }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.0 (trunk 127710)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2)
+!1 = !DIFile(filename: "string.h", directory: "Game")
+!2 = !{}
+!3 = !{i32 1, !"Debug Info Version", i32 3}
+!4 = distinct !DISubprogram(name: "passthru", scope: !1, file: !1, line: 79, type: !5, isLocal: true, isDefinition: true, scopeLine: 79, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !8)
+!5 = !DISubroutineType(types: !6)
+!6 = !{!7}
+!7 = !DIDerivedType(tag: DW_TAG_pointer_type, scope: !0, baseType: null, size: 64, align: 64)
+!8 = !{!9}
+!9 = !DILocalVariable(name: "a", arg: 1, scope: !4, file: !1, line: 78, type: !7)
+!10 = !DILocation(line: 78, column: 28, scope: !4)
Index: lib/Transforms/InstCombine/InstCombineCalls.cpp
===================================================================
--- lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -4394,6 +4394,7 @@
             cast<CallInst>(Caller)->getCallingConv());
         cast<CallInst>(NewCaller)->setAttributes(NewPAL);
       }
+      NewCaller->setDebugLoc(Caller->getDebugLoc());
 
       return NewCaller;
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41435.127680.patch
Type: text/x-patch
Size: 2538 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171220/1f45dea6/attachment.bin>


More information about the llvm-commits mailing list