[llvm-commits] [llvm] r68940 - in /llvm/trunk: docs/ include/llvm/ include/llvm/CodeGen/ lib/AsmParser/ lib/Bitcode/Reader/ lib/Bitcode/Writer/ lib/CodeGen/ lib/CodeGen/AsmPrinter/ lib/Linker/ lib/Target/CppBackend/ lib/VMCore/ test/CodeGen/Gener
Dale Johannesen
dalej at apple.com
Mon Apr 13 13:22:27 PDT 2009
On Apr 13, 2009, at 1:12 PMPDT, Chris Lattner wrote:
>
> On Apr 13, 2009, at 12:59 PM, Eli Friedman wrote:
>
>> On Mon, Apr 13, 2009 at 11:16 AM, Chris Lattner <clattner at apple.com>
>> wrote:
>>> This could be handled by having the linker drop
>>> "available_externally"
>>> symbols when it does linking, but do you expect this to be a problem
>>> in practice? Why would it be ok to inline a body in one translation
>>> unit but not in another?
>>
>>> From the C99 rationale: "Second, the requirement that all
>>> definitions
>> of an inline function be 'exactly the same' is replaced by the
>> requirement that the behavior of the program should not depend on
>> whether a call is implemented with a visible inline definition, or
>> the
>> external definition, of a function. This allows an inline definition
>> to be specialized for its use within a particular translation unit.
>> For example, the external definition of a library function might
>> include some argument validation that is not needed for calls made
>> from other functions in the same library."
I guess it's time to point out that making inline definitions
available in the wrong files can produce incorrect results:
/* file 1 */
extern int foo();
inline void inn(int i) {
printf("1\n");
}
main() {
foo();
inn(1);
}
/* file 2 */
inline void inn(int i) {
printf("2\n");
}
int foo() {
inn(2);
}
/* file 3 */
void inn(int i) {
printf("%d\n", i);
}
More information about the llvm-commits
mailing list