[llvm-commits] [llvm] r61030 - in /llvm/trunk: include/llvm/Attributes.h lib/AsmParser/llvmAsmParser.y lib/Bitcode/Writer/BitcodeWriter.cpp lib/VMCore/Attributes.cpp

Bill Wendling isanbard at gmail.com
Tue Dec 16 00:37:42 PST 2008


Nick,

You patch r61019 is causing a bootstrap failure on PPC. Here's the  
minimal testcase and the error:

$ cat testcase.i
struct S {
   unsigned long long f1;
   unsigned long long f2;
};
static void func2(struct S);
void func1() {
   struct S a;
   func2(a);
}

$ Volumes/SandBox/NightlyTest/test/llvm-gcc.obj/./prev-gcc/xgcc -B/ 
Volumes/SandBox/NightlyTest/test/llvm\
-gcc.obj/./prev-gcc/ -B/Volumes/SandBox/NightlyTest/test/llvm- 
gcc.install/powerpc-apple-darwin9.5.0/bin\
/ -c testcase.i
bash-3.2$ bash-3.2$ Assertion failed: (isPowerOf2_32(i) && "Alignment  
must be a power of two."), functi\
on constructAlignmentFromInt, file /Volumes/SandBox/NightlyTest/test/ 
llvm.src/include/llvm/Attributes.h\
, line 81.
testcase.i: In function 'func1':
testcase.i:6: internal compiler error: Abort trap
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://developer.apple.com/bugreporter> for instructions.

Unfortunately, this occurs in the front-end, so I can't create a .bc  
file. Here is the backtrace:

(gdb) bt
#0  0x95bfd278 in abort ()
#1  0x95bec904 in __assert_rtn ()
#2  0x0093396c in llvm::Attribute::constructAlignmentFromInt ()
#3  0x00862a6c in DefaultABI<(anonymous  
namespace)::FunctionTypeConversion>::HandleArgument ()
#4  0x0084b4ec in TypeConverter::ConvertFunctionType ()
#5  0x007cf6fc in make_decl_llvm ()
#6  0x007e3790 in llvm_get_decl ()
#7  0x007e6fe0 in TreeToLLVM::EmitLV_DECL ()
#8  0x00816dcc in TreeToLLVM::EmitLV ()
#9  0x0081e7fc in TreeToLLVM::EmitADDR_EXPR ()
#10 0x00802734 in TreeToLLVM::Emit ()
#11 0x00801988 in TreeToLLVM::EmitCALL_EXPR ()
#12 0x00802750 in TreeToLLVM::Emit ()
#13 0x0081f558 in TreeToLLVM::EmitFunction ()
#14 0x007d22a4 in llvm_emit_code_for_current_function ()
#15 0x0018c3a8 in tree_rest_of_compilation ()
#16 0x0002d9bc in c_expand_body ()
#17 0x008df4dc in cgraph_expand_function ()
#18 0x008dba94 in cgraph_assemble_pending_functions ()
#19 0x008dc01c in cgraph_finalize_function ()
#20 0x0002d854 in finish_function ()
#21 0x000d88a0 in c_parser_declaration_or_fndef ()
#22 0x000d7afc in c_parser_external_declaration ()
#23 0x000d7968 in c_parser_translation_unit ()
#24 0x000eb214 in c_parse_file ()
#25 0x000c35dc in c_common_parse_file ()
#26 0x0070688c in compile_file ()
#27 0x007095e0 in do_compile ()
#28 0x00709680 in toplev_main ()
#29 0x0010b308 in main ()

Could you back-out your changes and investigate?

-bw

On Dec 14, 2008, at 11:29 PM, Nick Lewycky wrote:

> Author: nicholas
> Date: Mon Dec 15 01:29:55 2008
> New Revision: 61030
>
> URL: http://llvm.org/viewvc/llvm-project?rev=61030&view=rev
> Log:
> It turns out that "align 1" and unaligned are different. Add a bias  
> to the
> alignment attribute such that 0 means unaligned.
>
> This will probably require a rebuild of llvm-gcc because of the  
> change to
> Attributes.h. If you see many test failures on "make check", please  
> rebuild
> your llvm-gcc.
>
> Modified:
>    llvm/trunk/include/llvm/Attributes.h
>    llvm/trunk/lib/AsmParser/llvmAsmParser.y
>    llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
>    llvm/trunk/lib/VMCore/Attributes.cpp
>
> Modified: llvm/trunk/include/llvm/Attributes.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Attributes.h?rev=61030&r1=61029&r2=61030&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/include/llvm/Attributes.h (original)
> +++ llvm/trunk/include/llvm/Attributes.h Mon Dec 15 01:29:55 2008
> @@ -51,7 +51,8 @@
> const Attributes StackProtect    = 1<<14; ///< Stack protection.
> const Attributes StackProtectReq = 1<<15; ///< Stack protection  
> required.
> const Attributes Alignment = 31<<16; ///< Alignment of parameter (5  
> bits)
> -                                     // stored as log2 of alignment.
> +                                     // stored as log2 of alignment  
> with +1 bias
> +                                     // 0 means unaligned different  
> from align 1
> const Attributes NoCapture = 1<<21; ///< Function creates no aliases  
> of pointer
>
> /// @brief Attributes that only apply to function parameters.
> @@ -79,7 +80,8 @@
> /// form used internally in Attributes.
> inline Attributes constructAlignmentFromInt(unsigned i) {
>   assert(isPowerOf2_32(i) && "Alignment must be a power of two.");
> -  return Log2_32(i) << 16;
> +  assert(i <= 0x40000000 && "Alignment too large.");
> +  return (Log2_32(i)+1) << 16;
> }
>
> /// The set of Attributes set in Attributes is converted to a
> @@ -178,7 +180,7 @@
>   /// getParamAlignment - Return the alignment for the specified  
> function
>   /// parameter.
>   unsigned getParamAlignment(unsigned Idx) const {
> -    return (getAttributes(Idx) & Attribute::Alignment) >> 16;
> +    return 1ull << (((getAttributes(Idx) & Attribute::Alignment) >>  
> 16) - 1);
>   }
>
>   /// hasAttrSomewhere - Return true if the specified attribute is  
> set for at
>
> Modified: llvm/trunk/lib/AsmParser/llvmAsmParser.y
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/llvmAsmParser.y?rev=61030&r1=61029&r2=61030&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/AsmParser/llvmAsmParser.y (original)
> +++ llvm/trunk/lib/AsmParser/llvmAsmParser.y Mon Dec 15 01:29:55 2008
> @@ -1332,6 +1332,8 @@
>   $$ = $2;
>   if ($$ != 0 && !isPowerOf2_32($$))
>     GEN_ERROR("Alignment must be a power of two");
> +  if ($$ > 0x40000000)
> +    GEN_ERROR("Alignment too large");
>   CHECK_FOR_ERROR
> };
> OptCAlign : /*empty*/            { $$ = 0; } |
> @@ -1339,6 +1341,8 @@
>   $$ = $3;
>   if ($$ != 0 && !isPowerOf2_32($$))
>     GEN_ERROR("Alignment must be a power of two");
> +  if ($$ > 0x40000000)
> +    GEN_ERROR("Alignment too large");
>   CHECK_FOR_ERROR
> };
>
> @@ -1368,6 +1372,8 @@
>   | ALIGN EUINT64VAL {
>     if ($2 != 0 && !isPowerOf2_32($2))
>       GEN_ERROR("Alignment must be a power of two");
> +    if ($2 > 0x40000000)
> +      GEN_ERROR("Alignment too large");
>     CurGV->setAlignment($2);
>     CHECK_FOR_ERROR
>   };
>
> Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=61030&r1=61029&r2=61030&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
> +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Mon Dec 15  
> 01:29:55 2008
> @@ -128,7 +128,8 @@
>       // 5-bit log2 encoded value. Shift the bits above the  
> alignment up by
>       // 11 bits.
>       uint64_t FauxAttr = PAWI.Attrs & 0xffff;
> -      FauxAttr |= (1ull<<16)<<((PAWI.Attrs & Attribute::Alignment)  
> >> 16);
> +      if (PAWI.Attrs & Attribute::Alignment)
> +        FauxAttr |= (1ull<<16)<<(((PAWI.Attrs &  
> Attribute::Alignment)-1) >> 16);
>       FauxAttr |= (PAWI.Attrs & (0x3FFull << 21)) << 11;
>
>       Record.push_back(FauxAttr);
>
> Modified: llvm/trunk/lib/VMCore/Attributes.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Attributes.cpp?rev=61030&r1=61029&r2=61030&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/lib/VMCore/Attributes.cpp (original)
> +++ llvm/trunk/lib/VMCore/Attributes.cpp Mon Dec 15 01:29:55 2008
> @@ -61,7 +61,7 @@
>     Result += "sspreq ";
>   if (Attrs & Attribute::Alignment) {
>     Result += "align ";
> -    Result += utostr(1ull << ((Attrs & Attribute::Alignment)>>16));
> +    Result += utostr(1ull << (((Attrs & Attribute::Alignment)>>16)  
> - 1));
>     Result += " ";
>   }
>   // Trim the trailing space.
>
>
> _______________________________________________
> 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