[cfe-commits] r160174 - in /cfe/trunk: lib/AST/Decl.cpp test/CodeGenCXX/visibility-inlines-hidden.cpp

Tobias Grosser tobias at grosser.es
Sun Sep 23 10:51:01 PDT 2012


On 07/13/2012 04:25 PM, Rafael Espindola wrote:
> Author: rafael
> Date: Fri Jul 13 09:25:36 2012
> New Revision: 160174
>
> URL: http://llvm.org/viewvc/llvm-project?rev=160174&view=rev
> Log:
> Use -fvisibility-inlines-hidden in inline functions too. This matches gcc
> behavior since gcc pr30066. Thanks to Benjamin Kramer for pointing it out.

This commit causes clang to fail, when compiling Polly.

The error I get is:

/usr/bin/ld: error: 
tools/polly/lib/Analysis/CMakeFiles/PollyAnalysis.dir/ScopInfo.cpp.o: 
requires dynamic R_X86_64_PC32 reloc against '__gmpz_neg' which may 
overflow at runtime; recompile with -fPIC

I get the same error on other projects that use 
-fvisibility-inlines-hidden in combination with gmp. The error 
disappears with older versions of gcc and clang. There is also no error 
if I use gcc 4.7, even though gcc 4.7 should have the functionality that 
was introduced in this commit (pr30066 is part of gcc4.7).

I looked into this and reduced a test case:

extern __inline__ __attribute__ ((__gnu_inline__))
void foo() {}

void bar() {
         foo();
}

I compiled with both current clang++ and g++-4.7.

g++-4.7 -S test-visiblity-inlines-hidden-gnuinline.cpp 
-fvisibility-inlines-hidden -O0 -o g++.s

clang++ -S test-visiblity-inlines-hidden-gnuinline.cpp 
-fvisibility-inlines-hidden -O0 -o clang.s

Both, clang.s and g++.s, contain no implementation of foo, but a call to 
foo. However, clang.s contains the string  ".hidden _Z3foov", g++.s does 
not contain the string. This difference seems to cause incorrect 
relocation information.

The attached patch fixes this for me. I also tried to add a test case, 
but was not sure what LLVM-IR output I should put into the CHECK-line.
Can anybody comment on the solution?

Cheers
Tobi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test-visiblity-inlines-hidden-gnuinline.cpp
Type: text/x-c++src
Size: 89 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120923/c668bd10/attachment.cpp>
-------------- next part --------------
	.file	"test-visiblity-inlines-hidden-gnuinline.cpp"
	.text
	.globl	_Z3barv
	.align	16, 0x90
	.type	_Z3barv, at function
_Z3barv:                                # @_Z3barv
	.cfi_startproc
# BB#0:                                 # %entry
	pushq	%rbp
.Ltmp2:
	.cfi_def_cfa_offset 16
.Ltmp3:
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
.Ltmp4:
	.cfi_def_cfa_register %rbp
	callq	_Z3foov
	popq	%rbp
	ret
.Ltmp5:
	.size	_Z3barv, .Ltmp5-_Z3barv
	.cfi_endproc

	.hidden	_Z3foov

	.section	".note.GNU-stack","", at progbits
-------------- next part --------------
	.file	"test-visiblity-inlines-hidden-gnuinline.cpp"
	.text
	.globl	_Z3barv
	.type	_Z3barv, @function
_Z3barv:
.LFB1:
	.cfi_startproc
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	_Z3foov
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	_Z3barv, .-_Z3barv
	.ident	"GCC: (Ubuntu/Linaro 4.7.0-7ubuntu3) 4.7.0"
	.section	.note.GNU-stack,"", at progbits
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-InlineVisibilityHidden-with-GNUInlineAttr.patch
Type: text/x-patch
Size: 924 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120923/c668bd10/attachment.bin>


More information about the cfe-commits mailing list