diff options
author | emaste <emaste@FreeBSD.org> | 2015-02-06 21:38:51 +0000 |
---|---|---|
committer | emaste <emaste@FreeBSD.org> | 2015-02-06 21:38:51 +0000 |
commit | 0c2019f4ca6b2dc6d710f6bb16a0e3ed10271531 (patch) | |
tree | 09bc83f73246ee3c7a779605cd0122093d2a8a19 /source/Expression/IRForTarget.cpp | |
parent | 01ee1789d6aa7294e5966a97f8d29387f6f81699 (diff) | |
download | FreeBSD-src-0c2019f4ca6b2dc6d710f6bb16a0e3ed10271531.zip FreeBSD-src-0c2019f4ca6b2dc6d710f6bb16a0e3ed10271531.tar.gz |
Import LLDB as of upstream SVN r225923 (git 2b588ecd)
This corresponds with the branchpoint for the 3.6 release.
A number of files not required for the FreeBSD build have been removed.
Sponsored by: DARPA, AFRL
Diffstat (limited to 'source/Expression/IRForTarget.cpp')
-rw-r--r-- | source/Expression/IRForTarget.cpp | 54 |
1 files changed, 23 insertions, 31 deletions
diff --git a/source/Expression/IRForTarget.cpp b/source/Expression/IRForTarget.cpp index b91e1b4..8e75c32 100644 --- a/source/Expression/IRForTarget.cpp +++ b/source/Expression/IRForTarget.cpp @@ -18,6 +18,7 @@ #include "llvm/IR/Module.h" #include "llvm/PassManager.h" #include "llvm/Transforms/IPO.h" +#include "llvm/IR/Metadata.h" #include "llvm/IR/ValueSymbolTable.h" #include "clang/AST/ASTContext.h" @@ -403,18 +404,17 @@ IRForTarget::DeclForGlobal (const GlobalValue *global_val, Module *module) node_index < num_nodes; ++node_index) { - MDNode *metadata_node = named_metadata->getOperand(node_index); - + llvm::MDNode *metadata_node = dyn_cast<llvm::MDNode>(named_metadata->getOperand(node_index)); if (!metadata_node) return NULL; if (metadata_node->getNumOperands() != 2) continue; - if (metadata_node->getOperand(0) != global_val) + if (mdconst::dyn_extract_or_null<GlobalValue>(metadata_node->getOperand(0)) != global_val) continue; - ConstantInt *constant_int = dyn_cast<ConstantInt>(metadata_node->getOperand(1)); + ConstantInt *constant_int = mdconst::dyn_extract<ConstantInt>(metadata_node->getOperand(1)); if (!constant_int) return NULL; @@ -639,11 +639,11 @@ IRForTarget::CreateResultVariable (llvm::Function &llvm_function) reinterpret_cast<uint64_t>(result_decl), false); - llvm::Value* values[2]; - values[0] = new_result_global; - values[1] = new_constant_int; + llvm::Metadata *values[2]; + values[0] = ConstantAsMetadata::get(new_result_global); + values[1] = ConstantAsMetadata::get(new_constant_int); - ArrayRef<Value*> value_ref(values, 2); + ArrayRef<Metadata *> value_ref(values, 2); MDNode *persistent_global_md = MDNode::get(m_module->getContext(), value_ref); NamedMDNode *named_metadata = m_module->getNamedMetadata("clang.global.decl.ptrs"); @@ -1037,7 +1037,7 @@ static bool IsObjCSelectorRef (Value *value) { GlobalVariable *global_variable = dyn_cast<GlobalVariable>(value); - if (!global_variable || !global_variable->hasName() || !global_variable->getName().startswith("\01L_OBJC_SELECTOR_REFERENCES_")) + if (!global_variable || !global_variable->hasName() || !global_variable->getName().startswith("OBJC_SELECTOR_REFERENCES_")) return false; return true; @@ -1056,12 +1056,12 @@ IRForTarget::RewriteObjCSelector (Instruction* selector_load) // Unpack the message name from the selector. In LLVM IR, an objc_msgSend gets represented as // - // %tmp = load i8** @"\01L_OBJC_SELECTOR_REFERENCES_" ; <i8*> + // %tmp = load i8** @"OBJC_SELECTOR_REFERENCES_" ; <i8*> // %call = call i8* (i8*, i8*, ...)* @objc_msgSend(i8* %obj, i8* %tmp, ...) ; <i8*> // // where %obj is the object pointer and %tmp is the selector. // - // @"\01L_OBJC_SELECTOR_REFERENCES_" is a pointer to a character array called @"\01L_OBJC_llvm_moduleETH_VAR_NAllvm_moduleE_". + // @"OBJC_SELECTOR_REFERENCES_" is a pointer to a character array called @"\01L_OBJC_llvm_moduleETH_VAR_NAllvm_moduleE_". // @"\01L_OBJC_llvm_moduleETH_VAR_NAllvm_moduleE_" contains the string. // Find the pointer's initializer (a ConstantExpr with opcode GetElementPtr) and get the string from its target @@ -1215,7 +1215,7 @@ IRForTarget::RewritePersistentAlloc (llvm::Instruction *persistent_alloc) if (!alloc_md || !alloc_md->getNumOperands()) return false; - ConstantInt *constant_int = dyn_cast<ConstantInt>(alloc_md->getOperand(0)); + ConstantInt *constant_int = mdconst::dyn_extract<ConstantInt>(alloc_md->getOperand(0)); if (!constant_int) return false; @@ -1246,11 +1246,11 @@ IRForTarget::RewritePersistentAlloc (llvm::Instruction *persistent_alloc) NamedMDNode *named_metadata = m_module->getOrInsertNamedMetadata("clang.global.decl.ptrs"); - llvm::Value* values[2]; - values[0] = persistent_global; - values[1] = constant_int; + llvm::Metadata *values[2]; + values[0] = ConstantAsMetadata::get(persistent_global); + values[1] = ConstantAsMetadata::get(constant_int); - ArrayRef<llvm::Value*> value_ref(values, 2); + ArrayRef<llvm::Metadata *> value_ref(values, 2); MDNode *persistent_global_md = MDNode::get(m_module->getContext(), value_ref); named_metadata->addOperand(persistent_global_md); @@ -2043,8 +2043,12 @@ static bool isGuardVariableRef(Value *V) GlobalVariable *GV = dyn_cast<GlobalVariable>(Old); - if (!GV || !GV->hasName() || !GV->getName().startswith("_ZGV")) + if (!GV || !GV->hasName() || + (!GV->getName().startswith("_ZGV") && // Itanium ABI guard variable + !GV->getName().endswith("@4IA"))) // Microsoft ABI guard variable + { return false; + } return true; } @@ -2052,20 +2056,8 @@ static bool isGuardVariableRef(Value *V) void IRForTarget::TurnGuardLoadIntoZero(llvm::Instruction* guard_load) { - Constant* zero(ConstantInt::get(Type::getInt8Ty(m_module->getContext()), 0, true)); - - for (llvm::User *u : guard_load->users()) - { - if (isa<Constant>(u)) - { - // do nothing for the moment - } - else - { - u->replaceUsesOfWith(guard_load, zero); - } - } - + Constant *zero(Constant::getNullValue(guard_load->getType())); + guard_load->replaceAllUsesWith(zero); guard_load->eraseFromParent(); } |