[llvm-commits] [llvm] r146468 - in /llvm/trunk: lib/MC/ELFObjectWriter.cpp test/CodeGen/Mips/DO-relsym.ll

Hatanaka, Akira ahatanaka at mips.com
Mon Dec 12 19:54:31 PST 2011


r146470.
________________________________________
From: Bruno Cardoso Lopes [bruno.cardoso at gmail.com]
Sent: Monday, December 12, 2011 6:53 PM
To: Hatanaka, Akira; Carter, Jack
Cc: llvm-commits at cs.uiuc.edu
Subject: Re: [llvm-commits] [llvm] r146468 - in /llvm/trunk: lib/MC/ELFObjectWriter.cpp test/CodeGen/Mips/DO-relsym.ll

On Tue, Dec 13, 2011 at 12:27 AM, Akira Hatanaka <ahatanaka at mips.com> wrote:
> Author: ahatanak
> Date: Mon Dec 12 20:27:40 2011
> New Revision: 146468
>
> URL: http://llvm.org/viewvc/llvm-project?rev=146468&view=rev
> Log:
> Relocation against a symbol, instead of against section. We had some extreme
> test cases where there were a lot of relocations applied relative to a large
> rodata section. Gas would create a symbol for each of these whereas we would
> be relative to the beginning of the rodata section. This change mimics what
> gas does.
>
> Patch by Jack Carter.
>
> Added:
>    llvm/trunk/test/CodeGen/Mips/DO-relsym.ll
> Modified:
>    llvm/trunk/lib/MC/ELFObjectWriter.cpp
>
> Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=146468&r1=146467&r2=146468&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
> +++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Mon Dec 12 20:27:40 2011
> @@ -1851,7 +1851,8 @@
>   assert(Target.getSymA() && "SymA cannot be 0.");
>   const MCSymbol &Sym = Target.getSymA()->getSymbol();
>
> -  if (Sym.getSection().getKind().isMergeable1ByteCString())
> +  if (Sym.getSection().getKind().isMergeableCString() ||
> +      Sym.getSection().getKind().isMergeableConst())
>     return &Sym;
>
>   return NULL;
> @@ -1914,4 +1915,3 @@
>
>   return Type;
>  }
> -
>
> Added: llvm/trunk/test/CodeGen/Mips/DO-relsym.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/DO-relsym.ll?rev=146468&view=auto
> ==============================================================================
> --- llvm/trunk/test/CodeGen/Mips/DO-relsym.ll (added)
> +++ llvm/trunk/test/CodeGen/Mips/DO-relsym.ll Mon Dec 12 20:27:40 2011
> @@ -0,0 +1,29 @@
> +; RUN: llc -filetype=obj -mtriple mipsel-unknown-linux %s -o - | elf-dump --dump-section-data  | FileCheck %s
> +
> +; Check that the appropriate symbols were created.
> +
> +; CHECK: (('st_name', 0x{{[0-9|a-f]+}}) # '$.str'
> +; CHECK: (('st_name', 0x{{[0-9|a-f]+}}) # '$.str1'
> +; CHECK: (('st_name', 0x{{[0-9|a-f]+}}) # '$CPI0_0'
> +; CHECK: (('st_name', 0x{{[0-9|a-f]+}}) # '$CPI0_1'
> +
> + at .str = private unnamed_addr constant [6 x i8] c"abcde\00", align 1
> + at gc1 = external global i8*
> + at .str1 = private unnamed_addr constant [5 x i8] c"fghi\00", align 1
> + at gc2 = external global i8*
> + at gd1 = external global double
> + at gd2 = external global double
> +
> +define void @foo1() nounwind {
> +entry:
> +  store i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0), i8** @gc1, align 4
> +  store i8* getelementptr inbounds ([5 x i8]* @.str1, i32 0, i32 0), i8** @gc2, align 4
> +  %0 = load double* @gd1, align 8
> +  %add = fadd double %0, 2.500000e+00
> +  store double %add, double* @gd1, align 8
> +  %1 = load double* @gd2, align 8
> +  %add1 = fadd double %1, 4.500000e+00
> +  store double %add1, double* @gd2, align 8
> +  ret void
> +}
> +

Although ARM has some MC tests under CodeGen/ARM, I think it would be
better to create a new directory: test/MC/Mips and place this test
there (which is going to be the same dir to have future mips asm
parsing tests). Also, rename it to "elf-relsym.ll".


--
Bruno Cardoso Lopes
http://www.brunocardoso.cc




More information about the llvm-commits mailing list