From cc8923b4e4a0ccdf4867c8517031d09c7e41be74 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Sat, 7 May 2016 02:10:59 +0000 Subject: [PATCH] Revert r268832 "Refactor stripDebugInfo(Function) to handle intrinsic" It breaks many bots git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268837 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/DebugInfo.cpp | 34 +++++++++------ test/ThinLTO/X86/Inputs/drop-debug-info.bc | Bin 1472 -> 0 bytes test/ThinLTO/X86/Inputs/drop-debug-info.ll | 47 --------------------- test/ThinLTO/X86/drop-debug-info.ll | 20 --------- 4 files changed, 21 insertions(+), 80 deletions(-) delete mode 100644 test/ThinLTO/X86/Inputs/drop-debug-info.bc delete mode 100644 test/ThinLTO/X86/Inputs/drop-debug-info.ll delete mode 100644 test/ThinLTO/X86/drop-debug-info.ll diff --git a/lib/IR/DebugInfo.cpp b/lib/IR/DebugInfo.cpp index 18ec7cdfdba..e8c62961eba 100644 --- a/lib/IR/DebugInfo.cpp +++ b/lib/IR/DebugInfo.cpp @@ -247,20 +247,8 @@ bool llvm::stripDebugInfo(Function &F) { Changed = true; F.setSubprogram(nullptr); } - - Function *Declare = F.getParent()->getFunction("llvm.dbg.declare"); - Function *DbgVal = F.getParent()->getFunction("llvm.dbg.value"); for (BasicBlock &BB : F) { - for (auto II = BB.begin(), End = BB.end(); II != End;) { - Instruction &I = *II++; // We may delete the instruction, increment now. - // Remove all of the calls to the debugger intrinsics, and remove them - // from the module. - CallInst *CI = dyn_cast(&I); - if (CI && (CI->getCalledFunction() == Declare || - CI->getCalledFunction() == DbgVal)) { - CI->eraseFromParent(); - Changed = true; - } + for (Instruction &I : BB) { if (I.getDebugLoc()) { Changed = true; I.setDebugLoc(DebugLoc()); @@ -273,6 +261,26 @@ bool llvm::stripDebugInfo(Function &F) { bool llvm::StripDebugInfo(Module &M) { bool Changed = false; + // Remove all of the calls to the debugger intrinsics, and remove them from + // the module. + if (Function *Declare = M.getFunction("llvm.dbg.declare")) { + while (!Declare->use_empty()) { + CallInst *CI = cast(Declare->user_back()); + CI->eraseFromParent(); + } + Declare->eraseFromParent(); + Changed = true; + } + + if (Function *DbgVal = M.getFunction("llvm.dbg.value")) { + while (!DbgVal->use_empty()) { + CallInst *CI = cast(DbgVal->user_back()); + CI->eraseFromParent(); + } + DbgVal->eraseFromParent(); + Changed = true; + } + for (Module::named_metadata_iterator NMI = M.named_metadata_begin(), NME = M.named_metadata_end(); NMI != NME;) { NamedMDNode *NMD = &*NMI; diff --git a/test/ThinLTO/X86/Inputs/drop-debug-info.bc b/test/ThinLTO/X86/Inputs/drop-debug-info.bc deleted file mode 100644 index fbb1c99c83d94aa0642f57454275587a23dc0a98..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1472 zcmX|Be@qj16o1EEdj-mINGGkd&9yL6Gu=vYwOBFzfmk>GC_0UrZM6In62znJprTo> z^yXDpTy-Wk3x9yaxw*MPwz$Qa4GLnT;K*1Ow=n{O%q>8e(M%TO_C0j_B;R-M-uHdq zyZ7$%eUtq;>42a>t49Jr0$>hj|Ky9vfL@_WZp<&=`_0_KUt8Ai>Yyb_WY@_7Dlvfc zb_P4C-1dr4bUJ+JIH4<(Rww~*6f-wE^$!AROEJK9WJ4(-yB**d13)3& zq?e^KHE$8w`W_yM8NNHFSXCa0rt^F`ZSWJa0huk8uVXwXK=G2Uc2~epc+fG(-f*NJ zw?33uyTWD}8RWXRh5}zM*Y7|I_@^+oPAhth|4(^YPiU<4pw*mJ_!d zKkLbT{rq>8HOsk^`ZHG__@7%afBRbFr6Fl3u@ALpFN6Lcn6z=ZDyuveO)c0qOgP)K z;JV(xXRTyCg!*Vhntod{R#D(uD;ixkId9*v3IetM!1L8C>lBrSra*PQ*H^jkm7Rr7 zuWx^KX{*;)$Ly~4`5O*4mDX0hv7g!ARCn+{3yPD?L!8MUB6MpDWXB3q*AUn$06Q=^ z^eZJ2fsy1k<8jQeneD;&}&)*+a~*wEFCY3n}J| z6wk%?U_UTZBG*=Mi}w7o8Z2P=kh5WC;^(7Ydpu+C)P^;wq!0CBA9@zaIQ7u9x=w+WM4T3WFzVpQLqXCX zZeRP%nuJ$dXFO)T61I*xi@(4(UkPvKaqGyE zqQyfVt|vFv3qB+{fsF~Q2ho#kc_=|)TREXpCNwJrUtBm853O5Vq86v92mRE%5wA*i zt7p5_BP(*ktG=#N4}~<>z0x0J&f=uAIKCpk8nm2tB63?#559nsK5DoAfLnV9<<}Yn zc8}m=!-0A-=n(=+Ant7{ zY@bsPcW2zSi*26MY3}MYlLH#?G5{h$vkCh;@y>|%za|ghPb0u;q_1$8;w1?*fEues z(pI)M1nMhmL~>RGeEb3Yy(P)u4DyGQQy3H}1@KPUT@uJm@r*N2ZKSXS$h!tHF2kXU z3|vP11sU)*Wuc9uiSP_9&L6u?l-@^32r4`U641{wA{R+FJ*w~`1)-aHQs4VTs1xIp zw7!a;RWPMT>8!l`JD@X_xste}Mpgj~jd5Zj2+a%t8l|vyOlBWZ@=+eH5kcZYcNfBXxGsnury diff --git a/test/ThinLTO/X86/Inputs/drop-debug-info.ll b/test/ThinLTO/X86/Inputs/drop-debug-info.ll deleted file mode 100644 index 82a728e2286..00000000000 --- a/test/ThinLTO/X86/Inputs/drop-debug-info.ll +++ /dev/null @@ -1,47 +0,0 @@ -; This file is checked-in as a .bc file, because the debug info version is -; intentionally out-of-date and llvm-as will drop it before writing the bitcode - -target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-apple-macosx10.11.0" - - -@argc = global i8 0, align 1 - -define void @globalfunc() { -entry: - %0 = load i8, i8* @argc, align 1 - tail call void @llvm.dbg.value(metadata i8 %0, i64 0, metadata !19, metadata !29), !dbg !DILocation(scope: !13) - ret void -} - - -declare void @llvm.dbg.value(metadata, i64, metadata, metadata) - -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!22, !23} - -!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, enums: !2, retainedTypes: !3, globals: !20, imports: !2, emissionKind: FullDebug) -!1 = !DIFile(filename: "test.cpp", directory: "") -!2 = !{} -!3 = !{!4} -!4 = !DICompositeType(tag: DW_TAG_class_type, name: "C", line: 2, size: 8, align: 8, file: !1, elements: !5, identifier: "_ZTS1C") -!5 = !{!6} -!6 = !DISubprogram(name: "test", file: !1, scope: !4, type: !7, isDefinition: false) -!7 = !DISubroutineType(types: !8) -!8 = !{!9, !10, !11, !11, !11, null} -!9 = !DIBasicType(encoding: DW_ATE_signed, size: 32, align: 32, name: "int") -!10 = !DIDerivedType(baseType: !4, tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial) -!11 = !DIBasicType(tag: DW_TAG_base_type, name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) -!13 = distinct !DISubprogram(name: "test_with_debug", linkageName: "test_with_debug", line: 6, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, unit: !0, scopeLine: 6, file: !1, scope: !14, type: !15, variables: !17) -!14 = !DIFile(filename: "test.cpp", directory: "") -!15 = !DISubroutineType(types: !16) -!16 = !{null} -!17 = !{!18, !19} -!18 = !DILocalVariable(name: "c", line: 7, scope: !13, file: !14, type: !4) -!19 = !DILocalVariable(name: "lc", line: 8, scope: !13, file: !14, type: !11) -!20 = !{!21} -!21 = !DIGlobalVariable(name: "argc", line: 1, isLocal: false, isDefinition: true, scope: null, file: !14, type: !11, variable: i8* @argc) -!22 = !{i32 2, !"Dwarf Version", i32 4} -!23 = !{i32 2, !"Debug Info Version", i32 0} -!25 = !DILocation(line: 8, column: 3, scope: !13) -!29 = !DIExpression() diff --git a/test/ThinLTO/X86/drop-debug-info.ll b/test/ThinLTO/X86/drop-debug-info.ll deleted file mode 100644 index f8ed8dff420..00000000000 --- a/test/ThinLTO/X86/drop-debug-info.ll +++ /dev/null @@ -1,20 +0,0 @@ -; RUN: opt -module-summary %s -o %t.bc -; RUN: llvm-lto -thinlto-action=thinlink -o %t.index.bc %t.bc %p/Inputs/drop-debug-info.bc - -; The imported module has out-of-date debug information, let's make sure we can -; drop them without crashing when materializing later. -; RUN: llvm-lto -thinlto-action=import %t.bc -thinlto-index=%t.index.bc -o - | llvm-dis -o - | FileCheck %s -; CHECK: define available_externally void @globalfunc -; CHECK-NOT: llvm.dbg.value - -target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" -target triple = "x86_64-apple-macosx10.11.0" - - -define i32 @main() #0 { -entry: - call void (...) @globalfunc() - ret i32 0 -} - -declare void @globalfunc(...) \ No newline at end of file -- 2.50.1