[PATCH] D15028: [ELF] Enable temporary labels symbol names

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Sat Dec 5 19:29:59 PST 2015


(Sorry for the delay; I'm still working through mail from Thanksgiving.)

+Rafael, since we worked on this change together, and I don't know much about ELF.

> On 2015-Nov-26, at 09:58, Leny Kholodov <leny.kholodov at gmail.com> wrote:
> 
> lenykholodov created this revision.
> lenykholodov added a reviewer: dexonsmith.
> lenykholodov added a subscriber: llvm-commits.
> lenykholodov set the repository for this revision to rL LLVM.
> 
> After revision r236642 compiler prevents emitting of temp label names into object files to save memory. This creates problems for the binutils linker, which analyzes symbol names from the input object files and can skip some local compiler generated labels. As a result linker doesn't see the label names and therefore puts them all into the final binary as global symbols. Binutils require label names to have a prefix '.L'.
> 
> This patch fixes temporary label names generation for ELF.

I seem to remember this coming up a few months ago.  IIRC, Rafael
argued that this is a bug in the linker that should be fixed there.
(But I might be remembering incorrectly?)

> Repository:
>  rL LLVM
> 
> http://reviews.llvm.org/D15028
> 
> Files:
>  lib/CodeGen/LLVMTargetMachine.cpp
>  test/CodeGen/ARM/elf-debug-label-name.ll
> 
> Index: test/CodeGen/ARM/elf-debug-label-name.ll
> ===================================================================
> --- test/CodeGen/ARM/elf-debug-label-name.ll
> +++ test/CodeGen/ARM/elf-debug-label-name.ll
> @@ -0,0 +1,37 @@
> +; RUN: llc < %s -mtriple=armv7l-linux-eabihf -filetype=obj -o %s.o && llvm-objdump -t %s.o | FileCheck %s --check-prefix=CHECK
> +; CHECK: .debug_str	00000000 .Linfo_string0
> +; Function Attrs: nounwind
> +define arm_aapcs_vfpcc i32 @_Z1xi(i32 %a) #0 !dbg !4 {
> +entry:
> +  %a.addr = alloca i32, align 4
> +  store i32 %a, i32* %a.addr, align 4
> +  call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !13, metadata !14), !dbg !15
> +  %0 = load i32, i32* %a.addr, align 4, !dbg !16
> +  ret i32 %0, !dbg !17
> +}
> +
> +; Function Attrs: nounwind readnone
> +declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
> +
> +!llvm.dbg.cu = !{!0}
> +!llvm.module.flags = !{!8, !9, !10, !11}
> +!llvm.ident = !{!12}
> +
> +!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3)
> +!1 = !DIFile(filename: "file", directory: "dir")
> +!2 = !{}
> +!3 = !{!4}
> +!4 = distinct !DISubprogram(name: "x", linkageName: "_Z1xi", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, variables: !2)
> +!5 = !DISubroutineType(types: !6)
> +!6 = !{!7, !7}
> +!7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
> +!8 = !{i32 2, !"Dwarf Version", i32 4}
> +!9 = !{i32 2, !"Debug Info Version", i32 3}
> +!10 = !{i32 1, !"wchar_size", i32 4}
> +!11 = !{i32 1, !"min_enum_size", i32 4}
> +!12 = !{!"clang"}
> +!13 = !DILocalVariable(name: "a", arg: 1, scope: !4, file: !1, line: 1, type: !7)
> +!14 = !DIExpression()
> +!15 = !DILocation(line: 1, column: 11, scope: !4)
> +!16 = !DILocation(line: 3, column: 10, scope: !4)
> +!17 = !DILocation(line: 3, column: 3, scope: !4)
> Index: lib/CodeGen/LLVMTargetMachine.cpp
> ===================================================================
> --- lib/CodeGen/LLVMTargetMachine.cpp
> +++ lib/CodeGen/LLVMTargetMachine.cpp
> @@ -196,8 +196,11 @@
>     if (!MCE || !MAB)
>       return true;
> 
> -    // Don't waste memory on names of temp labels.
> -    Context->setUseNamesOnTempLabels(false);
> +    if (getObjFileLowering()->getObjectFileType() ==
> +        MCObjectFileInfo::Environment::IsELF) {
> +      // Don't waste memory on names of temp labels.
> +      Context->setUseNamesOnTempLabels(false);

I don't understand.  Your description and title suggest that
you're turning on temp label names for ELF, but this code
looks like, on the contrary, it's turning on temp label names
for everything *except* ELF.

> +    }
> 
>     Triple T(getTargetTriple().str());
>     AsmStreamer.reset(getTarget().createMCObjectStreamer(
> 
> 
> <D15028.41263.patch>



More information about the llvm-commits mailing list