[llvm-commits] [parallel] CVS: llvm/lib/VMCore/AsmWriter.cpp ConstantFolding.cpp Constants.cpp IntrinsicLowering.cpp Module.cpp Pass.cpp Verifier.cpp
Misha Brukman
brukman at cs.uiuc.edu
Wed Mar 10 19:37:01 PST 2004
Changes in directory llvm/lib/VMCore:
AsmWriter.cpp updated: 1.116.2.1 -> 1.116.2.2
ConstantFolding.cpp updated: 1.50.2.1 -> 1.50.2.2
Constants.cpp updated: 1.71.2.1 -> 1.71.2.2
IntrinsicLowering.cpp updated: 1.5.2.2 -> 1.5.2.3
Module.cpp updated: 1.47 -> 1.47.2.1
Pass.cpp updated: 1.54.4.1 -> 1.54.4.2
Verifier.cpp updated: 1.78.2.3 -> 1.78.2.4
---
Log message:
Merge from trunk.
---
Diffs of the changes: (+70 -105)
Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.116.2.1 llvm/lib/VMCore/AsmWriter.cpp:1.116.2.2
--- llvm/lib/VMCore/AsmWriter.cpp:1.116.2.1 Mon Mar 1 17:58:16 2004
+++ llvm/lib/VMCore/AsmWriter.cpp Wed Mar 10 19:36:09 2004
@@ -97,9 +97,9 @@
}
-// If the module has a symbol table, take all global types and stuff their
-// names into the TypeNames map.
-//
+/// fillTypeNameTable - If the module has a symbol table, take all global types
+/// and stuff their names into the TypeNames map.
+///
static void fillTypeNameTable(const Module *M,
std::map<const Type *, std::string> &TypeNames) {
if (!M) return;
@@ -381,10 +381,10 @@
}
-// WriteAsOperand - Write the name of the specified value out to the specified
-// ostream. This can be useful when you just want to print int %reg126, not the
-// whole instruction that generated it.
-//
+/// WriteAsOperand - Write the name of the specified value out to the specified
+/// ostream. This can be useful when you just want to print int %reg126, not
+/// the whole instruction that generated it.
+///
static void WriteAsOperandInternal(std::ostream &Out, const Value *V,
bool PrintName,
std::map<const Type*, std::string> &TypeTable,
@@ -422,7 +422,6 @@
}
-
/// WriteAsOperand - Write the name of the specified value out to the specified
/// ostream. This can be useful when you just want to print int %reg126, not
/// the whole instruction that generated it.
@@ -503,9 +502,9 @@
};
} // end of anonymous namespace
-// printTypeAtLeastOneLevel - Print out one level of the possibly complex type
-// without considering any symbolic types that we may have equal to it.
-//
+/// printTypeAtLeastOneLevel - Print out one level of the possibly complex type
+/// without considering any symbolic types that we may have equal to it.
+///
std::ostream &AssemblyWriter::printTypeAtLeastOneLevel(const Type *Ty) {
if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
printType(FTy->getReturnType()) << " (";
@@ -602,9 +601,9 @@
}
-// printSymbolTable - Run through symbol table looking for named constants
-// if a named constant is found, emit it's declaration...
-//
+/// printSymbolTable - Run through symbol table looking for named constants
+/// if a named constant is found, emit it's declaration...
+///
void AssemblyWriter::printSymbolTable(const SymbolTable &ST) {
for (SymbolTable::const_iterator TI = ST.begin(); TI != ST.end(); ++TI) {
SymbolTable::type_const_iterator I = ST.type_begin(TI->first);
@@ -628,8 +627,8 @@
}
-// printConstant - Print out a constant pool entry...
-//
+/// printConstant - Print out a constant pool entry...
+///
void AssemblyWriter::printConstant(const Constant *CPV) {
// Don't print out unnamed constants, they will be inlined
if (!CPV->hasName()) return;
@@ -644,8 +643,8 @@
Out << "\n";
}
-// printFunction - Print all aspects of a function.
-//
+/// printFunction - Print all aspects of a function.
+///
void AssemblyWriter::printFunction(const Function *F) {
// Print out the return type and name...
Out << "\n";
@@ -699,9 +698,9 @@
Table.purgeFunction();
}
-// printArgument - This member is called for every argument that
-// is passed into the function. Simply print it out
-//
+/// printArgument - This member is called for every argument that is passed into
+/// the function. Simply print it out
+///
void AssemblyWriter::printArgument(const Argument *Arg) {
// Insert commas as we go... the first arg doesn't get a comma
if (Arg != &Arg->getParent()->afront()) Out << ", ";
@@ -716,8 +715,8 @@
Out << "<badref>";
}
-// printBasicBlock - This member is called for each basic block in a method.
-//
+/// printBasicBlock - This member is called for each basic block in a method.
+///
void AssemblyWriter::printBasicBlock(const BasicBlock *BB) {
if (BB->hasName()) { // Print out the label if it exists...
Out << "\n" << BB->getName() << ":";
@@ -753,17 +752,19 @@
Out << "\n";
- if (AnnotationWriter) AnnotationWriter->emitBasicBlockAnnot(BB, Out);
+ if (AnnotationWriter) AnnotationWriter->emitBasicBlockStartAnnot(BB, Out);
// Output all of the instructions in the basic block...
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I)
printInstruction(*I);
+
+ if (AnnotationWriter) AnnotationWriter->emitBasicBlockEndAnnot(BB, Out);
}
-// printInfoComment - Print a little comment after the instruction indicating
-// which slot it occupies.
-//
+/// printInfoComment - Print a little comment after the instruction indicating
+/// which slot it occupies.
+///
void AssemblyWriter::printInfoComment(const Value &V) {
if (V.getType() != Type::VoidTy) {
Out << "\t\t; <";
@@ -778,8 +779,8 @@
}
}
-// printInstruction - This member is called for each Instruction in a method.
-//
+/// printInstruction - This member is called for each Instruction in a method.
+///
void AssemblyWriter::printInstruction(const Instruction &I) {
if (AnnotationWriter) AnnotationWriter->emitInstructionAnnot(&I, Out);
Index: llvm/lib/VMCore/ConstantFolding.cpp
diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.50.2.1 llvm/lib/VMCore/ConstantFolding.cpp:1.50.2.2
--- llvm/lib/VMCore/ConstantFolding.cpp:1.50.2.1 Mon Mar 1 17:58:16 2004
+++ llvm/lib/VMCore/ConstantFolding.cpp Wed Mar 10 19:36:09 2004
@@ -22,6 +22,7 @@
#include "llvm/Constants.h"
#include "llvm/Instructions.h"
#include "llvm/DerivedTypes.h"
+#include "llvm/Function.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include <cmath>
using namespace llvm;
@@ -523,6 +524,15 @@
const Type *DestTy) {
if (V->getType() == DestTy) return (Constant*)V;
+ // Cast of a global address to boolean is always true.
+ if (const ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(V))
+ if (DestTy == Type::BoolTy)
+ // FIXME: When we support 'external weak' references, we have to prevent
+ // this transformation from happening. In the meantime we avoid folding
+ // any cast of an external symbol.
+ if (!CPR->getValue()->isExternal())
+ return ConstantBool::True;
+
if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(V))
if (CE->getOpcode() == Instruction::Cast) {
Constant *Op = const_cast<Constant*>(CE->getOperand(0));
@@ -873,6 +883,16 @@
if (cast<ConstantIntegral>(V2)->isAllOnesValue())
return const_cast<Constant*>(V1); // X & -1 == X
if (V2->isNullValue()) return const_cast<Constant*>(V2); // X & 0 == 0
+ if (CE1->getOpcode() == Instruction::Cast &&
+ isa<ConstantPointerRef>(CE1->getOperand(0))) {
+ ConstantPointerRef *CPR =cast<ConstantPointerRef>(CE1->getOperand(0));
+
+ // Functions are at least 4-byte aligned. If and'ing the address of a
+ // function with a constant < 4, fold it to zero.
+ if (const ConstantInt *CI = dyn_cast<ConstantInt>(V2))
+ if (CI->getRawValue() < 4 && isa<Function>(CPR->getValue()))
+ return Constant::getNullValue(CI->getType());
+ }
break;
case Instruction::Or:
if (V2->isNullValue()) return const_cast<Constant*>(V1); // X | 0 == X
Index: llvm/lib/VMCore/Constants.cpp
diff -u llvm/lib/VMCore/Constants.cpp:1.71.2.1 llvm/lib/VMCore/Constants.cpp:1.71.2.2
--- llvm/lib/VMCore/Constants.cpp:1.71.2.1 Mon Mar 1 17:58:16 2004
+++ llvm/lib/VMCore/Constants.cpp Wed Mar 10 19:36:09 2004
@@ -1119,26 +1119,3 @@
const char *ConstantExpr::getOpcodeName() const {
return Instruction::getOpcodeName(getOpcode());
}
-
-unsigned Constant::mutateReferences(Value *OldV, Value *NewV) {
- // Uses of constant pointer refs are global values, not constants!
- if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(this)) {
- GlobalValue *NewGV = cast<GlobalValue>(NewV);
- GlobalValue *OldGV = CPR->getValue();
-
- assert(OldGV == OldV && "Cannot mutate old value if I'm not using it!");
- Operands[0] = NewGV;
- OldGV->getParent()->mutateConstantPointerRef(OldGV, NewGV);
- return 1;
- } else {
- Constant *NewC = cast<Constant>(NewV);
- unsigned NumReplaced = 0;
- for (unsigned i = 0, N = getNumOperands(); i != N; ++i)
- if (Operands[i] == OldV) {
- ++NumReplaced;
- Operands[i] = NewC;
- }
- return NumReplaced;
- }
-}
-
Index: llvm/lib/VMCore/IntrinsicLowering.cpp
diff -u llvm/lib/VMCore/IntrinsicLowering.cpp:1.5.2.2 llvm/lib/VMCore/IntrinsicLowering.cpp:1.5.2.3
--- llvm/lib/VMCore/IntrinsicLowering.cpp:1.5.2.2 Mon Mar 1 17:58:16 2004
+++ llvm/lib/VMCore/IntrinsicLowering.cpp Wed Mar 10 19:36:09 2004
@@ -125,11 +125,6 @@
CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
break; // Simply strip out debugging intrinsics
- case Intrinsic::join:
- // Insert the call to abort
- new CallInst(M->getOrInsertFunction("abort", Type::VoidTy, 0), "", CI);
- break;
-
case Intrinsic::memcpy:
// The memcpy intrinsic take an extra alignment argument that the memcpy
// libc function does not.
Index: llvm/lib/VMCore/Module.cpp
diff -u llvm/lib/VMCore/Module.cpp:1.47 llvm/lib/VMCore/Module.cpp:1.47.2.1
--- llvm/lib/VMCore/Module.cpp:1.47 Wed Dec 31 02:43:01 2003
+++ llvm/lib/VMCore/Module.cpp Wed Mar 10 19:36:09 2004
@@ -335,28 +335,3 @@
GVRefMap = 0;
}
}
-
-void Module::mutateConstantPointerRef(GlobalValue *OldGV, GlobalValue *NewGV) {
- assert(OldGV != NewGV && "Cannot mutate to the same global!");
- GlobalValueRefMap::iterator I = GVRefMap->Map.find(OldGV);
- assert(I != GVRefMap->Map.end() &&
- "mutateConstantPointerRef; OldGV not in table!");
- ConstantPointerRef *Ref = I->second;
-
- // Remove the old entry...
- GVRefMap->Map.erase(I);
-
- // Check to see if a CPR already exists for NewGV
- I = GVRefMap->Map.lower_bound(NewGV);
-
- if (I == GVRefMap->Map.end() || I->first != NewGV) {
- // Insert the new entry...
- GVRefMap->Map.insert(I, std::make_pair(NewGV, Ref));
- } else {
- // Otherwise, an entry already exists for the current global value.
- // Completely replace the old CPR with the existing one...
- Ref->replaceAllUsesWith(I->second);
- delete Ref;
- }
-}
-
Index: llvm/lib/VMCore/Pass.cpp
diff -u llvm/lib/VMCore/Pass.cpp:1.54.4.1 llvm/lib/VMCore/Pass.cpp:1.54.4.2
--- llvm/lib/VMCore/Pass.cpp:1.54.4.1 Mon Mar 1 17:58:16 2004
+++ llvm/lib/VMCore/Pass.cpp Wed Mar 10 19:36:09 2004
@@ -13,8 +13,8 @@
//
//===----------------------------------------------------------------------===//
-#include "llvm/PassManager.h"
#include "PassManagerT.h" // PassManagerT implementation
+#include "llvm/PassManager.h"
#include "llvm/Module.h"
#include "llvm/ModuleProvider.h"
#include "Support/STLExtras.h"
Index: llvm/lib/VMCore/Verifier.cpp
diff -u llvm/lib/VMCore/Verifier.cpp:1.78.2.3 llvm/lib/VMCore/Verifier.cpp:1.78.2.4
--- llvm/lib/VMCore/Verifier.cpp:1.78.2.3 Mon Mar 1 17:58:16 2004
+++ llvm/lib/VMCore/Verifier.cpp Wed Mar 10 19:36:09 2004
@@ -62,8 +62,8 @@
bool Broken; // Is this module found to be broken?
bool RealPass; // Are we not being run by a PassManager?
bool AbortBroken; // If broken, should it or should it not abort?
- Module *Mod; // Module we are verifying right now
- DominatorSet *DS; // Dominator set, caution can be null!
+ Module *Mod; // Module we are verifying right now
+ DominatorSet *DS; // Dominator set, caution can be null!
Verifier() : Broken(false), RealPass(true), AbortBroken(true), DS(0) {}
Verifier(bool AB) : Broken(false), RealPass(true), AbortBroken(AB), DS(0) {}
@@ -78,7 +78,6 @@
// If this is a real pass, in a pass manager, we must abort before
// returning back to the pass manager, or else the pass manager may try to
// run other passes on the broken module.
- //
if (RealPass)
abortIfBroken();
return false;
@@ -92,7 +91,6 @@
// If this is a real pass, in a pass manager, we must abort before
// returning back to the pass manager, or else the pass manager may try to
// run other passes on the broken module.
- //
if (RealPass)
abortIfBroken();
@@ -118,9 +116,9 @@
AU.addRequired<DominatorSet>();
}
- // abortIfBroken - If the module is broken and we are supposed to abort on
- // this condition, do so.
- //
+ /// abortIfBroken - If the module is broken and we are supposed to abort on
+ /// this condition, do so.
+ ///
void abortIfBroken() const {
if (Broken && AbortBroken) {
std::cerr << "Broken module found, compilation aborted!\n";
@@ -167,7 +165,6 @@
// CheckFailed - A check failed, so print out the condition and the message
// that failed. This provides a nice place to put a breakpoint if you want
// to see why something is not correct.
- //
void CheckFailed(const std::string &Message,
const Value *V1 = 0, const Value *V2 = 0,
const Value *V3 = 0, const Value *V4 = 0) {
@@ -338,15 +335,16 @@
visitTerminatorInst(RI);
}
-// visitUserOp1 - User defined operators shouldn't live beyond the lifetime of a
-// pass, if any exist, it's an error.
-//
+/// visitUserOp1 - User defined operators shouldn't live beyond the lifetime of
+/// a pass, if any exist, it's an error.
+///
void Verifier::visitUserOp1(Instruction &I) {
Assert1(0, "User-defined operators should not live outside of a pass!",
&I);
}
-// visitPHINode - Ensure that a PHI node is well formed.
+/// visitPHINode - Ensure that a PHI node is well formed.
+///
void Verifier::visitPHINode(PHINode &PN) {
// Ensure that the PHI nodes are all grouped together at the top of the block.
// This can be tested by checking whether the instruction before this is
@@ -397,9 +395,9 @@
visitInstruction(CI);
}
-// visitBinaryOperator - Check that both arguments to the binary operator are
-// of the same type!
-//
+/// visitBinaryOperator - Check that both arguments to the binary operator are
+/// of the same type!
+///
void Verifier::visitBinaryOperator(BinaryOperator &B) {
Assert1(B.getOperand(0)->getType() == B.getOperand(1)->getType(),
"Both operands to a binary operator are not of the same type!", &B);
@@ -465,8 +463,8 @@
}
-// verifyInstruction - Verify that an instruction is well formed.
-//
+/// verifyInstruction - Verify that an instruction is well formed.
+///
void Verifier::visitInstruction(Instruction &I) {
BasicBlock *BB = I.getParent();
Assert1(BB, "Instruction not embedded in basic block!", &I);
@@ -486,7 +484,6 @@
// Check that all uses of the instruction, if they are instructions
// themselves, actually have parent basic blocks. If the use is not an
// instruction, it is an error!
- //
for (User::use_iterator UI = I.use_begin(), UE = I.use_end();
UI != UE; ++UI) {
Assert1(isa<Instruction>(*UI), "Use of instruction is not an instruction!",
@@ -507,7 +504,6 @@
BasicBlock *OpBlock = Op->getParent();
// Check that a definition dominates all of its uses.
- //
if (!isa<PHINode>(I)) {
// Invoke results are only usable in the normal destination, not in the
// exceptional destination.
@@ -531,6 +527,7 @@
}
/// visitIntrinsicFunction - Allow intrinsics to be verified in different ways.
+///
void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
Function *IF = CI.getCalledFunction();
const FunctionType *FT = IF->getFunctionType();
@@ -629,9 +626,9 @@
return V.Broken;
}
-// verifyModule - Check a module for errors, printing messages on stderr.
-// Return true if the module is corrupt.
-//
+/// verifyModule - Check a module for errors, printing messages on stderr.
+/// Return true if the module is corrupt.
+///
bool llvm::verifyModule(const Module &M) {
PassManager PM;
Verifier *V = new Verifier();
More information about the llvm-commits
mailing list