[llvm] r353537 - ArgumentPromotion should copy all metadata to new Function
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 13 14:12:35 PST 2019
Sorry about that. Reproduced and testing the fix. Teresa
On Wed, Feb 13, 2019 at 2:49 AM Mikael Holmén <mikael.holmen at ericsson.com>
wrote:
> Hi Teresa,
>
> I noticed a case that starts failing with this patch.
>
> running
>
> opt -S -o - bbi-24380.ll -argpromotion -instcombine
>
> yields
>
> function declaration may not have a !dbg attachment
> void (i8*)* @0
> LLVM ERROR: Broken module found, compilation aborted!
>
>
> Regards,
> Mikael
>
> On 2/8/19 6:08 PM, Teresa Johnson via llvm-commits wrote:
> > Author: tejohnson
> > Date: Fri Feb 8 09:08:27 2019
> > New Revision: 353537
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=353537&view=rev
> > Log:
> > ArgumentPromotion should copy all metadata to new Function
> >
> > Summary:
> > ArgumentPromotion had code to specifically move the dbg metadata over to
> > the new function, but other metadata such as the function_entry_count
> > !prof metadata was not. Replace code that moved dbg metadata with a call
> > to copyMetadata. The old metadata is automatically removed when the old
> > Function is removed.
> >
> > Reviewers: davidxl
> >
> > Subscribers: llvm-commits
> >
> > Tags: #llvm
> >
> > Differential Revision: https://reviews.llvm.org/D57846
> >
> > Modified:
> > llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
> > llvm/trunk/test/Transforms/ArgumentPromotion/profile.ll
> >
> > Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=353537&r1=353536&r2=353537&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original)
> > +++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Fri Feb 8
> 09:08:27 2019
> > @@ -216,10 +216,7 @@ doPromotion(Function *F, SmallPtrSetImpl
> > Function *NF = Function::Create(NFTy, F->getLinkage(),
> F->getAddressSpace(),
> > F->getName());
> > NF->copyAttributesFrom(F);
> > -
> > - // Patch the pointer to LLVM function in debug info descriptor.
> > - NF->setSubprogram(F->getSubprogram());
> > - F->setSubprogram(nullptr);
> > + NF->copyMetadata(F, 0);
> >
> > LLVM_DEBUG(dbgs() << "ARG PROMOTION: Promoting to:" << *NF << "\n"
> > << "From: " << *F);
> >
> > Modified: llvm/trunk/test/Transforms/ArgumentPromotion/profile.ll
> > URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/ArgumentPromotion/profile.ll?rev=353537&r1=353536&r2=353537&view=diff
> >
> ==============================================================================
> > --- llvm/trunk/test/Transforms/ArgumentPromotion/profile.ll (original)
> > +++ llvm/trunk/test/Transforms/ArgumentPromotion/profile.ll Fri Feb 8
> 09:08:27 2019
> > @@ -1,17 +1,18 @@
> > ; RUN: opt -argpromotion -mem2reg -S < %s | FileCheck %s
> > target datalayout =
> "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
> >
> > -; Checks if !prof metadata is corret in deadargelim.
> > +; Checks if !prof metadata is correct after argpromotion
> >
> > define void @caller() #0 {
> > %x = alloca i32
> > store i32 42, i32* %x
> > - call void @promote_i32_ptr(i32* %x), !prof !0
> > -; CHECK: call void @promote_i32_ptr(i32 42), !prof ![[PROF:[0-9]]]
> > + call void @promote_i32_ptr(i32* %x), !prof !6
> > +; CHECK: call void @promote_i32_ptr(i32 42), !prof ![[PROF:[0-9]+]]
> > ret void
> > }
> >
> > -define internal void @promote_i32_ptr(i32* %xp) {
> > +; CHECK: define internal void @promote_i32_ptr(i32 %xp.val) !dbg
> ![[DBG:[0-9]+]] !prof ![[FUNCPROF:[0-9]+]]
> > +define internal void @promote_i32_ptr(i32* %xp) !dbg !7 !prof !12 {
> > %x = load i32, i32* %xp
> > call void @use_i32(i32 %x)
> > ret void
> > @@ -19,5 +20,22 @@ define internal void @promote_i32_ptr(i3
> >
> > declare void @use_i32(i32)
> >
> > +!llvm.dbg.cu = !{!0}
> > +!llvm.module.flags = !{!3, !4, !5}
> > +
> > +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1,
> producer: "clang version 9.0.0 (trunk 353186) (llvm/trunk 353190)",
> isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2,
> nameTableKind: None)
> > +!1 = !DIFile(filename: "profile.cc", directory: ".")
> > +!2 = !{}
> > +!3 = !{i32 2, !"Dwarf Version", i32 4}
> > +!4 = !{i32 2, !"Debug Info Version", i32 3}
> > +!5 = !{i32 1, !"wchar_size", i32 4}
> > ; CHECK: ![[PROF]] = !{!"branch_weights", i32 30}
> > -!0 = !{!"branch_weights", i32 30}
> > +!6 = !{!"branch_weights", i32 30}
> > +; CHECK: ![[DBG]] = distinct !DISubprogram(name: "promote_i32_ptr"
> > +!7 = distinct !DISubprogram(name: "promote_i32_ptr", linkageName:
> "_ZL15promote_i32_ptrPi", scope: !1, file: !1, line: 2, type: !8,
> scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit |
> DISPFlagDefinition, unit: !0, retainedNodes: !2)
> > +!8 = !DISubroutineType(types: !9)
> > +!9 = !{null, !10}
> > +!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)
> > +!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
> > +; CHECK: ![[FUNCPROF]] = !{!"function_entry_count", i64 331}
> > +!12 = !{!"function_entry_count", i64 331}
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
> >
>
--
Teresa Johnson | Software Engineer | tejohnson at google.com |
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190213/9ea53570/attachment.html>
More information about the llvm-commits
mailing list