diff options
author | Chris Lattner <sabre@nondot.org> | 2006-11-01 18:03:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-11-01 18:03:33 +0000 |
commit | 25de4e5c21b8ef1bbf6d625de548ca3508c58947 (patch) | |
tree | 9dbb59e76c7413be89f7d0e242d3b3024e1b50d3 /lib/Transforms | |
parent | 22c8648b8aa88ecf56f331f115c45681530a6b4a (diff) | |
download | external_llvm-25de4e5c21b8ef1bbf6d625de548ca3508c58947.zip external_llvm-25de4e5c21b8ef1bbf6d625de548ca3508c58947.tar.gz external_llvm-25de4e5c21b8ef1bbf6d625de548ca3508c58947.tar.bz2 |
Fix GlobalOpt/2006-11-01-ShrinkGlobalPhiCrash.ll and McGill/chomp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31352 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/IPO/GlobalOpt.cpp | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index fc39fe8..bc5aecd 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -104,17 +104,20 @@ struct GlobalStatus { /// ever stored to this global, keep track of what value it is. Value *StoredOnceValue; - // AccessingFunction/HasMultipleAccessingFunctions - These start out - // null/false. When the first accessing function is noticed, it is recorded. - // When a second different accessing function is noticed, - // HasMultipleAccessingFunctions is set to true. + /// AccessingFunction/HasMultipleAccessingFunctions - These start out + /// null/false. When the first accessing function is noticed, it is recorded. + /// When a second different accessing function is noticed, + /// HasMultipleAccessingFunctions is set to true. Function *AccessingFunction; bool HasMultipleAccessingFunctions; - // HasNonInstructionUser - Set to true if this global has a user that is not - // an instruction (e.g. a constant expr or GV initializer). + /// HasNonInstructionUser - Set to true if this global has a user that is not + /// an instruction (e.g. a constant expr or GV initializer). bool HasNonInstructionUser; + /// HasPHIUser - Set to true if this global has a user that is a PHI node. + bool HasPHIUser; + /// isNotSuitableForSRA - Keep track of whether any SRA preventing users of /// the global exist. Such users include GEP instruction with variable /// indexes, and non-gep/load/store users like constant expr casts. @@ -122,7 +125,8 @@ struct GlobalStatus { GlobalStatus() : isLoaded(false), StoredType(NotStored), StoredOnceValue(0), AccessingFunction(0), HasMultipleAccessingFunctions(false), - HasNonInstructionUser(false), isNotSuitableForSRA(false) {} + HasNonInstructionUser(false), HasPHIUser(false), + isNotSuitableForSRA(false) {} }; @@ -238,6 +242,7 @@ static bool AnalyzeGlobal(Value *V, GlobalStatus &GS, if (PHIUsers.insert(PN).second) // Not already visited. if (AnalyzeGlobal(I, GS, PHIUsers)) return true; GS.isNotSuitableForSRA = true; + GS.HasPHIUser = true; } else if (isa<SetCondInst>(I)) { GS.isNotSuitableForSRA = true; } else if (isa<MemCpyInst>(I) || isa<MemMoveInst>(I)) { @@ -1321,7 +1326,8 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV, // boolean. if (Constant *SOVConstant = dyn_cast<Constant>(GS.StoredOnceValue)) if (GV->getType()->getElementType() != Type::BoolTy && - !GV->getType()->getElementType()->isFloatingPoint()) { + !GV->getType()->getElementType()->isFloatingPoint() && + !GS.HasPHIUser) { DEBUG(std::cerr << " *** SHRINKING TO BOOL: " << *GV); ShrinkGlobalToBoolean(GV, SOVConstant); ++NumShrunkToBool; |