summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2019-02-28 01:11:12 +0000
committerEric Christopher <echristo@gmail.com>2019-02-28 01:11:12 +0000
commit07944353fcac9bf78b210a294872c7a67a6d8ca1 (patch)
tree9610185fd154730d26adcc8fb3a434bf73db80f6
parent240315aa64a2783b93bbfc23f35ec9e17b080f32 (diff)
downloadbcm5719-llvm-07944353fcac9bf78b210a294872c7a67a6d8ca1.tar.gz
bcm5719-llvm-07944353fcac9bf78b210a294872c7a67a6d8ca1.zip
Temporarily revert "ArgumentPromotion should copy all metadata to new Function" and the dependent patch "Refine ArgPromotion metadata handling" as they're causing segfaults in argument promotion.
This reverts commits r354032 and r353537. llvm-svn: 355060
-rw-r--r--llvm/lib/Transforms/IPO/ArgumentPromotion.cpp7
-rw-r--r--llvm/test/Transforms/ArgumentPromotion/dbg2.ll31
-rw-r--r--llvm/test/Transforms/ArgumentPromotion/profile.ll28
3 files changed, 9 insertions, 57 deletions
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index feda27424c2..13df8280f34 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -216,8 +216,10 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
Function *NF = Function::Create(NFTy, F->getLinkage(), F->getAddressSpace(),
F->getName());
NF->copyAttributesFrom(F);
- NF->copyMetadata(F, 0);
- F->clearMetadata();
+
+ // Patch the pointer to LLVM function in debug info descriptor.
+ NF->setSubprogram(F->getSubprogram());
+ F->setSubprogram(nullptr);
LLVM_DEBUG(dbgs() << "ARG PROMOTION: Promoting to:" << *NF << "\n"
<< "From: " << *F);
@@ -472,7 +474,6 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
std::advance(I2, ArgIndices.size());
}
- assert(F->isDeclaration());
return NF;
}
diff --git a/llvm/test/Transforms/ArgumentPromotion/dbg2.ll b/llvm/test/Transforms/ArgumentPromotion/dbg2.ll
deleted file mode 100644
index ecec7d7a5dc..00000000000
--- a/llvm/test/Transforms/ArgumentPromotion/dbg2.ll
+++ /dev/null
@@ -1,31 +0,0 @@
-; RUN: opt < %s -argpromotion -instcombine -S | FileCheck %s
-
-%f_ty = type void (i8*)*
-
-define void @foo() {
-entry:
- %f_p = getelementptr inbounds %f_ty, %f_ty* null, i32 0
- store %f_ty @bar, %f_ty* %f_p, align 1
- ret void
-}
-
-define internal void @bar(i8*) !dbg !1 {
-entry:
- ret void
-}
-
-; The new copy should get the !dbg metadata
-; CHECK: define internal void @bar() !dbg
-; The old copy should now be a declaration without any !dbg metadata
-; CHECK-NOT: declare dso_local void @0(i8*) !dbg
-; CHECK: declare dso_local void @0(i8*)
-
-!llvm.dbg.cu = !{}
-!llvm.module.flags = !{!0}
-
-!0 = !{i32 2, !"Debug Info Version", i32 3}
-!1 = distinct !DISubprogram(name: "bar", scope: !2, file: !2, line: 14, type: !3, scopeLine: 14, spFlags: DISPFlagDefinition, unit: !5)
-!2 = !DIFile(filename: "foo.c", directory: "/bar")
-!3 = !DISubroutineType(types: !4)
-!4 = !{}
-!5 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "My Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, nameTableKind: None)
diff --git a/llvm/test/Transforms/ArgumentPromotion/profile.ll b/llvm/test/Transforms/ArgumentPromotion/profile.ll
index 64d424cd2cc..f667f9ea2c2 100644
--- a/llvm/test/Transforms/ArgumentPromotion/profile.ll
+++ b/llvm/test/Transforms/ArgumentPromotion/profile.ll
@@ -1,18 +1,17 @@
; 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 correct after argpromotion
+; Checks if !prof metadata is corret in deadargelim.
define void @caller() #0 {
%x = alloca i32
store i32 42, i32* %x
- call void @promote_i32_ptr(i32* %x), !prof !6
-; CHECK: call void @promote_i32_ptr(i32 42), !prof ![[PROF:[0-9]+]]
+ call void @promote_i32_ptr(i32* %x), !prof !0
+; CHECK: call void @promote_i32_ptr(i32 42), !prof ![[PROF:[0-9]]]
ret void
}
-; 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 {
+define internal void @promote_i32_ptr(i32* %xp) {
%x = load i32, i32* %xp
call void @use_i32(i32 %x)
ret void
@@ -20,22 +19,5 @@ define internal void @promote_i32_ptr(i32* %xp) !dbg !7 !prof !12 {
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}
-!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}
+!0 = !{!"branch_weights", i32 30}
OpenPOWER on IntegriCloud