From lattner at cs.uiuc.edu Mon Oct 24 00:03:57 2005
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon, 24 Oct 2005 00:03:57 -0500
Subject: [llvm-commits] CVS: llvm/include/llvm/Support/CommandLine.h
Message-ID: <200510240503.AAA29475@zion.cs.uiuc.edu>
Changes in directory llvm/include/llvm/Support:
CommandLine.h updated: 1.51 -> 1.52
---
Log message:
Move the END_WITH_NULL marker. Vladimir suggests that this works better with
GCC 4.1. I tried it with 4.0 and 3.3 and it seems fine.
---
Diffs of the changes: (+2 -7)
CommandLine.h | 9 ++-------
1 files changed, 2 insertions(+), 7 deletions(-)
Index: llvm/include/llvm/Support/CommandLine.h
diff -u llvm/include/llvm/Support/CommandLine.h:1.51 llvm/include/llvm/Support/CommandLine.h:1.52
--- llvm/include/llvm/Support/CommandLine.h:1.51 Sun Oct 23 10:22:50 2005
+++ llvm/include/llvm/Support/CommandLine.h Mon Oct 24 00:03:46 2005
@@ -334,14 +334,9 @@
}
};
-// Silly GCC doesn't allow attributes on a function definition.
template
-ValuesClass values(const char *Arg, DataType Val, const char *Desc,
- ...) END_WITH_NULL;
-
-template
-ValuesClass values(const char *Arg, DataType Val, const char *Desc,
- ...) {
+ValuesClass END_WITH_NULL values(const char *Arg, DataType Val,
+ const char *Desc, ...) {
va_list ValueArgs;
va_start(ValueArgs, Desc);
ValuesClass Vals(Arg, Val, Desc, ValueArgs);
From wanderer at rsu.ru Mon Oct 24 00:10:00 2005
From: wanderer at rsu.ru (Vladimir A. Merzliakov)
Date: Mon, 24 Oct 2005 09:10:00 +0400
Subject: [llvm-commits] CVS: llvm/include/llvm/Support/CommandLine.h
References: <200510240503.AAA29475@zion.cs.uiuc.edu>
Message-ID: <021601c5d859$2f51dbf0$10fcd0c3@cc.rsu.ru>
> Move the END_WITH_NULL marker. Vladimir suggests that this works better
> with
> GCC 4.1. I tried it with 4.0 and 3.3 and it seems fine.
Just for note: this suggested by Jeff Cohen in
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20051017/028884.html
I only check for 4.1.0 and post patch :)
Vladimir
From lattner at cs.uiuc.edu Mon Oct 24 01:04:09 2005
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon, 24 Oct 2005 01:04:09 -0500
Subject: [llvm-commits]
CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Message-ID: <200510240604.BAA29720@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.388 -> 1.389
---
Log message:
Pull some code out into a function, no functionality change
---
Diffs of the changes: (+36 -25)
InstructionCombining.cpp | 61 +++++++++++++++++++++++++++--------------------
1 files changed, 36 insertions(+), 25 deletions(-)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.388 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.389
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.388 Mon Oct 17 15:18:38 2005
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Mon Oct 24 01:03:58 2005
@@ -227,6 +227,7 @@
bool isSub, Instruction &I);
Instruction *InsertRangeTest(Value *V, Constant *Lo, Constant *Hi,
bool Inside, Instruction &IB);
+ Instruction *PromoteCastOfAllocation(CastInst &CI, AllocationInst &AI);
};
RegisterOpt X("instcombine", "Combine redundant instructions");
@@ -3761,6 +3762,39 @@
return CI;
}
+/// PromoteCastOfAllocation - If we find a cast of an allocation instruction,
+/// try to eliminate the cast by moving the type information into the alloc.
+Instruction *InstCombiner::PromoteCastOfAllocation(CastInst &CI,
+ AllocationInst &AI) {
+ const PointerType *PTy = dyn_cast(CI.getType());
+ if (AI.isArrayAllocation() || !PTy) return 0;
+
+ if (!AI.hasOneUse()) return 0;
+
+ // Get the type really allocated and the type casted to.
+ const Type *AllocElTy = AI.getAllocatedType();
+ const Type *CastElTy = PTy->getElementType();
+ if (!AllocElTy->isSized() || !CastElTy->isSized()) return 0;
+
+ uint64_t AllocElTySize = TD->getTypeSize(AllocElTy);
+ uint64_t CastElTySize = TD->getTypeSize(CastElTy);
+
+ // If the allocation is for an even multiple of the cast type size
+ if (CastElTySize == 0 || AllocElTySize % CastElTySize != 0)
+ return 0;
+ Value *Amt = ConstantUInt::get(Type::UIntTy,
+ AllocElTySize/CastElTySize);
+ std::string Name = AI.getName(); AI.setName("");
+ AllocationInst *New;
+ if (isa(AI))
+ New = new MallocInst(CastElTy, Amt, Name);
+ else
+ New = new AllocaInst(CastElTy, Amt, Name);
+ InsertNewInstBefore(New, AI);
+ return ReplaceInstUsesWith(CI, New);
+}
+
+
// CastInst simplification
//
Instruction *InstCombiner::visitCastInst(CastInst &CI) {
@@ -3839,30 +3873,8 @@
// size, rewrite the allocation instruction to allocate the "right" type.
//
if (AllocationInst *AI = dyn_cast(Src))
- if (AI->hasOneUse() && !AI->isArrayAllocation())
- if (const PointerType *PTy = dyn_cast(CI.getType())) {
- // Get the type really allocated and the type casted to...
- const Type *AllocElTy = AI->getAllocatedType();
- const Type *CastElTy = PTy->getElementType();
- if (AllocElTy->isSized() && CastElTy->isSized()) {
- uint64_t AllocElTySize = TD->getTypeSize(AllocElTy);
- uint64_t CastElTySize = TD->getTypeSize(CastElTy);
-
- // If the allocation is for an even multiple of the cast type size
- if (CastElTySize && (AllocElTySize % CastElTySize == 0)) {
- Value *Amt = ConstantUInt::get(Type::UIntTy,
- AllocElTySize/CastElTySize);
- std::string Name = AI->getName(); AI->setName("");
- AllocationInst *New;
- if (isa(AI))
- New = new MallocInst(CastElTy, Amt, Name);
- else
- New = new AllocaInst(CastElTy, Amt, Name);
- InsertNewInstBefore(New, *AI);
- return ReplaceInstUsesWith(CI, New);
- }
- }
- }
+ if (Instruction *V = PromoteCastOfAllocation(CI, *AI))
+ return V;
if (SelectInst *SI = dyn_cast(Src))
if (Instruction *NV = FoldOpIntoSelect(CI, SI, this))
@@ -5596,7 +5608,6 @@
return 0;
}
-
void InstCombiner::removeFromWorkList(Instruction *I) {
WorkList.erase(std::remove(WorkList.begin(), WorkList.end(), I),
WorkList.end());
From lattner at cs.uiuc.edu Mon Oct 24 01:22:24 2005
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon, 24 Oct 2005 01:22:24 -0500
Subject: [llvm-commits]
CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Message-ID: <200510240622.BAA29810@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.389 -> 1.390
---
Log message:
Before promoting a malloc type, remove dead uses. This makes instcombine
more effective at promoting these allocations, catching them earlier in the
compile process.
---
Diffs of the changes: (+20 -0)
InstructionCombining.cpp | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.389 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.390
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.389 Mon Oct 24 01:03:58 2005
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Mon Oct 24 01:22:12 2005
@@ -3769,6 +3769,26 @@
const PointerType *PTy = dyn_cast(CI.getType());
if (AI.isArrayAllocation() || !PTy) return 0;
+ // Remove any uses of AI that are dead.
+ assert(!CI.use_empty() && "Dead instructions should be removed earlier!");
+ std::vector DeadUsers;
+ for (Value::use_iterator UI = AI.use_begin(), E = AI.use_end(); UI != E; ) {
+ Instruction *User = cast(*UI++);
+ if (isInstructionTriviallyDead(User)) {
+ while (UI != E && *UI == User)
+ ++UI; // If this instruction uses AI more than once, don't break UI.
+
+ // Add operands to the worklist.
+ AddUsesToWorkList(*User);
+ ++NumDeadInst;
+ DEBUG(std::cerr << "IC: DCE: " << *User);
+
+ User->eraseFromParent();
+ removeFromWorkList(User);
+ }
+ }
+
+ // Finally, if the instruction now has one use, delete it.
if (!AI.hasOneUse()) return 0;
// Get the type really allocated and the type casted to.
From lattner at cs.uiuc.edu Mon Oct 24 01:26:29 2005
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon, 24 Oct 2005 01:26:29 -0500
Subject: [llvm-commits]
CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Message-ID: <200510240626.BAA29878@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.390 -> 1.391
---
Log message:
Fix a bug where we would 'promote' an allocation from one type to another
where the second has less alignment required. If we had explicit alignment
support in the IR, we could handle this case, but we can't until we do.
---
Diffs of the changes: (+6 -2)
InstructionCombining.cpp | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.390 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.391
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.390 Mon Oct 24 01:22:12 2005
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Mon Oct 24 01:26:18 2005
@@ -3795,10 +3795,14 @@
const Type *AllocElTy = AI.getAllocatedType();
const Type *CastElTy = PTy->getElementType();
if (!AllocElTy->isSized() || !CastElTy->isSized()) return 0;
-
+
+ unsigned AllocElTyAlign = TD->getTypeSize(AllocElTy);
+ unsigned CastElTyAlign = TD->getTypeSize(CastElTy);
+ if (CastElTyAlign < AllocElTyAlign) return 0;
+
uint64_t AllocElTySize = TD->getTypeSize(AllocElTy);
uint64_t CastElTySize = TD->getTypeSize(CastElTy);
-
+
// If the allocation is for an even multiple of the cast type size
if (CastElTySize == 0 || AllocElTySize % CastElTySize != 0)
return 0;
From lattner at cs.uiuc.edu Mon Oct 24 01:35:30 2005
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon, 24 Oct 2005 01:35:30 -0500
Subject: [llvm-commits]
CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Message-ID: <200510240635.BAA29953@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Transforms/Scalar:
InstructionCombining.cpp updated: 1.391 -> 1.392
---
Log message:
Handle allocations that, even after removing dead uses, still have more than
one use (but one is a cast). This handles the very common case of:
X = alloc [n x byte]
Y = cast X to somethingbetter
seteq X, null
In order to avoid infinite looping when there are multiple casts, we only
allow this if the xform is strictly increasing the alignment of the
allocation.
---
Diffs of the changes: (+15 -3)
InstructionCombining.cpp | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.391 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.392
--- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.391 Mon Oct 24 01:26:18 2005
+++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Mon Oct 24 01:35:18 2005
@@ -3788,9 +3788,6 @@
}
}
- // Finally, if the instruction now has one use, delete it.
- if (!AI.hasOneUse()) return 0;
-
// Get the type really allocated and the type casted to.
const Type *AllocElTy = AI.getAllocatedType();
const Type *CastElTy = PTy->getElementType();
@@ -3800,6 +3797,11 @@
unsigned CastElTyAlign = TD->getTypeSize(CastElTy);
if (CastElTyAlign < AllocElTyAlign) return 0;
+ // If the allocation has multiple uses, only promote it if we are strictly
+ // increasing the alignment of the resultant allocation. If we keep it the
+ // same, we open the door to infinite loops of various kinds.
+ if (!AI.hasOneUse() && CastElTyAlign == AllocElTyAlign) return 0;
+
uint64_t AllocElTySize = TD->getTypeSize(AllocElTy);
uint64_t CastElTySize = TD->getTypeSize(CastElTy);
@@ -3815,6 +3817,16 @@
else
New = new AllocaInst(CastElTy, Amt, Name);
InsertNewInstBefore(New, AI);
+
+ // If the allocation has multiple uses, insert a cast and change all things
+ // that used it to use the new cast. This will also hack on CI, but it will
+ // die soon.
+ if (!AI.hasOneUse()) {
+ AddUsesToWorkList(AI);
+ CastInst *NewCast = new CastInst(New, AI.getType(), "tmpcast");
+ InsertNewInstBefore(NewCast, AI);
+ AI.replaceAllUsesWith(NewCast);
+ }
return ReplaceInstUsesWith(CI, New);
}
From lattner at cs.uiuc.edu Mon Oct 24 01:38:46 2005
From: lattner at cs.uiuc.edu (Chris Lattner)
Date: Mon, 24 Oct 2005 01:38:46 -0500
Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV8/SparcV8CodeEmitter.cpp
Message-ID: <200510240638.BAA29987@zion.cs.uiuc.edu>
Changes in directory llvm/lib/Target/SparcV8:
SparcV8CodeEmitter.cpp updated: 1.5 -> 1.6
---
Log message:
do not wrap this whole file in namespace llvm
---
Diffs of the changes: (+1 -4)
SparcV8CodeEmitter.cpp | 5 +----
1 files changed, 1 insertion(+), 4 deletions(-)
Index: llvm/lib/Target/SparcV8/SparcV8CodeEmitter.cpp
diff -u llvm/lib/Target/SparcV8/SparcV8CodeEmitter.cpp:1.5 llvm/lib/Target/SparcV8/SparcV8CodeEmitter.cpp:1.6
--- llvm/lib/Target/SparcV8/SparcV8CodeEmitter.cpp:1.5 Sun Oct 23 23:51:35 2005
+++ llvm/lib/Target/SparcV8/SparcV8CodeEmitter.cpp Mon Oct 24 01:38:35 2005
@@ -20,8 +20,7 @@
#include
#include
LLVM explicitly allows declarations of global variables to be marked
@@ -720,8 +720,8 @@
-
Note that 'variable sized arrays' can be implemented in LLVM With a zero
-length array. Normally accesses past the end of an array are undefined in
+
Note that 'variable sized arrays' can be implemented in LLVM with a zero
+length array. Normally, accesses past the end of an array are undefined in
LLVM (e.g. it is illegal to access the 5th element of a 3 element array).
As a special case, however, zero length arrays are recognized to be variable
length. This allows implementation of 'pascal style arrays' with the LLVM
@@ -743,7 +743,7 @@
Syntax:
<returntype> (<parameter list>)
-
Where '<parameter list>' is a comma-separated list of type
+
The 'load' instruction is used to read from memory.
Arguments:
The argument to the 'load' instruction specifies the memory
-address to load from. The pointer must point to a first class type. If the load is
-marked as volatile then the optimizer is not allowed to modify
+marked as volatile, then the optimizer is not allowed to modify
the number or order of execution of this load with other
volatile load and store
instructions.
@@ -1889,7 +1889,7 @@
The 'store' instruction is used to write to memory.
Arguments:
There are two arguments to the 'store' instruction: a value
-to store and an address to store it into. The type of the '<pointer>'
+to store and an address in which to store it. The type of the '<pointer>'
operand must be a pointer to the type of the '<value>'
operand. If the store is marked as volatile, then the
optimizer is not allowed to modify the number or order of execution of
@@ -3314,7 +3314,7 @@
Chris Lattner The LLVM Compiler Infrastructure
- Last modified: $Date: 2005/07/21 01:29:16 $
+ Last modified: $Date: 2005/10/24 16:17:18 $