diff options
author | Duncan Sands <baldrick@free.fr> | 2007-11-27 13:23:08 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2007-11-27 13:23:08 +0000 |
commit | dc024674ff96820d6020757b48d47f46d4c07db2 (patch) | |
tree | 843dfcaeb8f6c99de930a32020148b563005c2fd /lib/Bitcode/Writer/ValueEnumerator.cpp | |
parent | f19341dec7361451f100a882a023b14583454d7e (diff) |
Fix PR1146: parameter attributes are longer part of
the function type, instead they belong to functions
and function calls. This is an updated and slightly
corrected version of Reid Spencer's original patch.
The only known problem is that auto-upgrading of
bitcode files doesn't seem to work properly (see
test/Bitcode/AutoUpgradeIntrinsics.ll). Hopefully
a bitcode guru (who might that be? :) ) will fix it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44359 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Writer/ValueEnumerator.cpp')
-rw-r--r-- | lib/Bitcode/Writer/ValueEnumerator.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/Bitcode/Writer/ValueEnumerator.cpp b/lib/Bitcode/Writer/ValueEnumerator.cpp index 6b3885ed1c..21b03725ff 100644 --- a/lib/Bitcode/Writer/ValueEnumerator.cpp +++ b/lib/Bitcode/Writer/ValueEnumerator.cpp @@ -17,6 +17,7 @@ #include "llvm/Module.h" #include "llvm/TypeSymbolTable.h" #include "llvm/ValueSymbolTable.h" +#include "llvm/Instructions.h" #include <algorithm> using namespace llvm; @@ -44,8 +45,10 @@ ValueEnumerator::ValueEnumerator(const Module *M) { EnumerateValue(I); // Enumerate the functions. - for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) + for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) { EnumerateValue(I); + EnumerateParamAttrs(cast<Function>(I)->getParamAttrs()); + } // Enumerate the aliases. for (Module::const_alias_iterator I = M->alias_begin(), E = M->alias_end(); @@ -86,6 +89,10 @@ ValueEnumerator::ValueEnumerator(const Module *M) { OI != E; ++OI) EnumerateOperandType(*OI); EnumerateType(I->getType()); + if (const CallInst *CI = dyn_cast<CallInst>(I)) + EnumerateParamAttrs(CI->getParamAttrs()); + else if (const InvokeInst *II = dyn_cast<InvokeInst>(I)) + EnumerateParamAttrs(II->getParamAttrs()); } } @@ -220,10 +227,6 @@ void ValueEnumerator::EnumerateType(const Type *Ty) { for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); I != E; ++I) EnumerateType(*I); - - // If this is a function type, enumerate the param attrs. - if (const FunctionType *FTy = dyn_cast<FunctionType>(Ty)) - EnumerateParamAttrs(FTy->getParamAttrs()); } // Enumerate the types for the specified value. If the value is a constant, @@ -296,6 +299,10 @@ void ValueEnumerator::incorporateFunction(const Function &F) { // Optimize the constant layout. OptimizeConstants(FirstFuncConstantID, Values.size()); + // Add the function's parameter attributes so they are available for use in + // the function's instruction. + EnumerateParamAttrs(F.getParamAttrs()); + FirstInstID = Values.size(); // Add all of the instructions. |