On Jul 30, 2008, at 11:39 AM, Duncan Sands wrote:> On Wednesday 30 July 2008 18:13:27 Duncan Sands wrote: >> On x86-64 linux, in stage 2, I get: >> >> c++ -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict- >> prototypes -Wmissing-prototypes -pedantic -Wno-long-long -Wno- >> variadic-macros -Wno-overlength-strings -Wold-style-definition - >> Wmissing-format-attribute -fno-common -DHAVE_CONFIG_H -o f951 \ >> fortran/arith.o fortran/array.o fortran/bbt.o >> fortran/check.o fortran/data.o fortran/decl.o fortran/dump-parse- >> tree.o fortran/error.o fortran/expr.o fortran/interface.o fortran/ >> intrinsic.o fortran/io.o fortran/iresolve.o fortran/match.o fortran/ >> matchexp.o fortran/misc.o fortran/module.o fortran/openmp.o fortran/ >> options.o fortran/parse.o fortran/primary.o fortran/resolve.o >> fortran/scanner.o fortran/simplify.o fortran/st.o fortran/symbol.o >> fortran/convert.o fortran/dependency.o fortran/f95-lang.o fortran/ >> trans.o fortran/trans-array.o fortran/trans-common.o fortran/trans- >> const.o fortran/trans-decl.o fortran/trans-expr.o fortran/trans- >> intrinsic.o fortran/trans-io.o fortran/trans-openmp.o fortran/trans- >> stmt.o fortran/trans-types.o llvm-main.o tree-browser.o >> libbackend.a ../libcpp/libcpp.a /home/duncan/LLVM/llvm-objects/ >> Debug/lib/libLLVMBitReader.a /home/duncan/LLVM/llvm-objects/Debug/ >> lib/libLLVMipo.a /home/duncan/LLVM/llvm-objects/Debug/lib/ >> libLLVMBitWriter.a /hom! >> e/duncan/LLVM/llvm-objects/Debug/lib/LLVMX86.o /home/duncan/LLVM/ >> llvm-objects/Debug/lib/libLLVMSelectionDAG.a /home/duncan/LLVM/llvm- >> objects/Debug/lib/libLLVMCodeGen.a /home/duncan/LLVM/llvm-objects/ >> Debug/lib/libLLVMScalarOpts.a /home/duncan/LLVM/llvm-objects/Debug/ >> lib/libLLVMTransformUtils.a /home/duncan/LLVM/llvm-objects/Debug/ >> lib/libLLVMipa.a /home/duncan/LLVM/llvm-objects/Debug/lib/ >> libLLVMAnalysis.a /home/duncan/LLVM/llvm-objects/Debug/lib/ >> libLLVMTarget.a /home/duncan/LLVM/llvm-objects/Debug/lib/ >> libLLVMCore.a /home/duncan/LLVM/llvm-objects/Debug/lib/ >> libLLVMSupport.a /home/duncan/LLVM/llvm-objects/Debug/lib/ >> libLLVMSystem.a attribs.o stub-objc.o stub-c.o -lmpfr -lgmp ../ >> libcpp/libcpp.a ../libiberty/libiberty.a ../libdecnumber/ >> libdecnumber.a -L/home/duncan/LLVM/llvm-objects/Debug/lib - >> lpthread -ldl -lm >> libbackend.a(dwarf2out.o): In function `add_type_attribute': >> (.text+0x1ffb3): undefined reference to `invoke_impl_ptr_type' >> libbackend.a(llvm-backend.o): In function `createOptimizationPasses': >> /home/duncan/LLVM/gcc-4.2.llvm-objects/gcc/../../gcc-4.2.llvm/gcc/ >> llvm-backend.cpp:384: undefined reference to `flag_no_builtin' > > This one (with Ada): > libbackend.a(dwarf2out.o): In function `modified_type_die': > gcc/../../gcc-4.2.llvm/gcc/dwarf2out.c:8617: undefined reference to > `c_language' > > ...> > How about something like this instead (I have no idea if this works): >Done. Thanks! -bw
And how about this one for handling the C specific invoke_impl_ptr_type? Index: gcc-4.2.llvm/gcc/c-common.h ==================================================================--- gcc-4.2.llvm.orig/gcc/c-common.h 2008-07-30 21:01:49.000000000 +0200 +++ gcc-4.2.llvm/gcc/c-common.h 2008-07-30 21:01:56.000000000 +0200 @@ -1164,7 +1164,6 @@ extern struct block_sema_info *cur_block; extern tree build_helper_func_decl (tree, tree); extern bool building_block_byref_decl; -extern tree invoke_impl_ptr_type; extern tree build_block_byref_decl (tree, tree, tree); extern tree build_block_ref_decl (tree, tree); extern tree begin_block (void); Index: gcc-4.2.llvm/gcc/dwarf2out.c ==================================================================--- gcc-4.2.llvm.orig/gcc/dwarf2out.c 2008-07-30 20:57:56.000000000 +0200 +++ gcc-4.2.llvm/gcc/dwarf2out.c 2008-07-30 20:58:16.000000000 +0200 @@ -11480,9 +11480,8 @@ dw_die_ref type_die = NULL; /* APPLE LOCAL begin radar 5811943 - Fix type of pointers to blocks */ - if (code == BLOCK_POINTER_TYPE) + if (code == BLOCK_POINTER_TYPE && invoke_impl_ptr_type) { - gcc_assert (invoke_impl_ptr_type); type = invoke_impl_ptr_type; code = TREE_CODE (type); } Index: gcc-4.2.llvm/gcc/tree.h ==================================================================--- gcc-4.2.llvm.orig/gcc/tree.h 2008-07-30 21:01:15.000000000 +0200 +++ gcc-4.2.llvm/gcc/tree.h 2008-07-30 21:04:46.000000000 +0200 @@ -4845,4 +4845,8 @@ extern void note_alternative_entry_points (void); /* APPLE LOCAL end CW asm blocks */ +/* LLVM LOCAL pointers to blocks */ +extern tree invoke_impl_ptr_type; +/* LLVM LOCAL pointers to blocks */ + #endif /* GCC_TREE_H */ Index: gcc-4.2.llvm/gcc/stub-c.c ==================================================================--- gcc-4.2.llvm.orig/gcc/stub-c.c 2008-07-30 21:05:10.000000000 +0200 +++ gcc-4.2.llvm/gcc/stub-c.c 2008-07-30 21:05:44.000000000 +0200 @@ -32,6 +32,7 @@ bool iasm_in_operands ATTRIBUTE_WEAK; int flag_iasm_blocks ATTRIBUTE_WEAK; int parse_in ATTRIBUTE_WEAK; +tree invoke_impl_ptr_type; tree iasm_addr (tree) ATTRIBUTE_WEAK;
And how about this one so as not to include a C specific header in llvm-backend (!!!) and not to have llvm-backend use a C specific flag (flag_no_builtin)? Index: gcc-4.2.llvm/gcc/c-opts.c ==================================================================--- gcc-4.2.llvm.orig/gcc/c-opts.c 2008-07-30 21:25:28.000000000 +0200 +++ gcc-4.2.llvm/gcc/c-opts.c 2008-07-30 21:26:17.000000000 +0200 @@ -660,6 +660,9 @@ case OPT_fbuiltin: flag_no_builtin = !value; +#ifdef LLVM + flag_no_simplify_libcalls = !value; +#endif break; case OPT_fbuiltin_: @@ -685,6 +688,9 @@ case OPT_fhosted: flag_hosted = value; flag_no_builtin = !value; +#ifdef LLVM + flag_no_simplify_libcalls = !value; +#endif /* warn_main will be 2 if set by -Wall, 1 if set by -Wmain */ if (!value && warn_main == 2) warn_main = 0; Index: gcc-4.2.llvm/gcc/flags.h ==================================================================--- gcc-4.2.llvm.orig/gcc/flags.h 2008-07-30 21:22:44.000000000 +0200 +++ gcc-4.2.llvm/gcc/flags.h 2008-07-30 21:24:50.000000000 +0200 @@ -391,6 +391,7 @@ /* LLVM LOCAL begin */ #ifdef ENABLE_LLVM extern int flag_llvm_pch_read; +extern int flag_no_simplify_libcalls; #endif /* LLVM LOCAL end */ Index: gcc-4.2.llvm/gcc/llvm-backend.cpp ==================================================================--- gcc-4.2.llvm.orig/gcc/llvm-backend.cpp 2008-07-30 21:17:36.000000000 +0200 +++ gcc-4.2.llvm/gcc/llvm-backend.cpp 2008-07-30 21:24:42.000000000 +0200 @@ -70,12 +70,14 @@ #include "tree-inline.h" #include "langhooks.h" #include "cgraph.h" -#include "c-common.h" } // Non-zero if bytecode from PCH is successfully read. int flag_llvm_pch_read; +// Non-zero if libcalls should not be simplified. +int flag_no_simplify_libcalls; + // Global state for the LLVM backend. Module *TheModule = 0; DebugInfo *TheDebugInfo = 0; @@ -381,7 +383,7 @@ PM->add(createFunctionInliningPass()); // Inline small functions if (optimize > 2) PM->add(createArgumentPromotionPass()); // Scalarize uninlined fn args - if (!flag_no_builtin) + if (!flag_no_simplify_libcalls) PM->add(createSimplifyLibCallsPass()); // Library Call Optimizations PM->add(createInstructionCombiningPass()); // Cleanup for scalarrepl. PM->add(createJumpThreadingPass()); // Thread jumps.
Sure. -bw On Jul 30, 2008, at 12:11 PM, Duncan Sands wrote:> And how about this one for handling the C specific > invoke_impl_ptr_type? > > Index: gcc-4.2.llvm/gcc/c-common.h > ==================================================================> --- gcc-4.2.llvm.orig/gcc/c-common.h 2008-07-30 21:01:49.000000000 > +0200 > +++ gcc-4.2.llvm/gcc/c-common.h 2008-07-30 21:01:56.000000000 +0200 > @@ -1164,7 +1164,6 @@ > extern struct block_sema_info *cur_block; > extern tree build_helper_func_decl (tree, tree); > extern bool building_block_byref_decl; > -extern tree invoke_impl_ptr_type; > extern tree build_block_byref_decl (tree, tree, tree); > extern tree build_block_ref_decl (tree, tree); > extern tree begin_block (void); > Index: gcc-4.2.llvm/gcc/dwarf2out.c > ==================================================================> --- gcc-4.2.llvm.orig/gcc/dwarf2out.c 2008-07-30 20:57:56.000000000 > +0200 > +++ gcc-4.2.llvm/gcc/dwarf2out.c 2008-07-30 20:58:16.000000000 +0200 > @@ -11480,9 +11480,8 @@ > dw_die_ref type_die = NULL; > > /* APPLE LOCAL begin radar 5811943 - Fix type of pointers to > blocks */ > - if (code == BLOCK_POINTER_TYPE) > + if (code == BLOCK_POINTER_TYPE && invoke_impl_ptr_type) > { > - gcc_assert (invoke_impl_ptr_type); > type = invoke_impl_ptr_type; > code = TREE_CODE (type); > } > Index: gcc-4.2.llvm/gcc/tree.h > ==================================================================> --- gcc-4.2.llvm.orig/gcc/tree.h 2008-07-30 21:01:15.000000000 +0200 > +++ gcc-4.2.llvm/gcc/tree.h 2008-07-30 21:04:46.000000000 +0200 > @@ -4845,4 +4845,8 @@ > extern void note_alternative_entry_points (void); > /* APPLE LOCAL end CW asm blocks */ > > +/* LLVM LOCAL pointers to blocks */ > +extern tree invoke_impl_ptr_type; > +/* LLVM LOCAL pointers to blocks */ > + > #endif /* GCC_TREE_H */ > Index: gcc-4.2.llvm/gcc/stub-c.c > ==================================================================> --- gcc-4.2.llvm.orig/gcc/stub-c.c 2008-07-30 21:05:10.000000000 +0200 > +++ gcc-4.2.llvm/gcc/stub-c.c 2008-07-30 21:05:44.000000000 +0200 > @@ -32,6 +32,7 @@ > bool iasm_in_operands ATTRIBUTE_WEAK; > int flag_iasm_blocks ATTRIBUTE_WEAK; > int parse_in ATTRIBUTE_WEAK; > +tree invoke_impl_ptr_type; > > > tree iasm_addr (tree) ATTRIBUTE_WEAK; >
Done. -bw On Jul 30, 2008, at 12:35 PM, Duncan Sands wrote:> And how about this one so as not to include a C specific > header in llvm-backend (!!!) and not to have llvm-backend > use a C specific flag (flag_no_builtin)? > > Index: gcc-4.2.llvm/gcc/c-opts.c > ==================================================================> --- gcc-4.2.llvm.orig/gcc/c-opts.c 2008-07-30 21:25:28.000000000 +0200 > +++ gcc-4.2.llvm/gcc/c-opts.c 2008-07-30 21:26:17.000000000 +0200 > @@ -660,6 +660,9 @@ > > case OPT_fbuiltin: > flag_no_builtin = !value; > +#ifdef LLVM > + flag_no_simplify_libcalls = !value; > +#endif > break; > > case OPT_fbuiltin_: > @@ -685,6 +688,9 @@ > case OPT_fhosted: > flag_hosted = value; > flag_no_builtin = !value; > +#ifdef LLVM > + flag_no_simplify_libcalls = !value; > +#endif > /* warn_main will be 2 if set by -Wall, 1 if set by -Wmain */ > if (!value && warn_main == 2) > warn_main = 0; > Index: gcc-4.2.llvm/gcc/flags.h > ==================================================================> --- gcc-4.2.llvm.orig/gcc/flags.h 2008-07-30 21:22:44.000000000 +0200 > +++ gcc-4.2.llvm/gcc/flags.h 2008-07-30 21:24:50.000000000 +0200 > @@ -391,6 +391,7 @@ > /* LLVM LOCAL begin */ > #ifdef ENABLE_LLVM > extern int flag_llvm_pch_read; > +extern int flag_no_simplify_libcalls; > #endif > /* LLVM LOCAL end */ > > Index: gcc-4.2.llvm/gcc/llvm-backend.cpp > ==================================================================> --- gcc-4.2.llvm.orig/gcc/llvm-backend.cpp 2008-07-30 > 21:17:36.000000000 +0200 > +++ gcc-4.2.llvm/gcc/llvm-backend.cpp 2008-07-30 21:24:42.000000000 > +0200 > @@ -70,12 +70,14 @@ > #include "tree-inline.h" > #include "langhooks.h" > #include "cgraph.h" > -#include "c-common.h" > } > > // Non-zero if bytecode from PCH is successfully read. > int flag_llvm_pch_read; > > +// Non-zero if libcalls should not be simplified. > +int flag_no_simplify_libcalls; > + > // Global state for the LLVM backend. > Module *TheModule = 0; > DebugInfo *TheDebugInfo = 0; > @@ -381,7 +383,7 @@ > PM->add(createFunctionInliningPass()); // Inline small > functions > if (optimize > 2) > PM->add(createArgumentPromotionPass()); // Scalarize > uninlined fn args > - if (!flag_no_builtin) > + if (!flag_no_simplify_libcalls) > PM->add(createSimplifyLibCallsPass()); // Library Call > Optimizations > PM->add(createInstructionCombiningPass()); // Cleanup for > scalarrepl. > PM->add(createJumpThreadingPass()); // Thread jumps.