Re: [llvm-commits] [llvm] r46349 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2008-01-25 Thread Duncan Sands
> Add skeletal code to increase the alignment of loads and stores when
> we can infer it.  This will eventually help stuff, though it doesn't
> do much right now because all fixed FI's have an alignment of 1.

By the way, I've always assumed that alignment 0 is not used by the
code generators, i.e. that IR alignment 0 gets turned into the
preferred alignment for the target during lowering.  Is that right?
(If not, all the alignment calculations for ptr+offset done in codegen
are wrong).

Ciao,

Duncan.
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r46333 - /llvm/trunk/test/CFrontend/2008-01-24-StructAlignAndBitFields.c

2008-01-25 Thread Duncan Sands
Hi Devang, what is this test testing?  A compiler crash?
It doesn't crash here without your fix.

> +// RUN: %llvmgcc %s -S -o -
> +
> +// This struct is not 4 byte aligned becaues bit-field 
> +// type does not influence struct alignment.
> +struct U { char a; short b; int c:25; char d; } u;

Ciao,

Duncan.
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm-gcc-4.2] r46334 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

2008-01-25 Thread Duncan Sands
Hi Devang,

> Fix 2008-01-24-StructAlignAndBitFields.c test case.
> Bit-field type does not influence struct alignment.

I don't see the point of trying to get the LLVM type to have the same
alignment as the gcc type.  I think all the code that tries to obtain
equal alignment should just be dropped.  Who cares if the LLVM type has
a different alignment to the gcc type?  Surely all that matters is that
when we allocate a variable (alloca or global), if the gcc declaration
is more aligned than the LLVM type, then we should force the alloca/global
to have the gcc alignment.

Ciao,

Duncan.
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r46351 - in /llvm/trunk: lib/Transforms/Scalar/DeadStoreElimination.cpp test/Transforms/DeadStoreElimination/byval.ll

2008-01-25 Thread Owen Anderson
Author: resistor
Date: Fri Jan 25 04:10:33 2008
New Revision: 46351

URL: http://llvm.org/viewvc/llvm-project?rev=46351&view=rev
Log:
DeadStoreElimination can treat byval parameters as if there were alloca's for 
the purpose of removing end-of-function stores.

Added:
llvm/trunk/test/Transforms/DeadStoreElimination/byval.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp?rev=46351&r1=46350&r2=46351&view=diff

==
--- llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/DeadStoreElimination.cpp Fri Jan 25 
04:10:33 2008
@@ -261,9 +261,6 @@
   for (BasicBlock::iterator BBI = BB.end(); BBI != BB.begin(); ){
 --BBI;
 
-if (deadPointers.empty())
-  break;
-
 // If we find a store whose pointer is dead...
 if (StoreInst* S = dyn_cast(BBI)) {
   if (!S->isVolatile()) {
@@ -271,8 +268,12 @@
 // See through pointer-to-pointer bitcasts
 TranslatePointerBitCasts(pointerOperand);
   
-if (isa(pointerOperand) && 
-deadPointers.count(cast(pointerOperand))) {
+// Alloca'd pointers or byval arguments (which are functionally like
+// alloca's) are valid candidates for removal.
+if ( (isa(pointerOperand) && 
+  deadPointers.count(cast(pointerOperand))) ||
+ (isa(pointerOperand) &&
+  cast(pointerOperand)->hasByValAttr())) {
   // Remove it!
   MD.removeInstruction(S);
 

Added: llvm/trunk/test/Transforms/DeadStoreElimination/byval.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/DeadStoreElimination/byval.ll?rev=46351&view=auto

==
--- llvm/trunk/test/Transforms/DeadStoreElimination/byval.ll (added)
+++ llvm/trunk/test/Transforms/DeadStoreElimination/byval.ll Fri Jan 25 
04:10:33 2008
@@ -0,0 +1,10 @@
+; RUN: llvm-as < %s | opt -dse | llvm-dis | not grep store
+
+%struct.x = type { i32, i32, i32, i32 }
+
+define i32 @foo(%struct.x* byval  %a) nounwind  {
+entry:
+   %tmp2 = getelementptr %struct.x* %a, i32 0, i32 0
+   store i32 1, i32* %tmp2, align 4
+   ret i32 1
+}


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r46352 - /llvm/trunk/include/llvm/Target/TargetLowering.h

2008-01-25 Thread Duncan Sands
Author: baldrick
Date: Fri Jan 25 04:20:53 2008
New Revision: 46352

URL: http://llvm.org/viewvc/llvm-project?rev=46352&view=rev
Log:
Add more assertions to catch accesses outside of
arrays.  Also, as a convenience, don't barf, just
return false, if someone calls isTruncStoreLegal
or isLoadXLegal with an extended type for the in
memory type.

Modified:
llvm/trunk/include/llvm/Target/TargetLowering.h

Modified: llvm/trunk/include/llvm/Target/TargetLowering.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=46352&r1=46351&r2=46352&view=diff

==
--- llvm/trunk/include/llvm/Target/TargetLowering.h (original)
+++ llvm/trunk/include/llvm/Target/TargetLowering.h Fri Jan 25 04:20:53 2008
@@ -123,7 +123,7 @@
   /// getRegClassFor - Return the register class that should be used for the
   /// specified value type.  This may only be called on legal types.
   TargetRegisterClass *getRegClassFor(MVT::ValueType VT) const {
-assert(!MVT::isExtendedVT(VT));
+assert(VT < array_lengthof(RegClassForVT));
 TargetRegisterClass *RC = RegClassForVT[VT];
 assert(RC && "This value type is not natively supported!");
 return RC;
@@ -133,6 +133,7 @@
   /// specified value type.  This means that it has a register that directly
   /// holds it without promotions or expansions.
   bool isTypeLegal(MVT::ValueType VT) const {
+assert(MVT::isExtendedVT(VT) || VT < array_lengthof(RegClassForVT));
 return !MVT::isExtendedVT(VT) && RegClassForVT[VT] != 0;
   }
 
@@ -158,11 +159,11 @@
   return VT == MVT::RoundIntegerType(VT) ? Expand : Promote;
 assert(0 && "Unsupported extended type!");
   }
+  
assert(VT<4*array_lengthof(ValueTypeActions)*sizeof(ValueTypeActions[0]));
   return (LegalizeAction)((ValueTypeActions[VT>>4] >> ((2*VT) & 31)) & 3);
 }
 void setTypeAction(MVT::ValueType VT, LegalizeAction Action) {
-  assert(!MVT::isExtendedVT(VT));
-  assert(unsigned(VT >> 4) < array_lengthof(ValueTypeActions));
+  
assert(VT<4*array_lengthof(ValueTypeActions)*sizeof(ValueTypeActions[0]));
   ValueTypeActions[VT>>4] |= Action << ((VT*2) & 31);
 }
   };
@@ -187,6 +188,7 @@
   /// returns the integer type to transform to.
   MVT::ValueType getTypeToTransformTo(MVT::ValueType VT) const {
 if (!MVT::isExtendedVT(VT)) {
+  assert(VT < array_lengthof(TransformToType));
   MVT::ValueType NVT = TransformToType[VT];
   assert(getTypeAction(NVT) != Promote &&
  "Promote may not follow Expand or Promote");
@@ -275,6 +277,8 @@
   /// for it.
   LegalizeAction getOperationAction(unsigned Op, MVT::ValueType VT) const {
 if (MVT::isExtendedVT(VT)) return Expand;
+assert(Op < array_lengthof(OpActions) &&
+   VT < sizeof(OpActions[0])*4 && "Table isn't big enough!");
 return (LegalizeAction)((OpActions[Op] >> (2*VT)) & 3);
   }
   
@@ -290,15 +294,17 @@
   /// expanded to some other code sequence, or the target has a custom expander
   /// for it.
   LegalizeAction getLoadXAction(unsigned LType, MVT::ValueType VT) const {
-if (MVT::isExtendedVT(VT)) return getTypeAction(VT);
+assert(LType < array_lengthof(LoadXActions) &&
+   VT < sizeof(LoadXActions[0])*4 && "Table isn't big enough!");
 return (LegalizeAction)((LoadXActions[LType] >> (2*VT)) & 3);
   }
   
   /// isLoadXLegal - Return true if the specified load with extension is legal
   /// on this target.
   bool isLoadXLegal(unsigned LType, MVT::ValueType VT) const {
-return getLoadXAction(LType, VT) == Legal ||
-   getLoadXAction(LType, VT) == Custom;
+return !MVT::isExtendedVT(VT) &&
+  (getLoadXAction(LType, VT) == Legal ||
+   getLoadXAction(LType, VT) == Custom);
   }
   
   /// getTruncStoreAction - Return how this store with truncation should be
@@ -315,8 +321,9 @@
   /// isTruncStoreLegal - Return true if the specified store with truncation is
   /// legal on this target.
   bool isTruncStoreLegal(MVT::ValueType ValVT, MVT::ValueType MemVT) const {
-return getTruncStoreAction(ValVT, MemVT) == Legal ||
-   getTruncStoreAction(ValVT, MemVT) == Custom;
+return !MVT::isExtendedVT(MemVT) &&
+  (getTruncStoreAction(ValVT, MemVT) == Legal ||
+   getTruncStoreAction(ValVT, MemVT) == Custom);
   }
 
   /// getIndexedLoadAction - Return how the indexed load should be treated:
@@ -325,7 +332,9 @@
   /// for it.
   LegalizeAction
   getIndexedLoadAction(unsigned IdxMode, MVT::ValueType VT) const {
-if (MVT::isExtendedVT(VT)) return getTypeAction(VT);
+assert(IdxMode < array_lengthof(IndexedModeActions[0]) &&
+   VT < sizeof(IndexedModeActions[0][0])*4 &&
+   "Table isn't big enough!");
 return (LegalizeAction)((IndexedModeActions[0][IdxMode] >> (2*VT)) & 3);
   }
 
@@ -342,7 +351,9 @@
   /// for it.
   LegalizeAction
   getIndexedStoreAction(unsigned IdxMode, MVT::Va

Re: [llvm-commits] [llvm] r46349 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2008-01-25 Thread Duncan Sands
PS: Does an alignment of 0 mean the ABI alignment or the preferred
alignment?  I'm guessing that it means ABI for globals and
preferred for allocas.
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm-gcc-4.2] r46334 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

2008-01-25 Thread Chris Lattner

On Jan 25, 2008, at 1:01 AM, Duncan Sands wrote:

> Hi Devang,
>
>> Fix 2008-01-24-StructAlignAndBitFields.c test case.
>> Bit-field type does not influence struct alignment.
>
> I don't see the point of trying to get the LLVM type to have the same
> alignment as the gcc type.  I think all the code that tries to obtain
> equal alignment should just be dropped.  Who cares if the LLVM type  
> has
> a different alignment to the gcc type?  Surely all that matters is  
> that
> when we allocate a variable (alloca or global), if the gcc declaration
> is more aligned than the LLVM type, then we should force the alloca/ 
> global
> to have the gcc alignment.

Right.  There are several cases where we *can't* get the same  
alignment.  If dropping the attempts makes the code simpler, I say go  
for it :)

-Chris
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r46349 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2008-01-25 Thread Chris Lattner

On Jan 25, 2008, at 12:53 AM, Duncan Sands wrote:

>> Add skeletal code to increase the alignment of loads and stores when
>> we can infer it.  This will eventually help stuff, though it doesn't
>> do much right now because all fixed FI's have an alignment of 1.
>
> By the way, I've always assumed that alignment 0 is not used by the
> code generators, i.e. that IR alignment 0 gets turned into the
> preferred alignment for the target during lowering.  Is that right?
> (If not, all the alignment calculations for ptr+offset done in codegen
> are wrong).

Right, that is my understanding as well.  The 'infer alignment'  
function I stubbed out returns 0 as a sentinel that says it was unable  
to infer something useful.

-Chris
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r46360 - /llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h

2008-01-25 Thread Chris Lattner
Author: lattner
Date: Fri Jan 25 11:49:41 2008
New Revision: 46360

URL: http://llvm.org/viewvc/llvm-project?rev=46360&view=rev
Log:
Reorder a field to reduce the size of StackObject.  Note that this
may require a clean rebuild on leopard. :(

Modified:
llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h

Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h?rev=46360&r1=46359&r2=46360&view=diff

==
--- llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Fri Jan 25 11:49:41 2008
@@ -6,7 +6,10 @@
 // License. See LICENSE.TXT for details.
 //
 
//===--===//
-
+//
+// The file defines the MachineFrameInfo class.
+//
+//===--===//
 
 #ifndef LLVM_CODEGEN_MACHINEFRAMEINFO_H
 #define LLVM_CODEGEN_MACHINEFRAMEINFO_H
@@ -83,17 +86,17 @@
 // Alignment - The required alignment of this stack slot.
 unsigned Alignment;
 
-// SPOffset - The offset of this object from the stack pointer on entry to
-// the function.  This field has no meaning for a variable sized element.
-int64_t SPOffset;
-
 // isImmutable - If true, the value of the stack object is set before
 // entering the function and is not modified inside the function. By
 // default, fixed objects are immutable unless marked otherwise.
 bool isImmutable;
+
+// SPOffset - The offset of this object from the stack pointer on entry to
+// the function.  This field has no meaning for a variable sized element.
+int64_t SPOffset;
 
 StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM = false)
-  : Size(Sz), Alignment(Al), SPOffset(SP), isImmutable(IM) {}
+  : Size(Sz), Alignment(Al), isImmutable(IM), SPOffset(SP) {}
   };
 
   /// Objects - The list of stack objects allocated...
@@ -194,13 +197,15 @@
   /// getObjectSize - Return the size of the specified object
   ///
   int64_t getObjectSize(int ObjectIdx) const {
-assert(ObjectIdx+NumFixedObjects < Objects.size() && "Invalid Object 
Idx!");
+assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
+   "Invalid Object Idx!");
 return Objects[ObjectIdx+NumFixedObjects].Size;
   }
 
   /// getObjectAlignment - Return the alignment of the specified stack 
object...
   int getObjectAlignment(int ObjectIdx) const {
-assert(ObjectIdx+NumFixedObjects < Objects.size() && "Invalid Object 
Idx!");
+assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
+   "Invalid Object Idx!");
 return Objects[ObjectIdx+NumFixedObjects].Alignment;
   }
 
@@ -208,7 +213,8 @@
   /// from the incoming stack pointer.
   ///
   int64_t getObjectOffset(int ObjectIdx) const {
-assert(ObjectIdx+NumFixedObjects < Objects.size() && "Invalid Object 
Idx!");
+assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
+   "Invalid Object Idx!");
 return Objects[ObjectIdx+NumFixedObjects].SPOffset;
   }
 
@@ -216,7 +222,8 @@
   /// offset is relative to the stack pointer on entry to the function.
   ///
   void setObjectOffset(int ObjectIdx, int64_t SPOffset) {
-assert(ObjectIdx+NumFixedObjects < Objects.size() && "Invalid Object 
Idx!");
+assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
+   "Invalid Object Idx!");
 Objects[ObjectIdx+NumFixedObjects].SPOffset = SPOffset;
   }
 
@@ -280,6 +287,8 @@
   /// isImmutableObjectIndex - Returns true if the specified index corresponds
   /// to an immutable object.
   bool isImmutableObjectIndex(int ObjectIdx) const {
+assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
+   "Invalid Object Idx!");
 return Objects[ObjectIdx+NumFixedObjects].isImmutable;
   }
 


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm-gcc-4.0] r46359 - in /llvm-gcc-4.0/trunk/gcc: llvm-convert.cpp llvm-internal.h

2008-01-25 Thread Duncan Sands
Author: baldrick
Date: Fri Jan 25 11:45:31 2008
New Revision: 46359

URL: http://llvm.org/viewvc/llvm-project?rev=46359&view=rev
Log:
Fix PR1942.  When returning an aggregate result,
create a temporary to hold the result, and copy
it out when returning.

Modified:
llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
llvm-gcc-4.0/trunk/gcc/llvm-internal.h

Modified: llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp?rev=46359&r1=46358&r2=46359&view=diff

==
--- llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp Fri Jan 25 11:45:31 2008
@@ -351,7 +351,9 @@
   }
 
   AllocaInsertionPoint = 0;
-  
+
+  UsedSRetBuffer = false;
+
   CleanupFilter = NULL_TREE;
   ExceptionValue = 0;
   ExceptionSelectorValue = 0;
@@ -384,11 +386,13 @@
 LLVMBuilder Builder;
 std::vector LocStack;
 std::vector NameStack;
+bool &UsedSRetBuffer;
 FunctionPrologArgumentConversion(tree FnDecl,
  Function::arg_iterator &ai,
- const LLVMBuilder &B)
-  : FunctionDecl(FnDecl), AI(ai), Builder(B) {}
-
+ const LLVMBuilder &B,
+ bool &SRetBuffer)
+  : FunctionDecl(FnDecl), AI(ai), Builder(B), UsedSRetBuffer(SRetBuffer) {}
+
 void setName(const std::string &Name) {
   NameStack.push_back(Name);
 }
@@ -408,23 +412,29 @@
   // instead.
   assert(AI != Builder.GetInsertBlock()->getParent()->arg_end() &&
  "No explicit return value?");
+  assert(AI == Builder.GetInsertBlock()->getParent()->arg_begin() &&
+ "Struct return is not first argument!");
   AI->setName("agg.result");
-
+
   tree ResultDecl = DECL_RESULT(FunctionDecl);
   tree RetTy = TREE_TYPE(TREE_TYPE(FunctionDecl));
   if (TREE_CODE(RetTy) == TREE_CODE(TREE_TYPE(ResultDecl))) {
-SET_DECL_LLVM(ResultDecl, AI);
+// Use a buffer for the return result.  This ensures that writes to the
+// return value do not interfere with reads from parameters: the same
+// aggregate might be used for the return value and as a parameter.
+TheTreeToLLVM->EmitAutomaticVariableDecl(DECL_RESULT(FunctionDecl));
+UsedSRetBuffer = true;
 ++AI;
 return;
   }
-  
+
   // Otherwise, this must be something returned with NRVO.
   assert(TREE_CODE(TREE_TYPE(ResultDecl)) == REFERENCE_TYPE &&
  "Not type match and not passing by reference?");
   // Create an alloca for the ResultDecl.
   Value *Tmp = TheTreeToLLVM->CreateTemporary(AI->getType());
   Builder.CreateStore(AI, Tmp);
-  
+
   SET_DECL_LLVM(ResultDecl, Tmp);
   if (TheDebugInfo) {
 TheDebugInfo->EmitDeclare(ResultDecl,
@@ -629,7 +639,7 @@
   Function::arg_iterator AI = Fn->arg_begin();
 
   // Rename and alloca'ify real arguments.
-  FunctionPrologArgumentConversion Client(FnDecl, AI, Builder);
+  FunctionPrologArgumentConversion Client(FnDecl, AI, Builder, UsedSRetBuffer);
   TheLLVMABI ABIConverter(Client);
 
   // Handle the DECL_RESULT.
@@ -729,6 +739,14 @@
  PointerType::getUnqual(Fn->getReturnType()));
   RetVal = Builder.CreateLoad(RetVal, "retval");
 }
+  } else if (UsedSRetBuffer) {
+// A buffer was used for the aggregate return result.  Copy it out now.
+assert(Fn->arg_begin() != Fn->arg_end() && "No struct return value?");
+unsigned Alignment = expr_align(DECL_RESULT(FnDecl))/8;
+bool Volatile = TREE_THIS_VOLATILE(DECL_RESULT(FnDecl));
+MemRef BufLoc(DECL_LLVM(DECL_RESULT(FnDecl)), Alignment, false);
+MemRef RetLoc(Fn->arg_begin(), Alignment, Volatile);
+EmitAggregateCopy(RetLoc, BufLoc, TREE_TYPE(DECL_RESULT(FnDecl)));
   }
   if (TheDebugInfo) TheDebugInfo->EmitRegionEnd(Fn, Builder.GetInsertBlock());
   Builder.CreateRet(RetVal);
@@ -3137,20 +3155,9 @@
 // Non-bitfield aggregate value.
 MemRef NewLoc(LV.Ptr, Alignment, isVolatile);
 
-if (DestLoc) {
-  Emit(TREE_OPERAND(exp, 1), &NewLoc);
+Emit(TREE_OPERAND(exp, 1), &NewLoc);
+if (DestLoc)
   EmitAggregateCopy(*DestLoc, NewLoc, TREE_TYPE(exp));
-} else if (TREE_CODE(TREE_OPERAND(exp, 0)) != RESULT_DECL) {
-  Emit(TREE_OPERAND(exp, 1), &NewLoc);
-} else {
-  // We do this for stores into RESULT_DECL because it is possible for that
-  // memory area to overlap with the object being stored into it; see 
-  // gcc.c-torture/execute/20010124-1.c.
-
-  MemRef Tmp = CreateTempLoc(ConvertType(TREE_TYPE(TREE_OPERAND(exp,1;
-  Emit(TREE_OPERAND(exp, 1), &Tmp);
-  EmitAggregateCopy(NewLoc, Tmp, TREE_TYPE(TREE_OPERAND(exp,1)));
-}
 return 0;
   }
 

Modified: llvm-gcc-4.0/trunk/gcc/llvm-internal.h
URL: 
http://llvm.org/vie

Re: [llvm-commits] [llvm] r46372 - /llvm/trunk/test/CFrontend/2008-01-25-ByValReadNone.c

2008-01-25 Thread Evan Cheng
How would this test case pass if the target does not pass structs byval?

Evan

On Jan 25, 2008, at 2:36 PM, Chris Lattner wrote:

> Author: lattner
> Date: Fri Jan 25 16:36:24 2008
> New Revision: 46372
>
> URL: http://llvm.org/viewvc/llvm-project?rev=46372&view=rev
> Log:
> add a testcase for a bug Duncan pointed out.
>
> Added:
> llvm/trunk/test/CFrontend/2008-01-25-ByValReadNone.c
>
> Added: llvm/trunk/test/CFrontend/2008-01-25-ByValReadNone.c
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CFrontend/ 
> 2008-01-25-ByValReadNone.c?rev=46372&view=auto
>
> == 
> 
> --- llvm/trunk/test/CFrontend/2008-01-25-ByValReadNone.c (added)
> +++ llvm/trunk/test/CFrontend/2008-01-25-ByValReadNone.c Fri Jan 25  
> 16:36:24 2008
> @@ -0,0 +1,10 @@
> +// RUN: %llvmgcc -O3 -S -o - -emit-llvm %s | grep readonly
> +// RUN: %llvmgcc -O3 -S -o - -emit-llvm %s | not grep readnone
> +
> +
> +// The struct being passed byval means that we need to mark the
> +// function readonly instead of readnone.  Readnone would allow
> +// stores to the arg to be deleted in the caller.
> +struct S { int A[1000]; };
> +int __attribute__ ((const)) f(struct S x) { return x.A[0]; }
> +
>
>
> ___
> llvm-commits mailing list
> llvm-commits@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r46387 - in /llvm/trunk: lib/Transforms/Scalar/SimplifyCFG.cpp test/CFrontend/2008-01-25-EmptyFunction.c

2008-01-25 Thread Bill Wendling
Author: void
Date: Fri Jan 25 19:43:44 2008
New Revision: 46387

URL: http://llvm.org/viewvc/llvm-project?rev=46387&view=rev
Log:
If we have a function like this:

void bork() {
  int *address = 0;
  *address = 0;
}

It's compiled into LLVM code that looks like this:

define void @bork() noreturn nounwind  {
entry:
unreachable
}

This is bad on some platforms (like PPC) because it will generate the label for
the function but no body. The label could end up being associated with some
non-code related stuff, like a section. This places a "trap" instruction if the
SimplifyCFG pass removed all code from the function leaving only one
"unreachable" instruction.

Added:
llvm/trunk/test/CFrontend/2008-01-25-EmptyFunction.c
Modified:
llvm/trunk/lib/Transforms/Scalar/SimplifyCFG.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyCFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyCFG.cpp?rev=46387&r1=46386&r2=46387&view=diff

==
--- llvm/trunk/lib/Transforms/Scalar/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SimplifyCFG.cpp Fri Jan 25 19:43:44 2008
@@ -26,6 +26,7 @@
 #include "llvm/Transforms/Utils/Local.h"
 #include "llvm/Constants.h"
 #include "llvm/Instructions.h"
+#include "llvm/Intrinsics.h"
 #include "llvm/Module.h"
 #include "llvm/ParameterAttributes.h"
 #include "llvm/Support/CFG.h"
@@ -154,8 +155,20 @@
   bool Changed = MarkAliveBlocks(F.begin(), Reachable);
   
   // If there are unreachable blocks in the CFG...
-  if (Reachable.size() == F.size())
+  if (Reachable.size() == F.size()) {
+if (F.size() == 1) {
+  // If the function has only one block with an "unreachable" instruction,
+  // then we should create *some* code for it. Issue a "trap" instead.
+  BasicBlock &BB = F.front();
+
+  if (BB.size() == 1 && dyn_cast(&BB.front()))
+new CallInst(Intrinsic::getDeclaration(F.getParent(),
+   Intrinsic::trap),
+ "", &BB.front());
+}
+
 return Changed;
+  }
   
   assert(Reachable.size() < F.size());
   NumSimpl += F.size()-Reachable.size();

Added: llvm/trunk/test/CFrontend/2008-01-25-EmptyFunction.c
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CFrontend/2008-01-25-EmptyFunction.c?rev=46387&view=auto

==
--- llvm/trunk/test/CFrontend/2008-01-25-EmptyFunction.c (added)
+++ llvm/trunk/test/CFrontend/2008-01-25-EmptyFunction.c Fri Jan 25 19:43:44 
2008
@@ -0,0 +1,7 @@
+// RUN: %llvmgcc -O2 -S -o - -emit-llvm %s | grep llvm.trap
+// RUN: %llvmgcc -O2 -S -o - -emit-llvm %s | grep unreachable
+
+void bork() {
+  int *address = 0;
+  *address = 0;
+}


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r46387 - in /llvm/trunk: lib/Transforms/Scalar/SimplifyCFG.cpp test/CFrontend/2008-01-25-EmptyFunction.c

2008-01-25 Thread Chris Lattner
On Jan 25, 2008, at 5:43 PM, Bill Wendling wrote:
> URL: http://llvm.org/viewvc/llvm-project?rev=46387&view=rev
> Log:
> If we have a function like this:
>
> This is bad on some platforms (like PPC) because it will generate  
> the label for
> the function but no body. The label could end up being associated  
> with some
> non-code related stuff, like a section. This places a "trap"  
> instruction if the
> SimplifyCFG pass removed all code from the function leaving only one
> "unreachable" instruction.

This is a darwin-specific hack, so it needs to be conditionalized on  
the target.  Second, this should only be done if there are zero  
machineinstrs, not zero llvm instrs.

>   // If there are unreachable blocks in the CFG...
> -  if (Reachable.size() == F.size())
> +  if (Reachable.size() == F.size()) {
> +if (F.size() == 1) {

F.size() is linear time, so you shouldn't call it here if you don't  
need it.  Why are you doing this in the Reachable.size() == F.size()  
case?

> +  // If the function has only one block with an "unreachable"  
> instruction,
> +  // then we should create *some* code for it. Issue a "trap"  
> instead.
> +  BasicBlock &BB = F.front();
> +
> +  if (BB.size() == 1 && dyn_cast(&BB.front()))

Only use dyn_cast if you want the result: use isa in this case.   
BB.size() is also linear time.

Finally, the testcase you added was for llvm-gcc, this is a codegen  
thing so it should be in test/CodeGen/* and should only run llc.

-Chris

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm-gcc-4.2] r46391 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h

2008-01-25 Thread Duncan Sands
Author: baldrick
Date: Fri Jan 25 23:33:48 2008
New Revision: 46391

URL: http://llvm.org/viewvc/llvm-project?rev=46391&view=rev
Log:
Correct spelling.

Modified:
llvm-gcc-4.2/trunk/gcc/llvm-abi.h

Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=46391&r1=46390&r2=46391&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Fri Jan 25 23:33:48 2008
@@ -228,7 +228,7 @@
   } else if (LLVM_SHOULD_PASS_AGGREGATE_IN_INTEGER_REGS(type)) {
 PassInIntegerRegisters(type, Ty);
   } else if (isAggregateOfSizeZero(type)) {
-// Zero sized aggregare, just drop it!
+// Zero sized aggregate, just drop it!
 ;
   } else if (TREE_CODE(type) == RECORD_TYPE) {
 for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field))


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm-gcc-4.2] r46373 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

2008-01-25 Thread Duncan Sands
> If a function takes a byval parameter, it can't be readnone, we 
> have to mark it readonly instead.  This fixes
> test/CFrontend/2008-01-25-ByValReadNone.c

Thanks for doing this!

Duncan.
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r46395 - in /llvm/trunk/test: CFrontend/2008-01-25-EmptyFunction.c CodeGen/PowerPC/2008-01-25-EmptyFunction.c

2008-01-25 Thread Bill Wendling
Author: void
Date: Sat Jan 26 00:53:06 2008
New Revision: 46395

URL: http://llvm.org/viewvc/llvm-project?rev=46395&view=rev
Log:
Move testcase to the code gen directory.

Added:
llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.c
  - copied unchanged from r46390, 
llvm/trunk/test/CFrontend/2008-01-25-EmptyFunction.c
Removed:
llvm/trunk/test/CFrontend/2008-01-25-EmptyFunction.c

Removed: llvm/trunk/test/CFrontend/2008-01-25-EmptyFunction.c
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CFrontend/2008-01-25-EmptyFunction.c?rev=46394&view=auto

==
--- llvm/trunk/test/CFrontend/2008-01-25-EmptyFunction.c (original)
+++ llvm/trunk/test/CFrontend/2008-01-25-EmptyFunction.c (removed)
@@ -1,7 +0,0 @@
-// RUN: %llvmgcc -O2 -S -o - -emit-llvm %s | grep llvm.trap
-// RUN: %llvmgcc -O2 -S -o - -emit-llvm %s | grep unreachable
-
-void bork() {
-  int *address = 0;
-  *address = 0;
-}


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r46396 - in /llvm/trunk/test/CodeGen/PowerPC: 2008-01-25-EmptyFunction.c 2008-01-25-EmptyFunction.ll

2008-01-25 Thread Bill Wendling
Author: void
Date: Sat Jan 26 00:53:40 2008
New Revision: 46396

URL: http://llvm.org/viewvc/llvm-project?rev=46396&view=rev
Log:
Rename the .c to .ll

Added:
llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.ll
  - copied unchanged from r46395, 
llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.c
Removed:
llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.c

Removed: llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.c
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.c?rev=46395&view=auto

==
--- llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.c (original)
+++ llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.c (removed)
@@ -1,7 +0,0 @@
-// RUN: %llvmgcc -O2 -S -o - -emit-llvm %s | grep llvm.trap
-// RUN: %llvmgcc -O2 -S -o - -emit-llvm %s | grep unreachable
-
-void bork() {
-  int *address = 0;
-  *address = 0;
-}


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r46397 - /llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.ll

2008-01-25 Thread Bill Wendling
Author: void
Date: Sat Jan 26 00:56:08 2008
New Revision: 46397

URL: http://llvm.org/viewvc/llvm-project?rev=46397&view=rev
Log:
Need to convert to LLVM code and not C.

Modified:
llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.ll

Modified: llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.ll
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.ll?rev=46397&r1=46396&r2=46397&view=diff

==
--- llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/2008-01-25-EmptyFunction.ll Sat Jan 26 
00:56:08 2008
@@ -1,7 +1,6 @@
-// RUN: %llvmgcc -O2 -S -o - -emit-llvm %s | grep llvm.trap
-// RUN: %llvmgcc -O2 -S -o - -emit-llvm %s | grep unreachable
+; RUN: llvm-as < %s | llc -march=ppc32 | grep nop
 
-void bork() {
-  int *address = 0;
-  *address = 0;
+define void @bork() noreturn nounwind  {
+entry:
+unreachable
 }


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm-gcc-4.2] r46381 - in /llvm-gcc-4.2/trunk/gcc: llvm-abi.h llvm-internal.h llvm-types.cpp

2008-01-25 Thread Duncan Sands
Hi Evan, dropping zero sized aggregates from types
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20080121/057570.html
broke the Ada build.  A zero-sized aggregate is used in a COMPONENT_REF, so
llvm-convert barfs because it can't find the corresponding LLVM field.  All gcc
fields should have a corresponding LLVM field - the only exception we make is
for fields at variable offsets.  I would like to keep it that way unless you
really can't solve this differently.

Best wishes,

Duncan.
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r46372 - /llvm/trunk/test/CFrontend/2008-01-25-ByValReadNone.c

2008-01-25 Thread Chris Lattner
On Jan 25, 2008, at 4:35 PM, Evan Cheng wrote:
> How would this test case pass if the target does not pass structs  
> byval?

That's why I picked a big struct.  :)

-Chris

>
> Evan
>
> On Jan 25, 2008, at 2:36 PM, Chris Lattner wrote:
>
>> Author: lattner
>> Date: Fri Jan 25 16:36:24 2008
>> New Revision: 46372
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=46372&view=rev
>> Log:
>> add a testcase for a bug Duncan pointed out.
>>
>> Added:
>>llvm/trunk/test/CFrontend/2008-01-25-ByValReadNone.c
>>
>> Added: llvm/trunk/test/CFrontend/2008-01-25-ByValReadNone.c
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CFrontend/
>> 2008-01-25-ByValReadNone.c?rev=46372&view=auto
>>
>> = 
>> =
>> 
>> --- llvm/trunk/test/CFrontend/2008-01-25-ByValReadNone.c (added)
>> +++ llvm/trunk/test/CFrontend/2008-01-25-ByValReadNone.c Fri Jan 25
>> 16:36:24 2008
>> @@ -0,0 +1,10 @@
>> +// RUN: %llvmgcc -O3 -S -o - -emit-llvm %s | grep readonly
>> +// RUN: %llvmgcc -O3 -S -o - -emit-llvm %s | not grep readnone
>> +
>> +
>> +// The struct being passed byval means that we need to mark the
>> +// function readonly instead of readnone.  Readnone would allow
>> +// stores to the arg to be deleted in the caller.
>> +struct S { int A[1000]; };
>> +int __attribute__ ((const)) f(struct S x) { return x.A[0]; }
>> +
>>
>>
>> ___
>> llvm-commits mailing list
>> llvm-commits@cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
> ___
> llvm-commits mailing list
> llvm-commits@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r46384 - in /llvm/trunk: lib/CodeGen/SelectionDAG/DAGCombiner.cpp test/CodeGen/Generic/2008-01-25-dag-combine-mul.ll

2008-01-25 Thread Chris Lattner
Author: lattner
Date: Fri Jan 25 19:09:19 2008
New Revision: 46384

URL: http://llvm.org/viewvc/llvm-project?rev=46384&view=rev
Log:
Fix some bugs in SimplifyNodeWithTwoResults where it would call deletenode to 
delete a node even if it was not dead in some cases.  Instead, just add it to
the worklist.  Also, make sure to use the CombineTo methods, as it was doing
things that were unsafe: the top level combine loop could touch dangling memory.

This fixes CodeGen/Generic/2008-01-25-dag-combine-mul.ll


Added:
llvm/trunk/test/CodeGen/Generic/2008-01-25-dag-combine-mul.ll
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=46384&r1=46383&r2=46384&view=diff

==
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Fri Jan 25 19:09:19 2008
@@ -277,7 +277,8 @@
bool NotExtCompare = false);
 SDOperand SimplifySetCC(MVT::ValueType VT, SDOperand N0, SDOperand N1,
 ISD::CondCode Cond, bool foldBooleans = true);
-bool SimplifyNodeWithTwoResults(SDNode *N, unsigned LoOp, unsigned HiOp);
+SDOperand SimplifyNodeWithTwoResults(SDNode *N, unsigned LoOp, 
+ unsigned HiOp);
 SDOperand ConstantFoldBIT_CONVERTofBUILD_VECTOR(SDNode *, MVT::ValueType);
 SDOperand BuildSDIV(SDNode *N);
 SDOperand BuildUDIV(SDNode *N);
@@ -586,6 +587,7 @@
   continue;
 
 ++NodesCombined;
+
 // If we get back the same node we passed in, rather than a new node or
 // zero, we know that the node must have defined multiple values and
 // CombineTo was used.  Since CombineTo takes care of the worklist 
@@ -604,7 +606,8 @@
 if (N->getNumValues() == RV.Val->getNumValues())
   DAG.ReplaceAllUsesWith(N, RV.Val, &NowDead);
 else {
-  assert(N->getValueType(0) == RV.getValueType() && "Type mismatch");
+  assert(N->getValueType(0) == RV.getValueType() &&
+ N->getNumValues() == 1 && "Type mismatch");
   SDOperand OpV = RV;
   DAG.ReplaceAllUsesWith(N, &OpV, &NowDead);
 }
@@ -1311,6 +1314,7 @@
   // X%C to the equivalent of X-X/C*C.
   if (N1C && !N1C->isNullValue()) {
 SDOperand Div = DAG.getNode(ISD::SDIV, VT, N0, N1);
+AddToWorkList(Div.Val);
 SDOperand OptimizedDiv = combine(Div.Val);
 if (OptimizedDiv.Val && OptimizedDiv.Val != Div.Val) {
   SDOperand Mul = DAG.getNode(ISD::MUL, VT, OptimizedDiv, N1);
@@ -1421,18 +1425,16 @@
 /// compute two values. LoOp and HiOp give the opcodes for the two computations
 /// that are being performed. Return true if a simplification was made.
 ///
-bool DAGCombiner::SimplifyNodeWithTwoResults(SDNode *N,
- unsigned LoOp, unsigned HiOp) {
+SDOperand DAGCombiner::SimplifyNodeWithTwoResults(SDNode *N, unsigned LoOp, 
+  unsigned HiOp) {
   // If the high half is not needed, just compute the low half.
   bool HiExists = N->hasAnyUseOfValue(1);
   if (!HiExists &&
   (!AfterLegalize ||
TLI.isOperationLegal(LoOp, N->getValueType(0 {
-DAG.ReplaceAllUsesOfValueWith(SDOperand(N, 0),
-  DAG.getNode(LoOp, N->getValueType(0),
-  N->op_begin(),
-  N->getNumOperands()));
-return true;
+SDOperand Res = DAG.getNode(LoOp, N->getValueType(0), N->op_begin(),
+N->getNumOperands());
+return CombineTo(N, Res, Res);
   }
 
   // If the low half is not needed, just compute the high half.
@@ -1440,74 +1442,62 @@
   if (!LoExists &&
   (!AfterLegalize ||
TLI.isOperationLegal(HiOp, N->getValueType(1 {
-DAG.ReplaceAllUsesOfValueWith(SDOperand(N, 1),
-  DAG.getNode(HiOp, N->getValueType(1),
-  N->op_begin(),
-  N->getNumOperands()));
-return true;
+SDOperand Res = DAG.getNode(HiOp, N->getValueType(1), N->op_begin(),
+N->getNumOperands());
+return CombineTo(N, Res, Res);
   }
 
   // If both halves are used, return as it is.
   if (LoExists && HiExists)
-return false;
+return SDOperand();
 
   // If the two computed results can be simplified separately, separate them.
-  bool RetVal = false;
   if (LoExists) {
 SDOperand Lo = DAG.getNode(LoOp, N->getValueType(0),
N->op_begin(), N->getNumOperands());
+AddToWorkList(Lo.Val);
 SDOperand LoOpt = combine(Lo.Val);
-if (LoOpt.Val && LoOpt != Lo &&
-TLI.isOperationLe

[llvm-commits] [llvm] r46383 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

2008-01-25 Thread Chris Lattner
Author: lattner
Date: Fri Jan 25 19:05:42 2008
New Revision: 46383

URL: http://llvm.org/viewvc/llvm-project?rev=46383&view=rev
Log:
don't bother making x&-1 only to simplify it in dag combine.  This commonly 
occurs expanding i64 ops.

Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=46383&r1=46382&r2=46383&view=diff

==
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Fri Jan 25 19:05:42 
2008
@@ -1877,6 +1877,8 @@
 // worth handling here.
 if (N2C && N2C->getValue() == 0)
   return N2;
+if (N2C && N2C->isAllOnesValue())  // X & -1 -> X
+  return N1;
 break;
   case ISD::OR:
   case ISD::XOR:


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r46382 - /llvm/trunk/test/CFrontend/2008-01-25-ZeroSizedAggregate.c

2008-01-25 Thread Evan Cheng
Author: evancheng
Date: Fri Jan 25 18:35:43 2008
New Revision: 46382

URL: http://llvm.org/viewvc/llvm-project?rev=46382&view=rev
Log:
New test case.

Added:
llvm/trunk/test/CFrontend/2008-01-25-ZeroSizedAggregate.c

Added: llvm/trunk/test/CFrontend/2008-01-25-ZeroSizedAggregate.c
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CFrontend/2008-01-25-ZeroSizedAggregate.c?rev=46382&view=auto

==
--- llvm/trunk/test/CFrontend/2008-01-25-ZeroSizedAggregate.c (added)
+++ llvm/trunk/test/CFrontend/2008-01-25-ZeroSizedAggregate.c Fri Jan 25 
18:35:43 2008
@@ -0,0 +1,23 @@
+// RUN: %llvmgcc %s -S -o -
+
+// Aggregates of size zero should be dropped from argument list.
+typedef long int Tlong;
+struct S2411 {
+  __attribute__((aligned)) Tlong:0;
+};
+
+extern struct S2411 a2411[5];
+extern void checkx2411(struct S2411);
+void test2411(void) {
+  checkx2411(a2411[0]);
+}
+
+// A field that is an aggregates of size zero should be dropped during
+// type conversion.
+typedef unsigned long long int Tal2ullong __attribute__((aligned(2)));
+struct S2525 {
+ Tal2ullong: 0;
+ struct {
+ } e;
+};
+struct S2525 s2525;


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm-gcc-4.2] r46381 - in /llvm-gcc-4.2/trunk/gcc: llvm-abi.h llvm-internal.h llvm-types.cpp

2008-01-25 Thread Evan Cheng
Author: evancheng
Date: Fri Jan 25 18:17:32 2008
New Revision: 46381

URL: http://llvm.org/viewvc/llvm-project?rev=46381&view=rev
Log:
Also drop zero-sized aggregates during type conversion.

Modified:
llvm-gcc-4.2/trunk/gcc/llvm-abi.h
llvm-gcc-4.2/trunk/gcc/llvm-internal.h
llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=46381&r1=46380&r2=46381&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Fri Jan 25 18:17:32 2008
@@ -120,13 +120,6 @@
   }
 }
 
-/// isAggregareOfSizeZero - Returns true if this is an aggregate with size 
zero.
-///
-static bool isAggregareOfSizeZero(tree type) {
-  if (!isAggregateTreeType(type)) return false;
-  return int_size_in_bytes(type) == 0;
-}
-
 // LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR - Return true if this aggregate
 // value should be passed by value, i.e. passing its address with the byval
 // attribute bit set. The default is false.
@@ -234,7 +227,7 @@
 PassInMixedRegisters(type, Ty, Elts);
   } else if (LLVM_SHOULD_PASS_AGGREGATE_IN_INTEGER_REGS(type)) {
 PassInIntegerRegisters(type, Ty);
-  } else if (isAggregareOfSizeZero(type)) {
+  } else if (isAggregateOfSizeZero(type)) {
 // Zero sized aggregare, just drop it!
 ;
   } else if (TREE_CODE(type) == RECORD_TYPE) {

Modified: llvm-gcc-4.2/trunk/gcc/llvm-internal.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-internal.h?rev=46381&r1=46380&r2=46381&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/llvm-internal.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-internal.h Fri Jan 25 18:17:32 2008
@@ -118,6 +118,10 @@
 /// element added to match llvm struct type size and gcc struct type size.
 bool isPaddingElement(const Type *T, unsigned N);
 
+/// isAggregateOfSizeZero - Returns true if this is an aggregate with size 
zero.
+///
+bool isAggregateOfSizeZero(union tree_node*);
+
 /// TypeConverter - Implement the converter from GCC types to LLVM types.
 ///
 class TypeConverter {

Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=46381&r1=46380&r2=46381&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Fri Jan 25 18:17:32 2008
@@ -1610,6 +1610,14 @@
 
 }
 
+/// isAggregateOfSizeZero - Returns true if this is an aggregate with size 
zero.
+///
+bool isAggregateOfSizeZero(tree type) {
+  if (!isAggregateTreeType(type)) return false;
+  return int_size_in_bytes(type) == 0;
+}
+
+
 /// Mapping from type to type-used-as-base-class and back.
 static DenseMap BaseTypesMap;
 
@@ -2044,6 +2052,9 @@
   unsigned FieldOffsetInBits = getFieldOffsetInBits(Field);
   tree FieldType = getDeclaredType(Field);
 
+  if (isAggregateOfSizeZero(FieldType))
+continue;
+
   // If this is a bitfield, we may want to adjust the FieldOffsetInBits to
   // produce safe code.  In particular, bitfields will be loaded/stored as
   // their *declared* type, not the smallest integer type that contains


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r46377 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2008-01-25 Thread Chris Lattner
Author: lattner
Date: Fri Jan 25 17:34:24 2008
New Revision: 46377

URL: http://llvm.org/viewvc/llvm-project?rev=46377&view=rev
Log:
reduce indentation

Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=46377&r1=46376&r2=46377&view=diff

==
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Fri Jan 25 17:34:24 2008
@@ -582,49 +582,51 @@
 
 SDOperand RV = combine(N);
 
-if (RV.Val) {
-  ++NodesCombined;
-  // If we get back the same node we passed in, rather than a new node or
-  // zero, we know that the node must have defined multiple values and
-  // CombineTo was used.  Since CombineTo takes care of the worklist 
-  // mechanics for us, we have no work to do in this case.
-  if (RV.Val != N) {
-assert(N->getOpcode() != ISD::DELETED_NODE &&
-   RV.Val->getOpcode() != ISD::DELETED_NODE &&
-   "Node was deleted but visit returned new node!");
+if (RV.Val == 0)
+  continue;
+
+++NodesCombined;
+// If we get back the same node we passed in, rather than a new node or
+// zero, we know that the node must have defined multiple values and
+// CombineTo was used.  Since CombineTo takes care of the worklist 
+// mechanics for us, we have no work to do in this case.
+if (RV.Val == N)
+  continue;
+
+assert(N->getOpcode() != ISD::DELETED_NODE &&
+   RV.Val->getOpcode() != ISD::DELETED_NODE &&
+   "Node was deleted but visit returned new node!");
 
-DOUT << "\nReplacing.3 "; DEBUG(N->dump(&DAG));
-DOUT << "\nWith: "; DEBUG(RV.Val->dump(&DAG));
-DOUT << '\n';
-std::vector NowDead;
-if (N->getNumValues() == RV.Val->getNumValues())
-  DAG.ReplaceAllUsesWith(N, RV.Val, &NowDead);
-else {
-  assert(N->getValueType(0) == RV.getValueType() && "Type mismatch");
-  SDOperand OpV = RV;
-  DAG.ReplaceAllUsesWith(N, &OpV, &NowDead);
-}
-  
-// Push the new node and any users onto the worklist
-AddToWorkList(RV.Val);
-AddUsersToWorkList(RV.Val);
-
-// Add any uses of the old node to the worklist in case this node is 
the
-// last one that uses them.  They may become dead after this node is
-// deleted.
-for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
-  AddToWorkList(N->getOperand(i).Val);
-  
-// Nodes can be reintroduced into the worklist.  Make sure we do not
-// process a node that has been replaced.
-removeFromWorkList(N);
-for (unsigned i = 0, e = NowDead.size(); i != e; ++i)
-  removeFromWorkList(NowDead[i]);
-
-// Finally, since the node is now dead, remove it from the graph.
-DAG.DeleteNode(N);
-  }
+DOUT << "\nReplacing.3 "; DEBUG(N->dump(&DAG));
+DOUT << "\nWith: "; DEBUG(RV.Val->dump(&DAG));
+DOUT << '\n';
+std::vector NowDead;
+if (N->getNumValues() == RV.Val->getNumValues())
+  DAG.ReplaceAllUsesWith(N, RV.Val, &NowDead);
+else {
+  assert(N->getValueType(0) == RV.getValueType() && "Type mismatch");
+  SDOperand OpV = RV;
+  DAG.ReplaceAllUsesWith(N, &OpV, &NowDead);
 }
+  
+// Push the new node and any users onto the worklist
+AddToWorkList(RV.Val);
+AddUsersToWorkList(RV.Val);
+
+// Add any uses of the old node to the worklist in case this node is the
+// last one that uses them.  They may become dead after this node is
+// deleted.
+for (unsigned i = 0, e = N->getNumOperands(); i != e; ++i)
+  AddToWorkList(N->getOperand(i).Val);
+  
+// Nodes can be reintroduced into the worklist.  Make sure we do not
+// process a node that has been replaced.
+removeFromWorkList(N);
+for (unsigned i = 0, e = NowDead.size(); i != e; ++i)
+  removeFromWorkList(NowDead[i]);
+
+// Finally, since the node is now dead, remove it from the graph.
+DAG.DeleteNode(N);
   }
   
   // If the root changed (e.g. it was a dead load, update the root).


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r46394 - in /llvm/trunk/lib: Target/PowerPC/PPCAsmPrinter.cpp Transforms/Scalar/SimplifyCFG.cpp

2008-01-25 Thread Bill Wendling
Author: void
Date: Sat Jan 26 00:51:24 2008
New Revision: 46394

URL: http://llvm.org/viewvc/llvm-project?rev=46394&view=rev
Log:
If there are no machine instructions emitted for a function, then insert
a "nop" instruction so that we don't have the function's label associated
with something that it's not supposed to be associated with.


Modified:
llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
llvm/trunk/lib/Transforms/Scalar/SimplifyCFG.cpp

Modified: llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp?rev=46394&r1=46393&r2=46394&view=diff

==
--- llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp Sat Jan 26 00:51:24 2008
@@ -30,6 +30,7 @@
 #include "llvm/CodeGen/MachineModuleInfo.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/CodeGen/MachineInstrBuilder.h"
 #include "llvm/Support/Mangler.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/CommandLine.h"
@@ -813,6 +814,18 @@
   // Emit pre-function debug information.
   DW.BeginFunction(&MF);
 
+  // If the function is empty, then we need to emit *something*. Otherwise, the
+  // function's label might be associated with something that it wasn't meant 
to
+  // be associated with. We emit a noop in this situation.
+  MachineFunction::iterator I = MF.begin();
+
+  if (++I == MF.end()) {
+MachineBasicBlock &MBB = MF.front();
+
+if (MBB.begin() == MBB.end())
+  BuildMI(MBB, MBB.end(), TM.getInstrInfo()->get(PPC::NOP));
+  }
+
   // Print out code for the function.
   for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
I != E; ++I) {
@@ -821,8 +834,8 @@
   printBasicBlockLabel(I, true);
   O << '\n';
 }
-for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
- II != E; ++II) {
+for (MachineBasicBlock::const_iterator II = I->begin(), IE = I->end();
+ II != IE; ++II) {
   // Print the assembly for the instruction.
   O << "\t";
   printMachineInstruction(II);

Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyCFG.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyCFG.cpp?rev=46394&r1=46393&r2=46394&view=diff

==
--- llvm/trunk/lib/Transforms/Scalar/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SimplifyCFG.cpp Sat Jan 26 00:51:24 2008
@@ -26,7 +26,6 @@
 #include "llvm/Transforms/Utils/Local.h"
 #include "llvm/Constants.h"
 #include "llvm/Instructions.h"
-#include "llvm/Intrinsics.h"
 #include "llvm/Module.h"
 #include "llvm/ParameterAttributes.h"
 #include "llvm/Support/CFG.h"
@@ -155,20 +154,8 @@
   bool Changed = MarkAliveBlocks(F.begin(), Reachable);
   
   // If there are unreachable blocks in the CFG...
-  if (Reachable.size() == F.size()) {
-if (F.size() == 1) {
-  // If the function has only one block with an "unreachable" instruction,
-  // then we should create *some* code for it. Issue a "trap" instead.
-  BasicBlock &BB = F.front();
-
-  if (BB.size() == 1 && dyn_cast(&BB.front()))
-new CallInst(Intrinsic::getDeclaration(F.getParent(),
-   Intrinsic::trap),
- "", &BB.front());
-}
-
+  if (Reachable.size() == F.size())
 return Changed;
-  }
   
   assert(Reachable.size() < F.size());
   NumSimpl += F.size()-Reachable.size();


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm-gcc-4.2] r46392 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

2008-01-25 Thread Duncan Sands
Author: baldrick
Date: Sat Jan 26 00:03:12 2008
New Revision: 46392

URL: http://llvm.org/viewvc/llvm-project?rev=46392&view=rev
Log:
Silence a warning.

Modified:
llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=46392&r1=46391&r2=46392&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Sat Jan 26 00:03:12 2008
@@ -1796,7 +1796,7 @@
 return false;
   } 
   else if (TYPE_USER_ALIGN(TREE_TYPE(Field))
-   && DECL_ALIGN_UNIT(Field) != Info.getTypeAlignment(Ty)
+   && (unsigned)DECL_ALIGN_UNIT(Field) != Info.getTypeAlignment(Ty)
&& !Info.isPacked()) {
 // If Field has user defined alignment and it does not match Ty alignment
 // then convert to a packed struct and try again.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r46360 - /llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h

2008-01-25 Thread Chris Lattner

On Jan 25, 2008, at 2:05 PM, Dale Johannesen wrote:

>
> On Jan 25, 2008, at 9:49 AM, Chris Lattner wrote:
>
>> Author: lattner
>> Date: Fri Jan 25 11:49:41 2008
>> New Revision: 46360
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=46360&view=rev
>> Log:
>> Reorder a field to reduce the size of StackObject.  Note that this
>> may require a clean rebuild on leopard. :(
>
> Does this indicate a bug in the header dependency machinery?

I think it's a bug in leopard make or in something else leopard  
related.  I started noticing these problems when I upgrade my machines.

-Chris
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm-gcc-4.2] r46373 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

2008-01-25 Thread Chris Lattner
Author: lattner
Date: Fri Jan 25 16:37:31 2008
New Revision: 46373

URL: http://llvm.org/viewvc/llvm-project?rev=46373&view=rev
Log:
If a function takes a byval parameter, it can't be readnone, we 
have to mark it readonly instead.  This fixes
test/CFrontend/2008-01-25-ByValReadNone.c


Modified:
llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=46373&r1=46372&r2=46373&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Fri Jan 25 16:37:31 2008
@@ -1123,18 +1123,17 @@
   // accepts it).  But llvm IR does not allow both, so
   // set only ReadNone.
   if (flags & ECF_CONST)
-// Since they write the return value through a pointer,
-// 'sret' functions cannot be 'readnone'.
-if (!ABIConverter.isStructReturn())
-  RAttributes |= ParamAttr::ReadNone;
+RAttributes |= ParamAttr::ReadNone;
 
   // Check for 'readonly' function attribute.
   if (flags & ECF_PURE && !(flags & ECF_CONST))
-// Since they write the return value through a pointer,
-// 'sret' functions cannot be 'readonly'.
-if (!ABIConverter.isStructReturn())
-  RAttributes |= ParamAttr::ReadOnly;
+RAttributes |= ParamAttr::ReadOnly;
 
+  // Since they write the return value through a pointer,
+  // 'sret' functions cannot be 'readnone' or 'readonly'.
+  if (ABIConverter.isStructReturn())
+RAttributes &= ~(ParamAttr::ReadNone|ParamAttr::ReadOnly);
+  
   // Compute whether the result needs to be zext or sext'd.
   RAttributes |= HandleArgumentExtension(TREE_TYPE(type));
 
@@ -1162,6 +1161,9 @@
   LLVM_TARGET_INIT_REGPARM(local_regparam, type);
 #endif // LLVM_TARGET_ENABLE_REGPARM
   
+  // Keep track of whether we see a byval argument.
+  bool HasByVal = false;
+  
   // Check if we have a corresponding decl to inspect.
   tree DeclArgs = (decl) ? DECL_ARGUMENTS(decl) : NULL;
   // Loop over all of the arguments, adding them as we go.
@@ -1208,13 +1210,25 @@
 local_regparam);
 #endif // LLVM_TARGET_ENABLE_REGPARM
 
-if (Attributes != ParamAttr::None)
+if (Attributes != ParamAttr::None) {
+  HasByVal |= Attributes & ParamAttr::ByVal;
   Attrs.push_back(ParamAttrsWithIndex::get(ArgTypes.size(), Attributes));
+}
   
 if (DeclArgs)
   DeclArgs = TREE_CHAIN(DeclArgs);
   }
   
+  // If we see a byval argument and if the function is 'readonly' we have to
+  // demote the function to being 'readonly' instead.  Not doing so would allow
+  // optimizers to delete stores into the argument that is passed into the
+  // function.
+  if (HasByVal && Attrs[0].index == 0 &&
+  (Attrs[0].attrs & ParamAttr::ReadNone)) {
+Attrs[0].attrs &= ~ParamAttr::ReadNone;
+Attrs[0].attrs |= ParamAttr::ReadOnly;
+  }
+  
   // If the argument list ends with a void type node, it isn't vararg.
   isVarArg = (Args == 0);
   assert(RetTy && "Return type not specified!");


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r46369 - /llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp

2008-01-25 Thread Duncan Sands
Author: baldrick
Date: Fri Jan 25 16:06:51 2008
New Revision: 46369

URL: http://llvm.org/viewvc/llvm-project?rev=46369&view=rev
Log:
Do this more neatly.

Modified:
llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp

Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=46369&r1=46368&r2=46369&view=diff

==
--- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Fri Jan 25 16:06:51 2008
@@ -245,8 +245,7 @@
   // or readnone, because the copy would be unneeded: the callee doesn't
   // modify the struct.
   if (CalledFunc->paramHasAttr(ArgNo+1, ParamAttr::ByVal) &&
-  !CalledFunc->paramHasAttr(0, ParamAttr::ReadOnly) &&
-  !CalledFunc->paramHasAttr(0, ParamAttr::ReadNone)) {
+  !CalledFunc->onlyReadsMemory()) {
 const Type *AggTy = cast(I->getType())->getElementType();
 const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty);
 


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r46337 - in /llvm/trunk/lib/Target/X86: X86RegisterInfo.cpp X86RegisterInfo.h X86RegisterInfo.td

2008-01-25 Thread Evan Cheng
Hi Anton,

Here is a silly test case:

#include 
struct ss {
   int x;
   int y;
};
void f(int a, struct ss b) {
=>printf("%d %d\n", a, b.x);
}
int main() {
   struct ss S = {1, 2};
   f(0, S);
   return 0;
}

Problem 1:
(gdb) b main
Line number not known for symbol "main"
Explicitly setting a breakpoint on line 10 works.

Problem 2:
In function f().
(gdb) p a
$2 = -1073743868
(gdb) p b
$3 = {
   x = 2,
   y = 0
}

Any ideas?

Evan

On Jan 24, 2008, at 9:41 PM, Anton Korobeynikov wrote:

> Evan,
>
>> This allows gdb to examine local scalar variables, but not aggregate
>> ones. There are also issues with parameters, even scalar ones.
> Ok. Any other testcases? Owen, ready for another session? :)
>
> -- 
> With best regards, Anton Korobeynikov.
>
> Faculty of Mathematics & Mechanics, Saint Petersburg State University.
>
>
> ___
> llvm-commits mailing list
> llvm-commits@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r46357 - /llvm/trunk/test/C++Frontend/2008-01-25-ResultIsParam.cpp

2008-01-25 Thread Duncan Sands
Author: baldrick
Date: Fri Jan 25 11:36:44 2008
New Revision: 46357

URL: http://llvm.org/viewvc/llvm-project?rev=46357&view=rev
Log:
Test for PR1942.

Added:
llvm/trunk/test/C++Frontend/2008-01-25-ResultIsParam.cpp

Added: llvm/trunk/test/C++Frontend/2008-01-25-ResultIsParam.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/C%2B%2BFrontend/2008-01-25-ResultIsParam.cpp?rev=46357&view=auto

==
--- llvm/trunk/test/C++Frontend/2008-01-25-ResultIsParam.cpp (added)
+++ llvm/trunk/test/C++Frontend/2008-01-25-ResultIsParam.cpp Fri Jan 25 
11:36:44 2008
@@ -0,0 +1,23 @@
+// RUN: %llvmgcc %s -S -o - | not grep [EMAIL PROTECTED]
+// PR1942
+
+class foo
+{
+public:
+  int a;
+  int b;
+
+  foo(void) : a(0), b(0) {}
+
+  foo(int aa, int bb) : a(aa), b(bb) {}
+
+  const foo operator+(const foo& in) const;
+
+};
+
+const foo foo::operator+(const foo& in) const {
+  foo Out;
+  Out.a = a + in.a;
+  Out.b = b + in.b;
+  return Out;
+}


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r46355 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

2008-01-25 Thread Chris Lattner
Author: lattner
Date: Fri Jan 25 11:24:52 2008
New Revision: 46355

URL: http://llvm.org/viewvc/llvm-project?rev=46355&view=rev
Log:
fix long lines.

Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=46355&r1=46354&r2=46355&view=diff

==
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Jan 25 
11:24:52 2008
@@ -57,7 +57,7 @@
   cl::desc("Pop up a window to show sched dags as they are 
processed"));
 static cl::opt
 ViewSUnitDAGs("view-sunit-dags", cl::Hidden,
-  cl::desc("Pop up a window to show SUnit dags after they are 
processed"));
+  cl::desc("Pop up a window to show SUnit dags after they are processed"));
 #else
 static const bool ViewISelDAGs = 0, ViewSchedDAGs = 0, ViewSUnitDAGs = 0;
 #endif
@@ -79,7 +79,8 @@
   RegisterPassParser >
   ISHeuristic("pre-RA-sched",
   cl::init(&createDefaultScheduler),
-  cl::desc("Instruction schedulers available (before register 
allocation):"));
+  cl::desc("Instruction schedulers available (before register"
+   " allocation):"));
 
   static RegisterScheduler
   defaultListDAGScheduler("default", "  Best scheduler for the target",


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r46349 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2008-01-25 Thread Chris Lattner

On Jan 25, 2008, at 8:37 AM, Duncan Sands wrote:

>>> PS: Does an alignment of 0 mean the ABI alignment or the preferred
>>> alignment?  I'm guessing that it means ABI for globals and
>>> preferred for allocas.
>>
>> In what context?
>
> In any context :)  Basically I'm asking what it means if you pass an
> alignment of 0 for an alloca (or a global).  For example, llvm-gcc
> uses alignment 0 for an alloca if the ABI alignment equals the gcc
> alignment.  But if the alloca gets the preferred alignment in the
> end (at codegen time) and this differs from the ABI alignment, then
> this would be wrong.

It looks like selectiondagisel is using the max(requested alignment,  
preferred alignment) for the type for allocas.  This makes sense.

-Chris
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r46350 - /llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h

2008-01-25 Thread Chris Lattner
On Jan 24, 2008, at 11:53 PM, Evan Cheng wrote:
> Ugh, really??

Yep, I didn't have time to investigate, but will try to look into it  
today.

-Chris

>
> Evan
> On Jan 24, 2008, at 11:29 PM, Chris Lattner wrote:
>
>> Author: lattner
>> Date: Fri Jan 25 01:29:34 2008
>> New Revision: 46350
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=46350&view=rev
>> Log:
>> move this field back.  Moving the field causes miscompilations (!)
>> of voronoi and others.
>>
>> Modified:
>>   llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h
>>
>> Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h?rev=46350&r1=46349&r2=46350&view=diff
>>
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> =
>> = 
>> =
>> --- llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h (original)
>> +++ llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Fri Jan 25
>> 01:29:34 2008
>> @@ -83,17 +83,17 @@
>>// Alignment - The required alignment of this stack slot.
>>unsigned Alignment;
>>
>> +// SPOffset - The offset of this object from the stack pointer
>> on entry to
>> +// the function.  This field has no meaning for a variable
>> sized element.
>> +int64_t SPOffset;
>> +
>>// isImmutable - If true, the value of the stack object is set
>> before
>>// entering the function and is not modified inside the
>> function. By
>>// default, fixed objects are immutable unless marked otherwise.
>>bool isImmutable;
>>
>> -// SPOffset - The offset of this object from the stack pointer
>> on entry to
>> -// the function.  This field has no meaning for a variable
>> sized element.
>> -int64_t SPOffset;
>> -
>>StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM = false)
>> -  : Size(Sz), Alignment(Al), isImmutable(IM), SPOffset(SP) {}
>> +  : Size(Sz), Alignment(Al), SPOffset(SP), isImmutable(IM) {}
>>  };
>>
>>  /// Objects - The list of stack objects allocated...
>>
>>
>> ___
>> llvm-commits mailing list
>> llvm-commits@cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
> ___
> llvm-commits mailing list
> llvm-commits@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r46393 - in /llvm/trunk: lib/Transforms/Utils/InlineFunction.cpp test/CFrontend/2008-01-26-ReadOnlyByVal.c

2008-01-25 Thread Duncan Sands
Author: baldrick
Date: Sat Jan 26 00:41:49 2008
New Revision: 46393

URL: http://llvm.org/viewvc/llvm-project?rev=46393&view=rev
Log:
Create an explicit copy for byval parameters even
when inlining a readonly function.

Added:
llvm/trunk/test/CFrontend/2008-01-26-ReadOnlyByVal.c
Modified:
llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp

Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=46393&r1=46392&r2=46393&view=diff

==
--- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Sat Jan 26 00:41:49 2008
@@ -240,12 +240,15 @@
  E = CalledFunc->arg_end(); I != E; ++I, ++AI, ++ArgNo) {
   Value *ActualArg = *AI;
   
-  // When byval arguments actually inlined, we need to make the copy 
implied
-  // by them explicit.  However, we don't do this if the callee is readonly
-  // or readnone, because the copy would be unneeded: the callee doesn't
-  // modify the struct.
-  if (CalledFunc->paramHasAttr(ArgNo+1, ParamAttr::ByVal) &&
-  !CalledFunc->onlyReadsMemory()) {
+  // When byval arguments are inlined, we need to make the copy implied
+  // by them explicit.  It is tempting to think that this is not needed if
+  // the callee is readonly, because the callee doesn't modify the struct.
+  // However this would be wrong: readonly means that any writes the callee
+  // performs are not visible to the caller.  But writes by the callee to
+  // an argument passed byval are by definition not visible to the caller!
+  // Since we allow this kind of readonly function, there needs to be an
+  // explicit copy in order to keep the writes invisible after inlining.
+  if (CalledFunc->paramHasAttr(ArgNo+1, ParamAttr::ByVal)) {
 const Type *AggTy = cast(I->getType())->getElementType();
 const Type *VoidPtrTy = PointerType::getUnqual(Type::Int8Ty);
 

Added: llvm/trunk/test/CFrontend/2008-01-26-ReadOnlyByVal.c
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CFrontend/2008-01-26-ReadOnlyByVal.c?rev=46393&view=auto

==
--- llvm/trunk/test/CFrontend/2008-01-26-ReadOnlyByVal.c (added)
+++ llvm/trunk/test/CFrontend/2008-01-26-ReadOnlyByVal.c Sat Jan 26 00:41:49 
2008
@@ -0,0 +1,19 @@
+// RUN: %llvmgcc %s -S -O1 -o - | llvm-as | opt -std-compile-opts | llvm-dis | 
not grep add
+
+struct S { int A; int B; int C; int D; };
+
+int f(struct S x) __attribute__ ((const));
+
+static int __attribute__ ((const)) g(struct S x) {
+   x.A = x.B;
+   return f(x);
+}
+
+int h(void) {
+   struct S x;
+   int r;
+   x.A = 0;
+   x.B = 9;
+   r = g(x);
+   return r + x.A;
+}


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r46385 - /llvm/trunk/test/CFrontend/2008-01-25-ZeroSizedAggregate.c

2008-01-25 Thread Devang Patel
Author: dpatel
Date: Fri Jan 25 19:21:48 2008
New Revision: 46385

URL: http://llvm.org/viewvc/llvm-project?rev=46385&view=rev
Log:
Add another testcase.

Modified:
llvm/trunk/test/CFrontend/2008-01-25-ZeroSizedAggregate.c

Modified: llvm/trunk/test/CFrontend/2008-01-25-ZeroSizedAggregate.c
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CFrontend/2008-01-25-ZeroSizedAggregate.c?rev=46385&r1=46384&r2=46385&view=diff

==
--- llvm/trunk/test/CFrontend/2008-01-25-ZeroSizedAggregate.c (original)
+++ llvm/trunk/test/CFrontend/2008-01-25-ZeroSizedAggregate.c Fri Jan 25 
19:21:48 2008
@@ -21,3 +21,11 @@
  } e;
 };
 struct S2525 s2525;
+
+struct {
+  signed char f;
+  char :0;
+  struct{}h;
+  char * i[5];
+} data; 
+


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r46337 - in /llvm/trunk/lib/Target/X86: X86RegisterInfo.cpp X86RegisterInfo.h X86RegisterInfo.td

2008-01-25 Thread Anton Korobeynikov
Hello, Evan

> Problem 1:
> (gdb) b main
> Line number not known for symbol "main"
> Explicitly setting a breakpoint on line 10 works.
That's strange. This definitely works for me. Could you please send me
the .bc and native gcc output with extra -dA option?

> Problem 2:
> In function f().
> (gdb) p a
> $2 = -1073743868
> (gdb) p b
> $3 = {
>x = 2,
>y = 0
> }
> 
Displaying incoming arguments is somehow broken for me too (it was so
always afair).

-- 
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r46337 - in /llvm/trunk/lib/Target/X86: X86RegisterInfo.cpp X86RegisterInfo.h X86RegisterInfo.td

2008-01-25 Thread Anton Korobeynikov
Hello, Evan

> Problem 1:
> (gdb) b main
> Line number not known for symbol "main"
> Explicitly setting a breakpoint on line 10 works.
That's strange. This definitely works for me. Could you please send me
the .bc and native gcc output with extra -dA option?

> Problem 2:
> In function f().
> (gdb) p a
> $2 = -1073743868
> (gdb) p b
> $3 = {
>x = 2,
>y = 0
> }
> 
Displaying incoming arguments is somehow broken for me too (it was so
always afair).

-- 
With best regards, Anton Korobeynikov.

Faculty of Mathematics & Mechanics, Saint Petersburg State University.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r46354 - in /llvm/trunk/lib: ExecutionEngine/JIT/JITEmitter.cpp Target/PowerPC/PPCJITInfo.cpp

2008-01-25 Thread Chris Lattner
Author: lattner
Date: Fri Jan 25 10:41:09 2008
New Revision: 46354

URL: http://llvm.org/viewvc/llvm-project?rev=46354&view=rev
Log:
JITEmitter.cpp was trying to sync the icache for function stubs, but
was actually passing a completely incorrect size to sys_icache_invalidate.
Instead of having the JITEmitter do this (which doesn't have the correct 
size), just make the target sync its own stubs.

Modified:
llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp
llvm/trunk/lib/Target/PowerPC/PPCJITInfo.cpp

Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=46354&r1=46353&r2=46354&view=diff

==
--- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Fri Jan 25 10:41:09 2008
@@ -182,10 +182,6 @@
 TheJIT->updateGlobalMapping(F, Stub);
   }
 
-  // Invalidate the icache if necessary.
-  synchronizeICache(Stub, TheJIT->getCodeEmitter()->getCurrentPCValue() -
-  (intptr_t)Stub);
-
   DOUT << "JIT: Stub emitted at [" << Stub << "] for function '"
<< F->getName() << "'\n";
 
@@ -224,10 +220,6 @@
   Stub = TheJIT->getJITInfo().emitFunctionStub(FnAddr,
*TheJIT->getCodeEmitter());
 
-  // Invalidate the icache if necessary.
-  synchronizeICache(Stub, TheJIT->getCodeEmitter()->getCurrentPCValue() -
-(intptr_t)Stub);
-
   DOUT << "JIT: Stub emitted at [" << Stub
<< "] for external function at '" << FnAddr << "'\n";
   return Stub;

Modified: llvm/trunk/lib/Target/PowerPC/PPCJITInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCJITInfo.cpp?rev=46354&r1=46353&r2=46354&view=diff

==
--- llvm/trunk/lib/Target/PowerPC/PPCJITInfo.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCJITInfo.cpp Fri Jan 25 10:41:09 2008
@@ -324,6 +324,20 @@
   return is64Bit ? PPC64CompilationCallback : PPC32CompilationCallback;
 }
 
+#if (defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)) && \
+defined(__APPLE__)
+extern "C" void sys_icache_invalidate(const void *Addr, size_t len);
+#endif
+
+/// SyncICache - On PPC, the JIT emitted code must be explicitly refetched to
+/// ensure correct execution.
+static void SyncICache(const void *Addr, size_t len) {
+#if (defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)) && \
+defined(__APPLE__)
+  sys_icache_invalidate(Addr, len);
+#endif
+}
+
 void *PPCJITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) {
   // If this is just a call to an external function, emit a branch instead of a
   // call.  The code is the same except for one bit of the last instruction.
@@ -339,10 +353,12 @@
 MCE.emitWordBE(0);
 MCE.emitWordBE(0);
 EmitBranchToAt(Addr, (intptr_t)Fn, false, is64Bit);
+SyncICache((void*)Addr, 7*4);
 return MCE.finishFunctionStub(0);
   }
 
   MCE.startFunctionStub(10*4);
+  intptr_t Addr = (intptr_t)MCE.getCurrentPCValue();
   if (is64Bit) {
 MCE.emitWordBE(0xf821ffb1); // stdu r1,-80(r1)
 MCE.emitWordBE(0x7d6802a6); // mflr r11
@@ -356,7 +372,7 @@
 MCE.emitWordBE(0x7d6802a6); // mflr r11
 MCE.emitWordBE(0x91610024); // stw r11, 36(r1)
   }
-  intptr_t Addr = (intptr_t)MCE.getCurrentPCValue();
+  intptr_t BranchAddr = (intptr_t)MCE.getCurrentPCValue();
   MCE.emitWordBE(0);
   MCE.emitWordBE(0);
   MCE.emitWordBE(0);
@@ -364,7 +380,8 @@
   MCE.emitWordBE(0);
   MCE.emitWordBE(0);
   MCE.emitWordBE(0);
-  EmitBranchToAt(Addr, (intptr_t)Fn, true, is64Bit);
+  EmitBranchToAt(BranchAddr, (intptr_t)Fn, true, is64Bit);
+  SyncICache((void*)Addr, 10*4);
   return MCE.finishFunctionStub(0);
 }
 


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r46333 - /llvm/trunk/test/CFrontend/2008-01-24-StructAlignAndBitFields.c

2008-01-25 Thread Duncan Sands
Hi Devang, this patch causes:

llvm-types.cpp: In member function ‘bool 
TypeConverter::DecodeStructFields(tree_node*, StructTypeConversionInfo&)’:
llvm-types.cpp:1777: warning: comparison between signed and unsigned integer 
expressions

Ciao,

Duncan.

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r46349 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2008-01-25 Thread Chris Lattner

On Jan 25, 2008, at 2:07 AM, Duncan Sands wrote:

> PS: Does an alignment of 0 mean the ABI alignment or the preferred
> alignment?  I'm guessing that it means ABI for globals and
> preferred for allocas.

In what context?

-Chris

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r46349 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

2008-01-25 Thread Duncan Sands
> > PS: Does an alignment of 0 mean the ABI alignment or the preferred
> > alignment?  I'm guessing that it means ABI for globals and
> > preferred for allocas.
> 
> In what context?

In any context :)  Basically I'm asking what it means if you pass an
alignment of 0 for an alloca (or a global).  For example, llvm-gcc
uses alignment 0 for an alloca if the ABI alignment equals the gcc
alignment.  But if the alloca gets the preferred alignment in the
end (at codegen time) and this differs from the ABI alignment, then
this would be wrong.

Ciao,

Duncan.
___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r46333 - /llvm/trunk/test/CFrontend/2008-01-24-StructAlignAndBitFields.c

2008-01-25 Thread Devang Patel

On Jan 25, 2008, at 6:11 AM, Duncan Sands wrote:

> Hi Devang, this patch causes:
>
> llvm-types.cpp: In member function ‘bool  
> TypeConverter::DecodeStructFields(tree_node*,  
> StructTypeConversionInfo&)’:
> llvm-types.cpp:1777: warning: comparison between signed and unsigned  
> integer expressions

I did not see this warning on darwin x86 and this line is not included  
in this patch. However, please apply t his patch if it helps you  
remove this warning.
Thanks,
-
Devang

Index: llvm-types.cpp
===
--- llvm-types.cpp  (revision 46334)
+++ llvm-types.cpp  (working copy)
@@ -1774,7 +1774,7 @@
  return false;
}
else if (TYPE_USER_ALIGN(TREE_TYPE(Field))
-   && DECL_ALIGN_UNIT(Field) != Info.getTypeAlignment(Ty)
+   && (unsigned) DECL_ALIGN_UNIT(Field) !=  
Info.getTypeAlignment(Ty)
 && !Info.isPacked()) {
  // If Field has user defined alignment and it does not match Ty  
alignment
  // then convert to a packed struct and try again.


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r46333 - /llvm/trunk/test/CFrontend/2008-01-24-StructAlignAndBitFields.c

2008-01-25 Thread Devang Patel

On Jan 25, 2008, at 12:55 AM, Duncan Sands wrote:

> Hi Devang, what is this test testing?  A compiler crash?
> It doesn't crash here without your fix.

Hmm.. did you try assertion enabled build ? What is the size and  
alignment of this struct for you without this patch ?
-
Devang
>
>
>> +// RUN: %llvmgcc %s -S -o -
>> +
>> +// This struct is not 4 byte aligned becaues bit-field
>> +// type does not influence struct alignment.
>> +struct U { char a; short b; int c:25; char d; } u;


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm-gcc-4.2] r46356 - in /llvm-gcc-4.2/trunk/gcc: llvm-convert.cpp llvm-internal.h

2008-01-25 Thread Duncan Sands
Author: baldrick
Date: Fri Jan 25 11:36:35 2008
New Revision: 46356

URL: http://llvm.org/viewvc/llvm-project?rev=46356&view=rev
Log:
Fix PR1942.  When returning an aggregate result,
create a temporary to hold the result, and copy
it out when returning.

Modified:
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
llvm-gcc-4.2/trunk/gcc/llvm-internal.h

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=46356&r1=46355&r2=46356&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Fri Jan 25 11:36:35 2008
@@ -367,6 +367,8 @@
 
   AllocaInsertionPoint = 0;
 
+  UsedSRetBuffer = false;
+
   ExceptionValue = 0;
   ExceptionSelectorValue = 0;
   FuncEHException = 0;
@@ -411,11 +413,13 @@
 LLVMBuilder Builder;
 std::vector LocStack;
 std::vector NameStack;
+bool &UsedSRetBuffer;
 FunctionPrologArgumentConversion(tree FnDecl,
  Function::arg_iterator &ai,
- const LLVMBuilder &B)
-  : FunctionDecl(FnDecl), AI(ai), Builder(B) {}
-
+ const LLVMBuilder &B,
+ bool &SRetBuffer)
+  : FunctionDecl(FnDecl), AI(ai), Builder(B), UsedSRetBuffer(SRetBuffer) {}
+
 void setName(const std::string &Name) {
   NameStack.push_back(Name);
 }
@@ -435,23 +439,29 @@
   // instead.
   assert(AI != Builder.GetInsertBlock()->getParent()->arg_end() &&
  "No explicit return value?");
+  assert(AI == Builder.GetInsertBlock()->getParent()->arg_begin() &&
+ "Struct return is not first argument!");
   AI->setName("agg.result");
-
+
   tree ResultDecl = DECL_RESULT(FunctionDecl);
   tree RetTy = TREE_TYPE(TREE_TYPE(FunctionDecl));
   if (TREE_CODE(RetTy) == TREE_CODE(TREE_TYPE(ResultDecl))) {
-SET_DECL_LLVM(ResultDecl, AI);
+// Use a buffer for the return result.  This ensures that writes to the
+// return value do not interfere with reads from parameters: the same
+// aggregate might be used for the return value and as a parameter.
+TheTreeToLLVM->EmitAutomaticVariableDecl(DECL_RESULT(FunctionDecl));
+UsedSRetBuffer = true;
 ++AI;
 return;
   }
-  
+
   // Otherwise, this must be something returned with NRVO.
   assert(TREE_CODE(TREE_TYPE(ResultDecl)) == REFERENCE_TYPE &&
  "Not type match and not passing by reference?");
   // Create an alloca for the ResultDecl.
   Value *Tmp = TheTreeToLLVM->CreateTemporary(AI->getType());
   Builder.CreateStore(AI, Tmp);
-  
+
   SET_DECL_LLVM(ResultDecl, Tmp);
   if (TheDebugInfo) {
 TheDebugInfo->EmitDeclare(ResultDecl,
@@ -656,7 +666,7 @@
   Function::arg_iterator AI = Fn->arg_begin();
 
   // Rename and alloca'ify real arguments.
-  FunctionPrologArgumentConversion Client(FnDecl, AI, Builder);
+  FunctionPrologArgumentConversion Client(FnDecl, AI, Builder, UsedSRetBuffer);
   TheLLVMABI ABIConverter(Client);
 
   // Handle the DECL_RESULT.
@@ -756,6 +766,14 @@
  PointerType::getUnqual(Fn->getReturnType()));
   RetVal = Builder.CreateLoad(RetVal, "retval");
 }
+  } else if (UsedSRetBuffer) {
+// A buffer was used for the aggregate return result.  Copy it out now.
+assert(Fn->arg_begin() != Fn->arg_end() && "No struct return value?");
+unsigned Alignment = expr_align(DECL_RESULT(FnDecl))/8;
+bool Volatile = TREE_THIS_VOLATILE(DECL_RESULT(FnDecl));
+MemRef BufLoc(DECL_LLVM(DECL_RESULT(FnDecl)), Alignment, false);
+MemRef RetLoc(Fn->arg_begin(), Alignment, Volatile);
+EmitAggregateCopy(RetLoc, BufLoc, TREE_TYPE(DECL_RESULT(FnDecl)));
   }
   if (TheDebugInfo) TheDebugInfo->EmitRegionEnd(Fn, Builder.GetInsertBlock());
   Builder.CreateRet(RetVal);
@@ -2675,20 +2693,9 @@
 // Non-bitfield aggregate value.
 MemRef NewLoc(LV.Ptr, Alignment, isVolatile);
 
-if (DestLoc) {
-  Emit(TREE_OPERAND(exp, 1), &NewLoc);
+Emit(TREE_OPERAND(exp, 1), &NewLoc);
+if (DestLoc)
   EmitAggregateCopy(*DestLoc, NewLoc, TREE_TYPE(exp));
-} else if (TREE_CODE(TREE_OPERAND(exp, 0)) != RESULT_DECL) {
-  Emit(TREE_OPERAND(exp, 1), &NewLoc);
-} else {
-  // We do this for stores into RESULT_DECL because it is possible for that
-  // memory area to overlap with the object being stored into it; see 
-  // gcc.c-torture/execute/20010124-1.c.
-
-  MemRef Tmp = CreateTempLoc(ConvertType(TREE_TYPE(TREE_OPERAND(exp,1;
-  Emit(TREE_OPERAND(exp, 1), &Tmp);
-  EmitAggregateCopy(NewLoc, Tmp, TREE_TYPE(TREE_OPERAND(exp,1)));
-}
 return 0;
   }
 

Modified: llvm-gcc-4.2/trunk/gcc/llvm-internal.h
URL: 
http://llvm.org/viewvc/llvm-projec

Re: [llvm-commits] [llvm-gcc-4.2] r46334 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

2008-01-25 Thread Devang Patel
Hi Duncan,

On Jan 25, 2008, at 1:01 AM, Duncan Sands wrote:

> Hi Devang,
>
>> Fix 2008-01-24-StructAlignAndBitFields.c test case.
>> Bit-field type does not influence struct alignment.
>
> I don't see the point of trying to get the LLVM type to have the same
> alignment as the gcc type.

This patch does not update llvm-gcc to generate LLVM type that matches  
GCC type. GCC type alignment is 2 byte here. Before this patch LLVM  
type alignment was 4 byte and now after this patch struct alignment is  
1 byte.

>  I think all the code that tries to obtain
> equal alignment should just be dropped.  Who cares if the LLVM type  
> has
> a different alignment to the gcc type?  Surely all that matters is  
> that
> when we allocate a variable (alloca or global), if the gcc declaration
> is more aligned than the LLVM type, then we should force the alloca/ 
> global
> to have the gcc alignment.

So idea is for llvm value you "fix" aligment, which can happen N  
number of times for each type instead of fixing type once. However, if  
you can simplify code then that is a good idea. Go for it.

-
Devang


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r46360 - /llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h

2008-01-25 Thread Dale Johannesen

On Jan 25, 2008, at 9:49 AM, Chris Lattner wrote:

> Author: lattner
> Date: Fri Jan 25 11:49:41 2008
> New Revision: 46360
>
> URL: http://llvm.org/viewvc/llvm-project?rev=46360&view=rev
> Log:
> Reorder a field to reduce the size of StackObject.  Note that this
> may require a clean rebuild on leopard. :(

Does this indicate a bug in the header dependency machinery?

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm] r46372 - /llvm/trunk/test/CFrontend/2008-01-25-ByValReadNone.c

2008-01-25 Thread Chris Lattner
Author: lattner
Date: Fri Jan 25 16:36:24 2008
New Revision: 46372

URL: http://llvm.org/viewvc/llvm-project?rev=46372&view=rev
Log:
add a testcase for a bug Duncan pointed out.

Added:
llvm/trunk/test/CFrontend/2008-01-25-ByValReadNone.c

Added: llvm/trunk/test/CFrontend/2008-01-25-ByValReadNone.c
URL: 
http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CFrontend/2008-01-25-ByValReadNone.c?rev=46372&view=auto

==
--- llvm/trunk/test/CFrontend/2008-01-25-ByValReadNone.c (added)
+++ llvm/trunk/test/CFrontend/2008-01-25-ByValReadNone.c Fri Jan 25 16:36:24 
2008
@@ -0,0 +1,10 @@
+// RUN: %llvmgcc -O3 -S -o - -emit-llvm %s | grep readonly
+// RUN: %llvmgcc -O3 -S -o - -emit-llvm %s | not grep readnone
+
+
+// The struct being passed byval means that we need to mark the 
+// function readonly instead of readnone.  Readnone would allow
+// stores to the arg to be deleted in the caller.
+struct S { int A[1000]; };
+int __attribute__ ((const)) f(struct S x) { return x.A[0]; }
+


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm-gcc-4.2] r46375 - /llvm-gcc-4.2/trunk/gcc/llvm-abi.h

2008-01-25 Thread Evan Cheng
Author: evancheng
Date: Fri Jan 25 17:02:28 2008
New Revision: 46375

URL: http://llvm.org/viewvc/llvm-project?rev=46375&view=rev
Log:
Drop zero-sized aggregate arguments.

Modified:
llvm-gcc-4.2/trunk/gcc/llvm-abi.h

Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=46375&r1=46374&r2=46375&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Fri Jan 25 17:02:28 2008
@@ -120,6 +120,13 @@
   }
 }
 
+/// isAggregareOfSizeZero - Returns true if this is an aggregate with size 
zero.
+///
+static bool isAggregareOfSizeZero(tree type) {
+  if (!isAggregateTreeType(type)) return false;
+  return int_size_in_bytes(type) == 0;
+}
+
 // LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR - Return true if this aggregate
 // value should be passed by value, i.e. passing its address with the byval
 // attribute bit set. The default is false.
@@ -227,6 +234,9 @@
 PassInMixedRegisters(type, Ty, Elts);
   } else if (LLVM_SHOULD_PASS_AGGREGATE_IN_INTEGER_REGS(type)) {
 PassInIntegerRegisters(type, Ty);
+  } else if (isAggregareOfSizeZero(type)) {
+// Zero sized aggregare, just drop it!
+;
   } else if (TREE_CODE(type) == RECORD_TYPE) {
 for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field))
   if (TREE_CODE(Field) == FIELD_DECL) {


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


Re: [llvm-commits] [llvm] r46387 - in /llvm/trunk: lib/Transforms/Scalar/SimplifyCFG.cpp test/CFrontend/2008-01-25-EmptyFunction.c

2008-01-25 Thread Bill Wendling
Okay.

On Jan 25, 2008, at 7:26 PM, Chris Lattner wrote:

> On Jan 25, 2008, at 5:43 PM, Bill Wendling wrote:
>> URL: http://llvm.org/viewvc/llvm-project?rev=46387&view=rev
>> Log:
>> If we have a function like this:
>>
>> This is bad on some platforms (like PPC) because it will generate
>> the label for
>> the function but no body. The label could end up being associated
>> with some
>> non-code related stuff, like a section. This places a "trap"
>> instruction if the
>> SimplifyCFG pass removed all code from the function leaving only one
>> "unreachable" instruction.
>
> This is a darwin-specific hack, so it needs to be conditionalized on
> the target.  Second, this should only be done if there are zero
> machineinstrs, not zero llvm instrs.
>
>>   // If there are unreachable blocks in the CFG...
>> -  if (Reachable.size() == F.size())
>> +  if (Reachable.size() == F.size()) {
>> +if (F.size() == 1) {
>
> F.size() is linear time, so you shouldn't call it here if you don't
> need it.  Why are you doing this in the Reachable.size() == F.size()
> case?
>
>> +  // If the function has only one block with an "unreachable"
>> instruction,
>> +  // then we should create *some* code for it. Issue a "trap"
>> instead.
>> +  BasicBlock &BB = F.front();
>> +
>> +  if (BB.size() == 1 && dyn_cast(&BB.front()))
>
> Only use dyn_cast if you want the result: use isa in this case.
> BB.size() is also linear time.
>
> Finally, the testcase you added was for llvm-gcc, this is a codegen
> thing so it should be in test/CodeGen/* and should only run llc.
>
> -Chris
>
> ___
> llvm-commits mailing list
> llvm-commits@cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


[llvm-commits] [llvm-gcc-4.2] r46390 - /llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

2008-01-25 Thread Duncan Sands
Author: baldrick
Date: Fri Jan 25 23:27:18 2008
New Revision: 46390

URL: http://llvm.org/viewvc/llvm-project?rev=46390&view=rev
Log:
Correct comment.

Modified:
llvm-gcc-4.2/trunk/gcc/llvm-types.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp
URL: 
http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=46390&r1=46389&r2=46390&view=diff

==
--- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Fri Jan 25 23:27:18 2008
@@ -1219,7 +1219,7 @@
   DeclArgs = TREE_CHAIN(DeclArgs);
   }
   
-  // If we see a byval argument and if the function is 'readonly' we have to
+  // If we see a byval argument and if the function is 'readnone' we have to
   // demote the function to being 'readonly' instead.  Not doing so would allow
   // optimizers to delete stores into the argument that is passed into the
   // function.
@@ -1228,7 +1228,7 @@
 Attrs[0].attrs &= ~ParamAttr::ReadNone;
 Attrs[0].attrs |= ParamAttr::ReadOnly;
   }
-  
+
   // If the argument list ends with a void type node, it isn't vararg.
   isVarArg = (Args == 0);
   assert(RetTy && "Return type not specified!");


___
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits