diff options
| author | Roman Divacky <rdivacky@FreeBSD.org> | 2010-03-03 17:27:15 +0000 | 
|---|---|---|
| committer | Roman Divacky <rdivacky@FreeBSD.org> | 2010-03-03 17:27:15 +0000 | 
| commit | 67a71b3184ce20a901e874d0ee25e01397dd87ef (patch) | |
| tree | 836a05cff50ca46176117b86029f061fa4db54f0 /lib/Bitcode | |
| parent | 6fe5c7aa327e188b7176daa5595bbf075a6b94df (diff) | |
Notes
Diffstat (limited to 'lib/Bitcode')
| -rw-r--r-- | lib/Bitcode/Reader/BitReader.cpp | 46 | ||||
| -rw-r--r-- | lib/Bitcode/Reader/BitcodeReader.cpp | 13 | ||||
| -rw-r--r-- | lib/Bitcode/Writer/ValueEnumerator.cpp | 5 | 
3 files changed, 41 insertions, 23 deletions
diff --git a/lib/Bitcode/Reader/BitReader.cpp b/lib/Bitcode/Reader/BitReader.cpp index 7537435a6064..15844c0041c3 100644 --- a/lib/Bitcode/Reader/BitReader.cpp +++ b/lib/Bitcode/Reader/BitReader.cpp @@ -45,26 +45,44 @@ LLVMBool LLVMParseBitcodeInContext(LLVMContextRef ContextRef,  /* Reads a module from the specified path, returning via the OutModule parameter     a module provider which performs lazy deserialization. Returns 0 on success.     Optionally returns a human-readable error message via OutMessage. */  -LLVMBool LLVMGetBitcodeModuleProvider(LLVMMemoryBufferRef MemBuf, -                                      LLVMModuleProviderRef *OutMP, -                                      char **OutMessage) { -  return LLVMGetBitcodeModuleProviderInContext(wrap(&getGlobalContext()), -                                               MemBuf, OutMP, OutMessage); -} - -LLVMBool LLVMGetBitcodeModuleProviderInContext(LLVMContextRef ContextRef, -                                               LLVMMemoryBufferRef MemBuf, -                                               LLVMModuleProviderRef *OutMP, -                                               char **OutMessage) { +LLVMBool LLVMGetBitcodeModuleInContext(LLVMContextRef ContextRef, +                                       LLVMMemoryBufferRef MemBuf, +                                       LLVMModuleRef *OutM, +                                       char **OutMessage) {    std::string Message; -  *OutMP = reinterpret_cast<LLVMModuleProviderRef>( -    getLazyBitcodeModule(unwrap(MemBuf), *unwrap(ContextRef), &Message)); -  if (!*OutMP) { +  *OutM = wrap(getLazyBitcodeModule(unwrap(MemBuf), *unwrap(ContextRef), +                                    &Message)); +  if (!*OutM) {      if (OutMessage)        *OutMessage = strdup(Message.c_str());      return 1;    }    return 0; + +} + +LLVMBool LLVMGetBitcodeModule(LLVMMemoryBufferRef MemBuf, LLVMModuleRef *OutM, +                              char **OutMessage) { +  return LLVMGetBitcodeModuleInContext(LLVMGetGlobalContext(), MemBuf, OutM, +                                       OutMessage); +} + +/* Deprecated: Use LLVMGetBitcodeModuleInContext instead. */ +LLVMBool LLVMGetBitcodeModuleProviderInContext(LLVMContextRef ContextRef, +                                               LLVMMemoryBufferRef MemBuf, +                                               LLVMModuleProviderRef *OutMP, +                                               char **OutMessage) { +  return LLVMGetBitcodeModuleInContext(ContextRef, MemBuf, +                                       reinterpret_cast<LLVMModuleRef*>(OutMP), +                                       OutMessage); +} + +/* Deprecated: Use LLVMGetBitcodeModule instead. */ +LLVMBool LLVMGetBitcodeModuleProvider(LLVMMemoryBufferRef MemBuf, +                                      LLVMModuleProviderRef *OutMP, +                                      char **OutMessage) { +  return LLVMGetBitcodeModuleProviderInContext(LLVMGetGlobalContext(), MemBuf, +                                               OutMP, OutMessage);  } diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index cebfbf6e32ec..a32883720be3 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -963,12 +963,12 @@ bool BitcodeReader::ParseConstants() {        V = Constant::getNullValue(CurTy);        break;      case bitc::CST_CODE_INTEGER:   // INTEGER: [intval] -      if (!isa<IntegerType>(CurTy) || Record.empty()) +      if (!CurTy->isIntegerTy() || Record.empty())          return Error("Invalid CST_INTEGER record");        V = ConstantInt::get(CurTy, DecodeSignRotatedValue(Record[0]));        break;      case bitc::CST_CODE_WIDE_INTEGER: {// WIDE_INTEGER: [n x intval] -      if (!isa<IntegerType>(CurTy) || Record.empty()) +      if (!CurTy->isIntegerTy() || Record.empty())          return Error("Invalid WIDE_INTEGER record");        unsigned NumWords = Record.size(); @@ -1407,7 +1407,7 @@ bool BitcodeReader::ParseModule() {        if (Record.size() < 6)          return Error("Invalid MODULE_CODE_GLOBALVAR record");        const Type *Ty = getTypeByID(Record[0]); -      if (!isa<PointerType>(Ty)) +      if (!Ty->isPointerTy())          return Error("Global not a pointer type!");        unsigned AddressSpace = cast<PointerType>(Ty)->getAddressSpace();        Ty = cast<PointerType>(Ty)->getElementType(); @@ -1450,7 +1450,7 @@ bool BitcodeReader::ParseModule() {        if (Record.size() < 8)          return Error("Invalid MODULE_CODE_FUNCTION record");        const Type *Ty = getTypeByID(Record[0]); -      if (!isa<PointerType>(Ty)) +      if (!Ty->isPointerTy())          return Error("Function not a pointer type!");        const FunctionType *FTy =          dyn_cast<FunctionType>(cast<PointerType>(Ty)->getElementType()); @@ -1491,7 +1491,7 @@ bool BitcodeReader::ParseModule() {        if (Record.size() < 3)          return Error("Invalid MODULE_ALIAS record");        const Type *Ty = getTypeByID(Record[0]); -      if (!isa<PointerType>(Ty)) +      if (!Ty->isPointerTy())          return Error("Function not a pointer type!");        GlobalAlias *NewGA = new GlobalAlias(Ty, GetDecodedLinkage(Record[2]), @@ -1622,6 +1622,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {    if (Stream.EnterSubBlock(bitc::FUNCTION_BLOCK_ID))      return Error("Malformed block record"); +  InstructionList.clear();    unsigned ModuleValueListSize = ValueList.size();    // Add all the function arguments to the value table. @@ -1932,7 +1933,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {          const Type *ReturnType = F->getReturnType();          if (Vs.size() > 1 || -            (isa<StructType>(ReturnType) && +            (ReturnType->isStructTy() &&               (Vs.empty() || Vs[0]->getType() != ReturnType))) {            Value *RV = UndefValue::get(ReturnType);            for (unsigned i = 0, e = Vs.size(); i != e; ++i) { diff --git a/lib/Bitcode/Writer/ValueEnumerator.cpp b/lib/Bitcode/Writer/ValueEnumerator.cpp index 595497f6de50..aa4c3afab40e 100644 --- a/lib/Bitcode/Writer/ValueEnumerator.cpp +++ b/lib/Bitcode/Writer/ValueEnumerator.cpp @@ -27,7 +27,7 @@ static bool isSingleValueType(const std::pair<const llvm::Type*,  }  static bool isIntegerValue(const std::pair<const Value*, unsigned> &V) { -  return isa<IntegerType>(V.first->getType()); +  return V.first->getType()->isIntegerTy();  }  static bool CompareByFrequency(const std::pair<const llvm::Type*, @@ -39,8 +39,6 @@ static bool CompareByFrequency(const std::pair<const llvm::Type*,  /// ValueEnumerator - Enumerate module-level information.  ValueEnumerator::ValueEnumerator(const Module *M) { -  InstructionCount = 0; -    // Enumerate the global variables.    for (Module::const_global_iterator I = M->global_begin(),           E = M->global_end(); I != E; ++I) @@ -377,6 +375,7 @@ void ValueEnumerator::EnumerateAttributes(const AttrListPtr &PAL) {  void ValueEnumerator::incorporateFunction(const Function &F) { +  InstructionCount = 0;    NumModuleValues = Values.size();    // Adding function arguments to the value table.  | 
