aboutsummaryrefslogtreecommitdiffstats
path: root/lib/AsmParser/LLParser.cpp
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2009-09-25 18:11:52 +0000
committerVictor Hernandez <vhernandez@apple.com>2009-09-25 18:11:52 +0000
commit3e0c99a26f365bddb667124db40a5734e35c5a2d (patch)
tree406ef499eb4ee0c0b5f704d726d1d9c39ad79694 /lib/AsmParser/LLParser.cpp
parenta45bfd31de14321262dd5f5123d04fc953a79ff1 (diff)
downloadexternal_llvm-3e0c99a26f365bddb667124db40a5734e35c5a2d.zip
external_llvm-3e0c99a26f365bddb667124db40a5734e35c5a2d.tar.gz
external_llvm-3e0c99a26f365bddb667124db40a5734e35c5a2d.tar.bz2
Revert 82694 "Auto-upgrade malloc instructions to malloc calls." because it causes regressions in the nightly tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82784 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser/LLParser.cpp')
-rw-r--r--lib/AsmParser/LLParser.cpp46
1 files changed, 7 insertions, 39 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index d90588d..0ecf847 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -69,27 +69,6 @@ bool LLParser::Run() {
/// ValidateEndOfModule - Do final validity and sanity checks at the end of the
/// module.
bool LLParser::ValidateEndOfModule() {
- // Update auto-upgraded malloc calls from "autoupgrade_malloc" to "malloc".
- if (MallocF) {
- MallocF->setName("malloc");
- // If setName() does not set the name to "malloc", then there is already a
- // declaration of "malloc". In that case, iterate over all calls to MallocF
- // and get them to call the declared "malloc" instead.
- if (MallocF->getName() != "malloc") {
- Function* realMallocF = M->getFunction("malloc");
- for (User::use_iterator UI = MallocF->use_begin(), UE= MallocF->use_end();
- UI != UE; ) {
- User* user = *UI;
- UI++;
- if (CallInst *Call = dyn_cast<CallInst>(user))
- Call->setCalledFunction(realMallocF);
- }
- if (!realMallocF->doesNotAlias(0)) realMallocF->setDoesNotAlias(0);
- MallocF->eraseFromParent();
- MallocF = NULL;
- }
- }
-
if (!ForwardRefTypes.empty())
return Error(ForwardRefTypes.begin()->second.second,
"use of undefined type named '" +
@@ -2797,8 +2776,8 @@ bool LLParser::ParseInstruction(Instruction *&Inst, BasicBlock *BB,
case lltok::kw_call: return ParseCall(Inst, PFS, false);
case lltok::kw_tail: return ParseCall(Inst, PFS, true);
// Memory.
- case lltok::kw_alloca: return ParseAlloc(Inst, PFS);
- case lltok::kw_malloc: return ParseAlloc(Inst, PFS, BB, false);
+ case lltok::kw_alloca:
+ case lltok::kw_malloc: return ParseAlloc(Inst, PFS, KeywordVal);
case lltok::kw_free: return ParseFree(Inst, PFS);
case lltok::kw_load: return ParseLoad(Inst, PFS, false);
case lltok::kw_store: return ParseStore(Inst, PFS, false);
@@ -3307,7 +3286,7 @@ bool LLParser::ParseShuffleVector(Instruction *&Inst, PerFunctionState &PFS) {
}
/// ParsePHI
-/// ::= 'phi' Type '[' Value ',' Value ']' (',' '[' Value ',' Valueß ']')*
+/// ::= 'phi' Type '[' Value ',' Value ']' (',' '[' Value ',' Valueß ']')*
bool LLParser::ParsePHI(Instruction *&Inst, PerFunctionState &PFS) {
PATypeHolder Ty(Type::getVoidTy(Context));
Value *Op0, *Op1;
@@ -3452,7 +3431,7 @@ bool LLParser::ParseCall(Instruction *&Inst, PerFunctionState &PFS,
/// ::= 'malloc' Type (',' TypeAndValue)? (',' OptionalInfo)?
/// ::= 'alloca' Type (',' TypeAndValue)? (',' OptionalInfo)?
bool LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS,
- BasicBlock* BB, bool isAlloca) {
+ unsigned Opc) {
PATypeHolder Ty(Type::getVoidTy(Context));
Value *Size = 0;
LocTy SizeLoc;
@@ -3472,21 +3451,10 @@ bool LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS,
if (Size && Size->getType() != Type::getInt32Ty(Context))
return Error(SizeLoc, "element count must be i32");
- if (isAlloca)
+ if (Opc == Instruction::Malloc)
+ Inst = new MallocInst(Ty, Size, Alignment);
+ else
Inst = new AllocaInst(Ty, Size, Alignment);
- else {
- // Autoupgrade old malloc instruction to malloc call.
- const Type* IntPtrTy = Type::getInt32Ty(Context);
- const Type* Int8PtrTy = PointerType::getUnqual(Type::getInt8Ty(Context));
- if (!MallocF)
- // Prototype malloc as "void *autoupgrade_malloc(int32)".
- MallocF = cast<Function>(M->getOrInsertFunction("autoupgrade_malloc",
- Int8PtrTy, IntPtrTy, NULL));
- // "autoupgrade_malloc" updated to "malloc" in ValidateEndOfModule().
-
- Inst = cast<Instruction>(CallInst::CreateMalloc(BB, IntPtrTy, Ty,
- Size, MallocF));
- }
return false;
}