diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-10-31 20:08:37 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-10-31 20:08:37 +0000 |
| commit | 7bc5f36e65090bc44026333e2966b720d0747a0d (patch) | |
| tree | efdb3c359fa548ada932f522239be84ab602df20 /lib/AsmParser | |
| parent | 12f2dae2e58e01e256f08d511bb1a8b1d46b6a95 (diff) | |
| download | external_llvm-7bc5f36e65090bc44026333e2966b720d0747a0d.zip external_llvm-7bc5f36e65090bc44026333e2966b720d0747a0d.tar.gz external_llvm-7bc5f36e65090bc44026333e2966b720d0747a0d.tar.bz2 | |
Make blockaddress(@func, null) be valid, and make 'deleting a basic
block with a blockaddress still referring to it' replace the invalid
blockaddress with a new blockaddress(@func, null) instead of a
inttoptr(1).
This changes the bitcode encoding format, and still needs codegen
support (this should produce a non-zero value, referring to the entry
block of the function would also be quite reasonable).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@85678 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AsmParser')
| -rw-r--r-- | lib/AsmParser/LLParser.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 07bf261..9dbd78c 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -123,20 +123,25 @@ bool LLParser::ResolveForwardRefBlockAddresses(Function *TheFn, // Loop over all the references, resolving them. for (unsigned i = 0, e = Refs.size(); i != e; ++i) { BasicBlock *Res; - if (PFS) { + if (Refs[i].first.Kind == ValID::t_Null) + Res = 0; + else if (PFS) { if (Refs[i].first.Kind == ValID::t_LocalName) Res = PFS->GetBB(Refs[i].first.StrVal, Refs[i].first.Loc); - else + else { + assert(Refs[i].first.Kind == ValID::t_LocalID); Res = PFS->GetBB(Refs[i].first.UIntVal, Refs[i].first.Loc); + } } else if (Refs[i].first.Kind == ValID::t_LocalID) { return Error(Refs[i].first.Loc, "cannot take address of numeric label after it the function is defined"); } else { + assert(Refs[i].first.Kind == ValID::t_LocalName); Res = dyn_cast_or_null<BasicBlock>( TheFn->getValueSymbolTable().lookup(Refs[i].first.StrVal)); } - if (Res == 0) + if (Res == 0 && Refs[i].first.Kind != ValID::t_Null) return Error(Refs[i].first.Loc, "referenced value is not a basic block"); @@ -2055,10 +2060,11 @@ bool LLParser::ParseValID(ValID &ID) { ParseValID(Label) || ParseToken(lltok::rparen, "expected ')' in block address expression")) return true; - + if (Fn.Kind != ValID::t_GlobalID && Fn.Kind != ValID::t_GlobalName) return Error(Fn.Loc, "expected function name in blockaddress"); - if (Label.Kind != ValID::t_LocalID && Label.Kind != ValID::t_LocalName) + if (Label.Kind != ValID::t_LocalID && Label.Kind != ValID::t_LocalName && + Label.Kind != ValID::t_Null) return Error(Label.Loc, "expected basic block name in blockaddress"); // Make a global variable as a placeholder for this reference. |
