[PATCH] AsmPrinter: introduce support for aliases with non-zero GEPs.
Rafael EspĂndola
rafael.espindola at gmail.com
Sat Apr 27 08:41:41 PDT 2013
This needs to go in the language spec. It also needs verifier support.
We should probably require the getelementptr to be inbound, no?
On 22 April 2013 03:47, Peter Collingbourne <peter at pcc.me.uk> wrote:
> http://llvm-reviews.chandlerc.com/D701
>
> Files:
> lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> test/CodeGen/X86/aliases.ll
>
> Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> ===================================================================
> --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> +++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> @@ -841,6 +841,8 @@
> // FIXME: Produce a DW_OP_bit_piece if we used a superregister
> }
>
> +static const MCExpr *lowerConstant(const Constant *CV, AsmPrinter &AP);
> +
> bool AsmPrinter::doFinalization(Module &M) {
> // Emit global variables.
> for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
> @@ -908,9 +910,6 @@
> I != E; ++I) {
> MCSymbol *Name = Mang->getSymbol(I);
>
> - const GlobalValue *GV = I->getAliasedGlobal();
> - MCSymbol *Target = Mang->getSymbol(GV);
> -
> if (I->hasExternalLinkage() || !MAI->getWeakRefDirective())
> OutStreamer.EmitSymbolAttribute(Name, MCSA_Global);
> else if (I->hasWeakLinkage())
> @@ -921,8 +920,7 @@
> EmitVisibility(Name, I->getVisibility());
>
> // Emit the directives as assignments aka .set:
> - OutStreamer.EmitAssignment(Name,
> - MCSymbolRefExpr::Create(Target, OutContext));
> + OutStreamer.EmitAssignment(Name, lowerConstant(I->getAliasee(), *this));
> }
> }
>
> Index: test/CodeGen/X86/aliases.ll
> ===================================================================
> --- test/CodeGen/X86/aliases.ll
> +++ test/CodeGen/X86/aliases.ll
> @@ -1,26 +1,42 @@
> -; RUN: llc < %s -mtriple=i686-pc-linux-gnu -asm-verbose=false -o %t
> -; RUN: grep globl %t | count 6
> -; RUN: grep weak %t | count 1
> -; RUN: grep hidden %t | count 1
> -; RUN: grep protected %t | count 1
> +; RUN: llc < %s -mtriple=i686-pc-linux-gnu -asm-verbose=false -o - | FileCheck %s
>
> @bar = external global i32
> +; CHECK: .globl foo1
> +; CHECK: foo1 = bar
> @foo1 = alias i32* @bar
> +; CHECK: .globl foo2
> +; CHECK: foo2 = bar
> @foo2 = alias i32* @bar
>
> %FunTy = type i32()
>
> declare i32 @foo_f()
> +; CHECK: .weak bar_f
> +; CHECK: bar_f = foo_f
> @bar_f = alias weak %FunTy* @foo_f
>
> +; CHECK-NOT: .{{.*}}bar_i
> +; CHECK: bar_i = bar
> @bar_i = alias internal i32* @bar
>
> +; CHECK: .globl A
> +; CHECK: A = bar
> @A = alias bitcast (i32* @bar to i64*)
>
> +; CHECK: .globl bar_h
> +; CHECK: .hidden bar_h
> +; CHECK: bar_h = bar
> @bar_h = hidden alias i32* @bar
>
> +; CHECK: .globl bar_p
> +; CHECK: .protected bar_p
> +; CHECK: bar_p = bar
> @bar_p = protected alias i32* @bar
>
> +; CHECK: .globl bar_offset
> +; CHECK: bar_offset = bar+4
> + at bar_offset = alias getelementptr (i32* @bar, i32 1)
> +
> define i32 @test() {
> entry:
> %tmp = load i32* @foo1
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
More information about the llvm-commits
mailing list