· 6 years ago · Apr 10, 2019, 11:50 AM
1diff -r -u llvm-7.0.0.src/lib/AsmParser/LLLexer.cpp llvm-8.0.0.src/lib/AsmParser/LLLexer.cpp
2--- llvm-7.0.0.src/lib/AsmParser/LLLexer.cpp 2018-07-12 11:03:53.000000000 +0900
3+++ llvm-8.0.0.src/lib/AsmParser/LLLexer.cpp 2018-11-29 06:14:32.000000000 +0900
4@@ -592,6 +592,7 @@
5 KEYWORD(arm_apcscc);
6 KEYWORD(arm_aapcscc);
7 KEYWORD(arm_aapcs_vfpcc);
8+ KEYWORD(aarch64_vector_pcs);
9 KEYWORD(msp430_intrcc);
10 KEYWORD(avr_intrcc);
11 KEYWORD(avr_signalcc);
12@@ -678,6 +679,7 @@
13 KEYWORD(sanitize_hwaddress);
14 KEYWORD(sanitize_thread);
15 KEYWORD(sanitize_memory);
16+ KEYWORD(speculative_load_hardening);
17 KEYWORD(swifterror);
18 KEYWORD(swiftself);
19 KEYWORD(uwtable);
20@@ -738,6 +740,7 @@
21 KEYWORD(readOnly);
22 KEYWORD(noRecurse);
23 KEYWORD(returnDoesNotAlias);
24+ KEYWORD(noInline);
25 KEYWORD(calls);
26 KEYWORD(callee);
27 KEYWORD(hotness);
28@@ -785,6 +788,7 @@
29 KEYWORD(info);
30 KEYWORD(byte);
31 KEYWORD(bit);
32+ KEYWORD(varFlags);
33
34 #undef KEYWORD
35
36@@ -820,6 +824,8 @@
37 } \
38 } while (false)
39
40+ INSTKEYWORD(fneg, FNeg);
41+
42 INSTKEYWORD(add, Add); INSTKEYWORD(fadd, FAdd);
43 INSTKEYWORD(sub, Sub); INSTKEYWORD(fsub, FSub);
44 INSTKEYWORD(mul, Mul); INSTKEYWORD(fmul, FMul);
45@@ -899,17 +905,27 @@
46 return lltok::DIFlag;
47 }
48
49+ if (Keyword.startswith("DISPFlag")) {
50+ StrVal.assign(Keyword.begin(), Keyword.end());
51+ return lltok::DISPFlag;
52+ }
53+
54 if (Keyword.startswith("CSK_")) {
55 StrVal.assign(Keyword.begin(), Keyword.end());
56 return lltok::ChecksumKind;
57 }
58
59 if (Keyword == "NoDebug" || Keyword == "FullDebug" ||
60- Keyword == "LineTablesOnly") {
61+ Keyword == "LineTablesOnly" || Keyword == "DebugDirectivesOnly") {
62 StrVal.assign(Keyword.begin(), Keyword.end());
63 return lltok::EmissionKind;
64 }
65
66+ if (Keyword == "GNU" || Keyword == "None" || Keyword == "Default") {
67+ StrVal.assign(Keyword.begin(), Keyword.end());
68+ return lltok::NameTableKind;
69+ }
70+
71 // Check for [us]0x[0-9A-Fa-f]+ which are Hexadecimal constant generated by
72 // the CFE to avoid forcing it to deal with 64-bit numbers.
73 if ((TokStart[0] == 'u' || TokStart[0] == 's') &&
74diff -r -u llvm-7.0.0.src/lib/AsmParser/LLParser.cpp llvm-8.0.0.src/lib/AsmParser/LLParser.cpp
75--- llvm-7.0.0.src/lib/AsmParser/LLParser.cpp 2018-11-13 10:04:11.002536171 +0900
76+++ llvm-8.0.0.src/lib/AsmParser/LLParser.cpp 2019-01-13 03:36:22.000000000 +0900
77@@ -1276,6 +1276,9 @@
78 B.addAttribute(Attribute::SanitizeThread); break;
79 case lltok::kw_sanitize_memory:
80 B.addAttribute(Attribute::SanitizeMemory); break;
81+ case lltok::kw_speculative_load_hardening:
82+ B.addAttribute(Attribute::SpeculativeLoadHardening);
83+ break;
84 case lltok::kw_strictfp: B.addAttribute(Attribute::StrictFP); break;
85 case lltok::kw_uwtable: B.addAttribute(Attribute::UWTable); break;
86 case lltok::kw_writeonly: B.addAttribute(Attribute::WriteOnly); break;
87@@ -1317,7 +1320,8 @@
88 static inline GlobalValue *createGlobalFwdRef(Module *M, PointerType *PTy,
89 const std::string &Name) {
90 if (auto *FT = dyn_cast<FunctionType>(PTy->getElementType()))
91- return Function::Create(FT, GlobalValue::ExternalWeakLinkage, Name, M);
92+ return Function::Create(FT, GlobalValue::ExternalWeakLinkage,
93+ PTy->getAddressSpace(), Name, M);
94 else
95 return new GlobalVariable(*M, PTy->getElementType(), false,
96 GlobalValue::ExternalWeakLinkage, nullptr, Name,
97@@ -1325,11 +1329,33 @@
98 PTy->getAddressSpace());
99 }
100
101+Value *LLParser::checkValidVariableType(LocTy Loc, const Twine &Name, Type *Ty,
102+ Value *Val, bool IsCall) {
103+ if (Val->getType() == Ty)
104+ return Val;
105+ // For calls we also accept variables in the program address space.
106+ Type *SuggestedTy = Ty;
107+ if (IsCall && isa<PointerType>(Ty)) {
108+ Type *TyInProgAS = cast<PointerType>(Ty)->getElementType()->getPointerTo(
109+ M->getDataLayout().getProgramAddressSpace());
110+ SuggestedTy = TyInProgAS;
111+ if (Val->getType() == TyInProgAS)
112+ return Val;
113+ }
114+ if (Ty->isLabelTy())
115+ Error(Loc, "'" + Name + "' is not a basic block");
116+ else
117+ Error(Loc, "'" + Name + "' defined with type '" +
118+ getTypeString(Val->getType()) + "' but expected '" +
119+ getTypeString(SuggestedTy) + "'");
120+ return nullptr;
121+}
122+
123 /// GetGlobalVal - Get a value with the specified name or ID, creating a
124 /// forward reference record if needed. This can return null if the value
125 /// exists but does not have the right type.
126 GlobalValue *LLParser::GetGlobalVal(const std::string &Name, Type *Ty,
127- LocTy Loc) {
128+ LocTy Loc, bool IsCall) {
129 PointerType *PTy = dyn_cast<PointerType>(Ty);
130 if (!PTy) {
131 Error(Loc, "global variable reference must have pointer type");
132@@ -1349,12 +1375,9 @@
133 }
134
135 // If we have the value in the symbol table or fwd-ref table, return it.
136- if (Val) {
137- if (Val->getType() == Ty) return Val;
138- Error(Loc, "'@" + Name + "' defined with type '" +
139- getTypeString(Val->getType()) + "'");
140- return nullptr;
141- }
142+ if (Val)
143+ return cast_or_null<GlobalValue>(
144+ checkValidVariableType(Loc, "@" + Name, Ty, Val, IsCall));
145
146 // Otherwise, create a new forward reference for this value and remember it.
147 GlobalValue *FwdVal = createGlobalFwdRef(M, PTy, Name);
148@@ -1362,7 +1385,8 @@
149 return FwdVal;
150 }
151
152-GlobalValue *LLParser::GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc) {
153+GlobalValue *LLParser::GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc,
154+ bool IsCall) {
155 PointerType *PTy = dyn_cast<PointerType>(Ty);
156 if (!PTy) {
157 Error(Loc, "global variable reference must have pointer type");
158@@ -1380,12 +1404,9 @@
159 }
160
161 // If we have the value in the symbol table or fwd-ref table, return it.
162- if (Val) {
163- if (Val->getType() == Ty) return Val;
164- Error(Loc, "'@" + Twine(ID) + "' defined with type '" +
165- getTypeString(Val->getType()) + "'");
166- return nullptr;
167- }
168+ if (Val)
169+ return cast_or_null<GlobalValue>(
170+ checkValidVariableType(Loc, "@" + Twine(ID), Ty, Val, IsCall));
171
172 // Otherwise, create a new forward reference for this value and remember it.
173 GlobalValue *FwdVal = createGlobalFwdRef(M, PTy, "");
174@@ -1500,8 +1521,8 @@
175 /// ParseOptionalAddrSpace
176 /// := /*empty*/
177 /// := 'addrspace' '(' uint32 ')'
178-bool LLParser::ParseOptionalAddrSpace(unsigned &AddrSpace) {
179- AddrSpace = 0;
180+bool LLParser::ParseOptionalAddrSpace(unsigned &AddrSpace, unsigned DefaultAS) {
181+ AddrSpace = DefaultAS;
182 if (!EatIfPresent(lltok::kw_addrspace))
183 return false;
184 return ParseToken(lltok::lparen, "expected '(' in address space") ||
185@@ -1601,6 +1622,7 @@
186 case lltok::kw_sanitize_hwaddress:
187 case lltok::kw_sanitize_memory:
188 case lltok::kw_sanitize_thread:
189+ case lltok::kw_speculative_load_hardening:
190 case lltok::kw_ssp:
191 case lltok::kw_sspreq:
192 case lltok::kw_sspstrong:
193@@ -1697,6 +1719,7 @@
194 case lltok::kw_sanitize_hwaddress:
195 case lltok::kw_sanitize_memory:
196 case lltok::kw_sanitize_thread:
197+ case lltok::kw_speculative_load_hardening:
198 case lltok::kw_ssp:
199 case lltok::kw_sspreq:
200 case lltok::kw_sspstrong:
201@@ -1851,6 +1874,7 @@
202 /// ::= 'arm_apcscc'
203 /// ::= 'arm_aapcscc'
204 /// ::= 'arm_aapcs_vfpcc'
205+/// ::= 'aarch64_vector_pcs'
206 /// ::= 'msp430_intrcc'
207 /// ::= 'avr_intrcc'
208 /// ::= 'avr_signalcc'
209@@ -1894,6 +1918,7 @@
210 case lltok::kw_arm_apcscc: CC = CallingConv::ARM_APCS; break;
211 case lltok::kw_arm_aapcscc: CC = CallingConv::ARM_AAPCS; break;
212 case lltok::kw_arm_aapcs_vfpcc:CC = CallingConv::ARM_AAPCS_VFP; break;
213+ case lltok::kw_aarch64_vector_pcs:CC = CallingConv::AArch64_VectorCall; break;
214 case lltok::kw_msp430_intrcc: CC = CallingConv::MSP430_INTR; break;
215 case lltok::kw_avr_intrcc: CC = CallingConv::AVR_INTR; break;
216 case lltok::kw_avr_signalcc: CC = CallingConv::AVR_SIGNAL; break;
217@@ -2741,19 +2766,6 @@
218 return false;
219 }
220
221-static bool isValidVariableType(Module *M, Type *Ty, Value *Val, bool IsCall) {
222- if (Val->getType() == Ty)
223- return true;
224- // For calls we also accept variables in the program address space
225- if (IsCall && isa<PointerType>(Ty)) {
226- Type *TyInProgAS = cast<PointerType>(Ty)->getElementType()->getPointerTo(
227- M->getDataLayout().getProgramAddressSpace());
228- if (Val->getType() == TyInProgAS)
229- return true;
230- }
231- return false;
232-}
233-
234 /// GetVal - Get a value with the specified name or ID, creating a
235 /// forward reference record if needed. This can return null if the value
236 /// exists but does not have the right type.
237@@ -2771,16 +2783,8 @@
238 }
239
240 // If we have the value in the symbol table or fwd-ref table, return it.
241- if (Val) {
242- if (isValidVariableType(P.M, Ty, Val, IsCall))
243- return Val;
244- if (Ty->isLabelTy())
245- P.Error(Loc, "'%" + Name + "' is not a basic block");
246- else
247- P.Error(Loc, "'%" + Name + "' defined with type '" +
248- getTypeString(Val->getType()) + "'");
249- return nullptr;
250- }
251+ if (Val)
252+ return P.checkValidVariableType(Loc, "%" + Name, Ty, Val, IsCall);
253
254 // Don't make placeholders with invalid type.
255 if (!Ty->isFirstClassType()) {
256@@ -2814,16 +2818,8 @@
257 }
258
259 // If we have the value in the symbol table or fwd-ref table, return it.
260- if (Val) {
261- if (isValidVariableType(P.M, Ty, Val, IsCall))
262- return Val;
263- if (Ty->isLabelTy())
264- P.Error(Loc, "'%" + Twine(ID) + "' is not a basic block");
265- else
266- P.Error(Loc, "'%" + Twine(ID) + "' defined with type '" +
267- getTypeString(Val->getType()) + "'");
268- return nullptr;
269- }
270+ if (Val)
271+ return P.checkValidVariableType(Loc, "%" + Twine(ID), Ty, Val, IsCall);
272
273 if (!Ty->isFirstClassType()) {
274 P.Error(Loc, "invalid use of a non-first-class type");
275@@ -3299,7 +3295,31 @@
276 ID.Kind = ValID::t_Constant;
277 return false;
278 }
279-
280+
281+ // Unary Operators.
282+ case lltok::kw_fneg: {
283+ unsigned Opc = Lex.getUIntVal();
284+ Constant *Val;
285+ Lex.Lex();
286+ if (ParseToken(lltok::lparen, "expected '(' in unary constantexpr") ||
287+ ParseGlobalTypeAndValue(Val) ||
288+ ParseToken(lltok::rparen, "expected ')' in unary constantexpr"))
289+ return true;
290+
291+ // Check that the type is valid for the operator.
292+ switch (Opc) {
293+ case Instruction::FNeg:
294+ if (!Val->getType()->isFPOrFPVectorTy())
295+ return Error(ID.Loc, "constexpr requires fp operands");
296+ break;
297+ default: llvm_unreachable("Unknown unary operator!");
298+ }
299+ unsigned Flags = 0;
300+ Constant *C = ConstantExpr::get(Opc, Val, Flags);
301+ ID.ConstantVal = C;
302+ ID.Kind = ValID::t_Constant;
303+ return false;
304+ }
305 // Binary Operators.
306 case lltok::kw_add:
307 case lltok::kw_fadd:
308@@ -3718,10 +3738,21 @@
309 EmissionKindField() : MDUnsignedField(0, DICompileUnit::LastEmissionKind) {}
310 };
311
312+struct NameTableKindField : public MDUnsignedField {
313+ NameTableKindField()
314+ : MDUnsignedField(
315+ 0, (unsigned)
316+ DICompileUnit::DebugNameTableKind::LastDebugNameTableKind) {}
317+};
318+
319 struct DIFlagField : public MDFieldImpl<DINode::DIFlags> {
320 DIFlagField() : MDFieldImpl(DINode::FlagZero) {}
321 };
322
323+struct DISPFlagField : public MDFieldImpl<DISubprogram::DISPFlags> {
324+ DISPFlagField() : MDFieldImpl(DISubprogram::SPFlagZero) {}
325+};
326+
327 struct MDSignedField : public MDFieldImpl<int64_t> {
328 int64_t Min;
329 int64_t Max;
330@@ -3938,6 +3969,25 @@
331
332 template <>
333 bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
334+ NameTableKindField &Result) {
335+ if (Lex.getKind() == lltok::APSInt)
336+ return ParseMDField(Loc, Name, static_cast<MDUnsignedField &>(Result));
337+
338+ if (Lex.getKind() != lltok::NameTableKind)
339+ return TokError("expected nameTable kind");
340+
341+ auto Kind = DICompileUnit::getNameTableKind(Lex.getStrVal());
342+ if (!Kind)
343+ return TokError("invalid nameTable kind" + Twine(" '") + Lex.getStrVal() +
344+ "'");
345+ assert(((unsigned)*Kind) <= Result.Max && "Expected valid nameTable kind");
346+ Result.assign((unsigned)*Kind);
347+ Lex.Lex();
348+ return false;
349+}
350+
351+template <>
352+bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
353 DwarfAttEncodingField &Result) {
354 if (Lex.getKind() == lltok::APSInt)
355 return ParseMDField(Loc, Name, static_cast<MDUnsignedField &>(Result));
356@@ -3995,6 +4045,46 @@
357 return false;
358 }
359
360+/// DISPFlagField
361+/// ::= uint32
362+/// ::= DISPFlagVector
363+/// ::= DISPFlagVector '|' DISPFlag* '|' uint32
364+template <>
365+bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DISPFlagField &Result) {
366+
367+ // Parser for a single flag.
368+ auto parseFlag = [&](DISubprogram::DISPFlags &Val) {
369+ if (Lex.getKind() == lltok::APSInt && !Lex.getAPSIntVal().isSigned()) {
370+ uint32_t TempVal = static_cast<uint32_t>(Val);
371+ bool Res = ParseUInt32(TempVal);
372+ Val = static_cast<DISubprogram::DISPFlags>(TempVal);
373+ return Res;
374+ }
375+
376+ if (Lex.getKind() != lltok::DISPFlag)
377+ return TokError("expected debug info flag");
378+
379+ Val = DISubprogram::getFlag(Lex.getStrVal());
380+ if (!Val)
381+ return TokError(Twine("invalid subprogram debug info flag '") +
382+ Lex.getStrVal() + "'");
383+ Lex.Lex();
384+ return false;
385+ };
386+
387+ // Parse the flags and combine them together.
388+ DISubprogram::DISPFlags Combined = DISubprogram::SPFlagZero;
389+ do {
390+ DISubprogram::DISPFlags Val;
391+ if (parseFlag(Val))
392+ return true;
393+ Combined |= Val;
394+ } while (EatIfPresent(lltok::bar));
395+
396+ Result.assign(Combined);
397+ return false;
398+}
399+
400 template <>
401 bool LLParser::ParseMDField(LocTy Loc, StringRef Name,
402 MDSignedField &Result) {
403@@ -4206,18 +4296,21 @@
404 (IsDistinct ? CLASS::getDistinct ARGS : CLASS::get ARGS)
405
406 /// ParseDILocationFields:
407-/// ::= !DILocation(line: 43, column: 8, scope: !5, inlinedAt: !6)
408+/// ::= !DILocation(line: 43, column: 8, scope: !5, inlinedAt: !6,
409+/// isImplicitCode: true)
410 bool LLParser::ParseDILocation(MDNode *&Result, bool IsDistinct) {
411 #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
412 OPTIONAL(line, LineField, ); \
413 OPTIONAL(column, ColumnField, ); \
414 REQUIRED(scope, MDField, (/* AllowNull */ false)); \
415- OPTIONAL(inlinedAt, MDField, );
416+ OPTIONAL(inlinedAt, MDField, ); \
417+ OPTIONAL(isImplicitCode, MDBoolField, (false));
418 PARSE_MD_FIELDS();
419 #undef VISIT_MD_FIELDS
420
421- Result = GET_OR_DISTINCT(
422- DILocation, (Context, line.Val, column.Val, scope.Val, inlinedAt.Val));
423+ Result =
424+ GET_OR_DISTINCT(DILocation, (Context, line.Val, column.Val, scope.Val,
425+ inlinedAt.Val, isImplicitCode.Val));
426 return false;
427 }
428
429@@ -4281,19 +4374,21 @@
430 }
431
432 /// ParseDIBasicType:
433-/// ::= !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32)
434+/// ::= !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32,
435+/// encoding: DW_ATE_encoding, flags: 0)
436 bool LLParser::ParseDIBasicType(MDNode *&Result, bool IsDistinct) {
437 #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
438 OPTIONAL(tag, DwarfTagField, (dwarf::DW_TAG_base_type)); \
439 OPTIONAL(name, MDStringField, ); \
440 OPTIONAL(size, MDUnsignedField, (0, UINT64_MAX)); \
441 OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX)); \
442- OPTIONAL(encoding, DwarfAttEncodingField, );
443+ OPTIONAL(encoding, DwarfAttEncodingField, ); \
444+ OPTIONAL(flags, DIFlagField, );
445 PARSE_MD_FIELDS();
446 #undef VISIT_MD_FIELDS
447
448 Result = GET_OR_DISTINCT(DIBasicType, (Context, tag.Val, name.Val, size.Val,
449- align.Val, encoding.Val));
450+ align.Val, encoding.Val, flags.Val));
451 return false;
452 }
453
454@@ -4446,7 +4541,8 @@
455 OPTIONAL(dwoId, MDUnsignedField, ); \
456 OPTIONAL(splitDebugInlining, MDBoolField, = true); \
457 OPTIONAL(debugInfoForProfiling, MDBoolField, = false); \
458- OPTIONAL(gnuPubnames, MDBoolField, = false);
459+ OPTIONAL(nameTableKind, NameTableKindField, ); \
460+ OPTIONAL(debugBaseAddress, MDBoolField, = false);
461 PARSE_MD_FIELDS();
462 #undef VISIT_MD_FIELDS
463
464@@ -4454,7 +4550,8 @@
465 Context, language.Val, file.Val, producer.Val, isOptimized.Val, flags.Val,
466 runtimeVersion.Val, splitDebugFilename.Val, emissionKind.Val, enums.Val,
467 retainedTypes.Val, globals.Val, imports.Val, macros.Val, dwoId.Val,
468- splitDebugInlining.Val, debugInfoForProfiling.Val, gnuPubnames.Val);
469+ splitDebugInlining.Val, debugInfoForProfiling.Val, nameTableKind.Val,
470+ debugBaseAddress.Val);
471 return false;
472 }
473
474@@ -4464,8 +4561,8 @@
475 /// isDefinition: true, scopeLine: 8, containingType: !3,
476 /// virtuality: DW_VIRTUALTIY_pure_virtual,
477 /// virtualIndex: 10, thisAdjustment: 4, flags: 11,
478-/// isOptimized: false, templateParams: !4, declaration: !5,
479-/// retainedNodes: !6, thrownTypes: !7)
480+/// spFlags: 10, isOptimized: false, templateParams: !4,
481+/// declaration: !5, retainedNodes: !6, thrownTypes: !7)
482 bool LLParser::ParseDISubprogram(MDNode *&Result, bool IsDistinct) {
483 auto Loc = Lex.getLoc();
484 #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
485@@ -4483,26 +4580,31 @@
486 OPTIONAL(virtualIndex, MDUnsignedField, (0, UINT32_MAX)); \
487 OPTIONAL(thisAdjustment, MDSignedField, (0, INT32_MIN, INT32_MAX)); \
488 OPTIONAL(flags, DIFlagField, ); \
489+ OPTIONAL(spFlags, DISPFlagField, ); \
490 OPTIONAL(isOptimized, MDBoolField, ); \
491 OPTIONAL(unit, MDField, ); \
492 OPTIONAL(templateParams, MDField, ); \
493 OPTIONAL(declaration, MDField, ); \
494- OPTIONAL(retainedNodes, MDField, ); \
495+ OPTIONAL(retainedNodes, MDField, ); \
496 OPTIONAL(thrownTypes, MDField, );
497 PARSE_MD_FIELDS();
498 #undef VISIT_MD_FIELDS
499
500- if (isDefinition.Val && !IsDistinct)
501+ // An explicit spFlags field takes precedence over individual fields in
502+ // older IR versions.
503+ DISubprogram::DISPFlags SPFlags =
504+ spFlags.Seen ? spFlags.Val
505+ : DISubprogram::toSPFlags(isLocal.Val, isDefinition.Val,
506+ isOptimized.Val, virtuality.Val);
507+ if ((SPFlags & DISubprogram::SPFlagDefinition) && !IsDistinct)
508 return Lex.Error(
509 Loc,
510- "missing 'distinct', required for !DISubprogram when 'isDefinition'");
511-
512+ "missing 'distinct', required for !DISubprogram that is a Definition");
513 Result = GET_OR_DISTINCT(
514 DISubprogram,
515 (Context, scope.Val, name.Val, linkageName.Val, file.Val, line.Val,
516- type.Val, isLocal.Val, isDefinition.Val, scopeLine.Val,
517- containingType.Val, virtuality.Val, virtualIndex.Val, thisAdjustment.Val,
518- flags.Val, isOptimized.Val, unit.Val, templateParams.Val,
519+ type.Val, scopeLine.Val, containingType.Val, virtualIndex.Val,
520+ thisAdjustment.Val, flags.Val, SPFlags, unit.Val, templateParams.Val,
521 declaration.Val, retainedNodes.Val, thrownTypes.Val));
522 return false;
523 }
524@@ -4637,7 +4739,8 @@
525 /// ParseDIGlobalVariable:
526 /// ::= !DIGlobalVariable(scope: !0, name: "foo", linkageName: "foo",
527 /// file: !1, line: 7, type: !2, isLocal: false,
528-/// isDefinition: true, declaration: !3, align: 8)
529+/// isDefinition: true, templateParams: !3,
530+/// declaration: !4, align: 8)
531 bool LLParser::ParseDIGlobalVariable(MDNode *&Result, bool IsDistinct) {
532 #define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
533 REQUIRED(name, MDStringField, (/* AllowEmpty */ false)); \
534@@ -4648,15 +4751,17 @@
535 OPTIONAL(type, MDField, ); \
536 OPTIONAL(isLocal, MDBoolField, ); \
537 OPTIONAL(isDefinition, MDBoolField, (true)); \
538+ OPTIONAL(templateParams, MDField, ); \
539 OPTIONAL(declaration, MDField, ); \
540 OPTIONAL(align, MDUnsignedField, (0, UINT32_MAX));
541 PARSE_MD_FIELDS();
542 #undef VISIT_MD_FIELDS
543
544- Result = GET_OR_DISTINCT(DIGlobalVariable,
545- (Context, scope.Val, name.Val, linkageName.Val,
546- file.Val, line.Val, type.Val, isLocal.Val,
547- isDefinition.Val, declaration.Val, align.Val));
548+ Result =
549+ GET_OR_DISTINCT(DIGlobalVariable,
550+ (Context, scope.Val, name.Val, linkageName.Val, file.Val,
551+ line.Val, type.Val, isLocal.Val, isDefinition.Val,
552+ declaration.Val, templateParams.Val, align.Val));
553 return false;
554 }
555
556@@ -4912,10 +5017,10 @@
557 return false;
558 }
559 case ValID::t_GlobalName:
560- V = GetGlobalVal(ID.StrVal, Ty, ID.Loc);
561+ V = GetGlobalVal(ID.StrVal, Ty, ID.Loc, IsCall);
562 return V == nullptr;
563 case ValID::t_GlobalID:
564- V = GetGlobalVal(ID.UIntVal, Ty, ID.Loc);
565+ V = GetGlobalVal(ID.UIntVal, Ty, ID.Loc, IsCall);
566 return V == nullptr;
567 case ValID::t_APSInt:
568 if (!Ty->isIntegerTy())
569@@ -5058,8 +5163,8 @@
570 /// FunctionHeader
571 /// ::= OptionalLinkage OptionalPreemptionSpecifier OptionalVisibility
572 /// OptionalCallingConv OptRetAttrs OptUnnamedAddr Type GlobalName
573-/// '(' ArgList ')' OptFuncAttrs OptSection OptionalAlign OptGC
574-/// OptionalPrefix OptionalPrologue OptPersonalityFn
575+/// '(' ArgList ')' OptAddrSpace OptFuncAttrs OptSection OptionalAlign
576+/// OptGC OptionalPrefix OptionalPrologue OptPersonalityFn
577 bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) {
578 // Parse the linkage.
579 LocTy LinkageLoc = Lex.getLoc();
580@@ -5137,6 +5242,7 @@
581 unsigned Alignment;
582 std::string GC;
583 GlobalValue::UnnamedAddr UnnamedAddr = GlobalValue::UnnamedAddr::None;
584+ unsigned AddrSpace = 0;
585 Constant *Prefix = nullptr;
586 Constant *Prologue = nullptr;
587 Constant *PersonalityFn = nullptr;
588@@ -5144,6 +5250,7 @@
589
590 if (ParseArgumentList(ArgList, isVarArg) ||
591 ParseOptionalUnnamedAddr(UnnamedAddr) ||
592+ ParseOptionalProgramAddrSpace(AddrSpace) ||
593 ParseFnAttributeValuePairs(FuncAttrs, FwdRefAttrGrps, false,
594 BuiltinLoc) ||
595 (EatIfPresent(lltok::kw_section) &&
596@@ -5188,7 +5295,7 @@
597
598 FunctionType *FT =
599 FunctionType::get(RetType, ParamTypeList, isVarArg);
600- PointerType *PFT = PointerType::getUnqual(FT);
601+ PointerType *PFT = PointerType::get(FT, AddrSpace);
602
603 Fn = nullptr;
604 if (!FunctionName.empty()) {
605@@ -5202,8 +5309,9 @@
606 "function as global value!");
607 if (Fn->getType() != PFT)
608 return Error(FRVI->second.second, "invalid forward reference to "
609- "function '" + FunctionName + "' with wrong type!");
610-
611+ "function '" + FunctionName + "' with wrong type: "
612+ "expected '" + getTypeString(PFT) + "' but was '" +
613+ getTypeString(Fn->getType()) + "'");
614 ForwardRefVals.erase(FRVI);
615 } else if ((Fn = M->getFunction(FunctionName))) {
616 // Reject redefinitions.
617@@ -5221,16 +5329,21 @@
618 Fn = cast<Function>(I->second.first);
619 if (Fn->getType() != PFT)
620 return Error(NameLoc, "type of definition and forward reference of '@" +
621- Twine(NumberedVals.size()) + "' disagree");
622+ Twine(NumberedVals.size()) + "' disagree: "
623+ "expected '" + getTypeString(PFT) + "' but was '" +
624+ getTypeString(Fn->getType()) + "'");
625 ForwardRefValIDs.erase(I);
626 }
627 }
628
629 if (!Fn)
630- Fn = Function::Create(FT, GlobalValue::ExternalLinkage, FunctionName, M);
631+ Fn = Function::Create(FT, GlobalValue::ExternalLinkage, AddrSpace,
632+ FunctionName, M);
633 else // Move the forward-reference to the correct spot in the module.
634 M->getFunctionList().splice(M->end(), M->getFunctionList(), Fn);
635
636+ assert(Fn->getAddressSpace() == AddrSpace && "Created function in wrong AS");
637+
638 if (FunctionName.empty())
639 NumberedVals.push_back(Fn);
640
641@@ -5419,7 +5532,7 @@
642
643 // Set the name on the instruction.
644 if (PFS.SetInstName(NameID, NameStr, NameLoc, Inst)) return true;
645- } while (!isa<TerminatorInst>(Inst));
646+ } while (!Inst->isTerminator());
647
648 return false;
649 }
650@@ -5454,6 +5567,16 @@
651 case lltok::kw_catchswitch: return ParseCatchSwitch(Inst, PFS);
652 case lltok::kw_catchpad: return ParseCatchPad(Inst, PFS);
653 case lltok::kw_cleanuppad: return ParseCleanupPad(Inst, PFS);
654+ // Unary Operators.
655+ case lltok::kw_fneg: {
656+ FastMathFlags FMF = EatFastMathFlagsIfPresent();
657+ int Res = ParseUnaryOp(Inst, PFS, KeywordVal, 2);
658+ if (Res != 0)
659+ return Res;
660+ if (FMF.any())
661+ Inst->setFastMathFlags(FMF);
662+ return false;
663+ }
664 // Binary Operators.
665 case lltok::kw_add:
666 case lltok::kw_sub:
667@@ -5749,6 +5872,7 @@
668 std::vector<unsigned> FwdRefAttrGrps;
669 LocTy NoBuiltinLoc;
670 unsigned CC;
671+ unsigned InvokeAddrSpace;
672 Type *RetType = nullptr;
673 LocTy RetTypeLoc;
674 ValID CalleeID;
675@@ -5757,6 +5881,7 @@
676
677 BasicBlock *NormalBB, *UnwindBB;
678 if (ParseOptionalCallingConv(CC) || ParseOptionalReturnAttrs(RetAttrs) ||
679+ ParseOptionalProgramAddrSpace(InvokeAddrSpace) ||
680 ParseType(RetType, RetTypeLoc, true /*void allowed*/) ||
681 ParseValID(CalleeID) || ParseParameterList(ArgList, PFS) ||
682 ParseFnAttributeValuePairs(FnAttrs, FwdRefAttrGrps, false,
683@@ -5788,8 +5913,8 @@
684
685 // Look up the callee.
686 Value *Callee;
687- if (ConvertValIDToValue(PointerType::getUnqual(Ty), CalleeID, Callee, &PFS,
688- /*IsCall=*/true))
689+ if (ConvertValIDToValue(PointerType::get(Ty, InvokeAddrSpace), CalleeID,
690+ Callee, &PFS, /*IsCall=*/true))
691 return true;
692
693 // Set up the Attribute for the function.
694@@ -6024,6 +6149,43 @@
695 }
696
697 //===----------------------------------------------------------------------===//
698+// Unary Operators.
699+//===----------------------------------------------------------------------===//
700+
701+/// ParseUnaryOp
702+/// ::= UnaryOp TypeAndValue ',' Value
703+///
704+/// If OperandType is 0, then any FP or integer operand is allowed. If it is 1,
705+/// then any integer operand is allowed, if it is 2, any fp operand is allowed.
706+bool LLParser::ParseUnaryOp(Instruction *&Inst, PerFunctionState &PFS,
707+ unsigned Opc, unsigned OperandType) {
708+ LocTy Loc; Value *LHS;
709+ if (ParseTypeAndValue(LHS, Loc, PFS))
710+ return true;
711+
712+ bool Valid;
713+ switch (OperandType) {
714+ default: llvm_unreachable("Unknown operand type!");
715+ case 0: // int or FP.
716+ Valid = LHS->getType()->isIntOrIntVectorTy() ||
717+ LHS->getType()->isFPOrFPVectorTy();
718+ break;
719+ case 1:
720+ Valid = LHS->getType()->isIntOrIntVectorTy();
721+ break;
722+ case 2:
723+ Valid = LHS->getType()->isFPOrFPVectorTy();
724+ break;
725+ }
726+
727+ if (!Valid)
728+ return Error(Loc, "invalid operand type for instruction");
729+
730+ Inst = UnaryOperator::Create((Instruction::UnaryOps)Opc, LHS);
731+ return false;
732+}
733+
734+//===----------------------------------------------------------------------===//
735 // Binary Operators.
736 //===----------------------------------------------------------------------===//
737
738@@ -6332,6 +6494,7 @@
739 AttrBuilder RetAttrs, FnAttrs;
740 std::vector<unsigned> FwdRefAttrGrps;
741 LocTy BuiltinLoc;
742+ unsigned CallAddrSpace;
743 unsigned CC;
744 Type *RetType = nullptr;
745 LocTy RetTypeLoc;
746@@ -6348,6 +6511,7 @@
747 FastMathFlags FMF = EatFastMathFlagsIfPresent();
748
749 if (ParseOptionalCallingConv(CC) || ParseOptionalReturnAttrs(RetAttrs) ||
750+ ParseOptionalProgramAddrSpace(CallAddrSpace) ||
751 ParseType(RetType, RetTypeLoc, true /*void allowed*/) ||
752 ParseValID(CalleeID) ||
753 ParseParameterList(ArgList, PFS, TCK == CallInst::TCK_MustTail,
754@@ -6380,8 +6544,8 @@
755
756 // Look up the callee.
757 Value *Callee;
758- if (ConvertValIDToValue(PointerType::getUnqual(Ty), CalleeID, Callee, &PFS,
759- /*IsCall=*/true))
760+ if (ConvertValIDToValue(PointerType::get(Ty, CallAddrSpace), CalleeID, Callee,
761+ &PFS, /*IsCall=*/true))
762 return true;
763
764 // Set up the Attribute for the function.
765@@ -6685,8 +6849,13 @@
766 return Error(PtrLoc, "atomicrmw operand must be a pointer");
767 if (cast<PointerType>(Ptr->getType())->getElementType() != Val->getType())
768 return Error(ValLoc, "atomicrmw value and pointer type do not match");
769- if (!Val->getType()->isIntegerTy())
770- return Error(ValLoc, "atomicrmw operand must be an integer");
771+
772+ if (!Val->getType()->isIntegerTy()) {
773+ return Error(ValLoc, "atomicrmw " +
774+ AtomicRMWInst::getOperationName(Operation) +
775+ " operand must be an integer");
776+ }
777+
778 unsigned Size = Val->getType()->getPrimitiveSizeInBits();
779 if (Size < 8 || (Size & (Size - 1)))
780 return Error(ValLoc, "atomicrmw operand must be power-of-two byte-sized"
781@@ -7350,8 +7519,14 @@
782 return false;
783 }
784
785-static ValueInfo EmptyVI =
786- ValueInfo(false, (GlobalValueSummaryMapTy::value_type *)-8);
787+static const auto FwdVIRef = (GlobalValueSummaryMapTy::value_type *)-8;
788+
789+static void resolveFwdRef(ValueInfo *Fwd, ValueInfo &Resolved) {
790+ bool ReadOnly = Fwd->isReadOnly();
791+ *Fwd = Resolved;
792+ if (ReadOnly)
793+ Fwd->setReadOnly();
794+}
795
796 /// Stores the given Name/GUID and associated summary into the Index.
797 /// Also updates any forward references to the associated entry ID.
798@@ -7387,9 +7562,9 @@
799 auto FwdRefVIs = ForwardRefValueInfos.find(ID);
800 if (FwdRefVIs != ForwardRefValueInfos.end()) {
801 for (auto VIRef : FwdRefVIs->second) {
802- assert(*VIRef.first == EmptyVI &&
803+ assert(VIRef.first->getRef() == FwdVIRef &&
804 "Forward referenced ValueInfo expected to be empty");
805- *VIRef.first = VI;
806+ resolveFwdRef(VIRef.first, VI);
807 }
808 ForwardRefValueInfos.erase(FwdRefVIs);
809 }
810@@ -7552,8 +7727,8 @@
811 return true;
812
813 auto FS = llvm::make_unique<FunctionSummary>(
814- GVFlags, InstCount, FFlags, std::move(Refs), std::move(Calls),
815- std::move(TypeIdInfo.TypeTests),
816+ GVFlags, InstCount, FFlags, /*EntryCount=*/0, std::move(Refs),
817+ std::move(Calls), std::move(TypeIdInfo.TypeTests),
818 std::move(TypeIdInfo.TypeTestAssumeVCalls),
819 std::move(TypeIdInfo.TypeCheckedLoadVCalls),
820 std::move(TypeIdInfo.TypeTestAssumeConstVCalls),
821@@ -7579,11 +7754,14 @@
822 GlobalValueSummary::GVFlags GVFlags = GlobalValueSummary::GVFlags(
823 /*Linkage=*/GlobalValue::ExternalLinkage, /*NotEligibleToImport=*/false,
824 /*Live=*/false, /*IsLocal=*/false);
825+ GlobalVarSummary::GVarFlags GVarFlags(/*ReadOnly*/ false);
826 std::vector<ValueInfo> Refs;
827 if (ParseToken(lltok::colon, "expected ':' here") ||
828 ParseToken(lltok::lparen, "expected '(' here") ||
829 ParseModuleReference(ModulePath) ||
830- ParseToken(lltok::comma, "expected ',' here") || ParseGVFlags(GVFlags))
831+ ParseToken(lltok::comma, "expected ',' here") || ParseGVFlags(GVFlags) ||
832+ ParseToken(lltok::comma, "expected ',' here") ||
833+ ParseGVarFlags(GVarFlags))
834 return true;
835
836 // Parse optional refs field
837@@ -7595,7 +7773,8 @@
838 if (ParseToken(lltok::rparen, "expected ')' here"))
839 return true;
840
841- auto GS = llvm::make_unique<GlobalVarSummary>(GVFlags, std::move(Refs));
842+ auto GS =
843+ llvm::make_unique<GlobalVarSummary>(GVFlags, GVarFlags, std::move(Refs));
844
845 GS->setModulePath(ModulePath);
846
847@@ -7640,7 +7819,7 @@
848 AS->setModulePath(ModulePath);
849
850 // Record forward reference if the aliasee is not parsed yet.
851- if (AliaseeVI == EmptyVI) {
852+ if (AliaseeVI.getRef() == FwdVIRef) {
853 auto FwdRef = ForwardRefAliasees.insert(
854 std::make_pair(GVId, std::vector<std::pair<AliasSummary *, LocTy>>()));
855 FwdRef.first->second.push_back(std::make_pair(AS.get(), Loc));
856@@ -7667,6 +7846,7 @@
857 /// := 'funcFlags' ':' '(' ['readNone' ':' Flag]?
858 /// [',' 'readOnly' ':' Flag]? [',' 'noRecurse' ':' Flag]?
859 /// [',' 'returnDoesNotAlias' ':' Flag]? ')'
860+/// [',' 'noInline' ':' Flag]? ')'
861 bool LLParser::ParseOptionalFFlags(FunctionSummary::FFlags &FFlags) {
862 assert(Lex.getKind() == lltok::kw_funcFlags);
863 Lex.Lex();
864@@ -7702,6 +7882,12 @@
865 return true;
866 FFlags.ReturnDoesNotAlias = Val;
867 break;
868+ case lltok::kw_noInline:
869+ Lex.Lex();
870+ if (ParseToken(lltok::colon, "expected ':'") || ParseFlag(Val))
871+ return true;
872+ FFlags.NoInline = Val;
873+ break;
874 default:
875 return Error(Lex.getLoc(), "expected function flag type");
876 }
877@@ -7755,7 +7941,7 @@
878 // Keep track of the Call array index needing a forward reference.
879 // We will save the location of the ValueInfo needing an update, but
880 // can only do so once the std::vector is finalized.
881- if (VI == EmptyVI)
882+ if (VI.getRef() == FwdVIRef)
883 IdToIndexMap[GVId].push_back(std::make_pair(Calls.size(), Loc));
884 Calls.push_back(FunctionSummary::EdgeTy{VI, CalleeInfo(Hotness, RelBF)});
885
886@@ -7767,7 +7953,7 @@
887 // of any forward GV references that need updating later.
888 for (auto I : IdToIndexMap) {
889 for (auto P : I.second) {
890- assert(Calls[P.first].first == EmptyVI &&
891+ assert(Calls[P.first].first.getRef() == FwdVIRef &&
892 "Forward referenced ValueInfo expected to be empty");
893 auto FwdRef = ForwardRefValueInfos.insert(std::make_pair(
894 I.first, std::vector<std::pair<ValueInfo *, LocTy>>()));
895@@ -7818,28 +8004,42 @@
896 ParseToken(lltok::lparen, "expected '(' in refs"))
897 return true;
898
899- IdToIndexMapType IdToIndexMap;
900- // Parse each ref edge
901- do {
902+ struct ValueContext {
903 ValueInfo VI;
904- LocTy Loc = Lex.getLoc();
905 unsigned GVId;
906- if (ParseGVReference(VI, GVId))
907+ LocTy Loc;
908+ };
909+ std::vector<ValueContext> VContexts;
910+ // Parse each ref edge
911+ do {
912+ ValueContext VC;
913+ VC.Loc = Lex.getLoc();
914+ if (ParseGVReference(VC.VI, VC.GVId))
915 return true;
916+ VContexts.push_back(VC);
917+ } while (EatIfPresent(lltok::comma));
918+
919+ // Sort value contexts so that ones with readonly ValueInfo are at the end
920+ // of VContexts vector. This is needed to match immutableRefCount() behavior.
921+ llvm::sort(VContexts, [](const ValueContext &VC1, const ValueContext &VC2) {
922+ return VC1.VI.isReadOnly() < VC2.VI.isReadOnly();
923+ });
924
925+ IdToIndexMapType IdToIndexMap;
926+ for (auto &VC : VContexts) {
927 // Keep track of the Refs array index needing a forward reference.
928 // We will save the location of the ValueInfo needing an update, but
929 // can only do so once the std::vector is finalized.
930- if (VI == EmptyVI)
931- IdToIndexMap[GVId].push_back(std::make_pair(Refs.size(), Loc));
932- Refs.push_back(VI);
933- } while (EatIfPresent(lltok::comma));
934+ if (VC.VI.getRef() == FwdVIRef)
935+ IdToIndexMap[VC.GVId].push_back(std::make_pair(Refs.size(), VC.Loc));
936+ Refs.push_back(VC.VI);
937+ }
938
939 // Now that the Refs vector is finalized, it is safe to save the locations
940 // of any forward GV references that need updating later.
941 for (auto I : IdToIndexMap) {
942 for (auto P : I.second) {
943- assert(Refs[P.first] == EmptyVI &&
944+ assert(Refs[P.first].getRef() == FwdVIRef &&
945 "Forward referenced ValueInfo expected to be empty");
946 auto FwdRef = ForwardRefValueInfos.insert(std::make_pair(
947 I.first, std::vector<std::pair<ValueInfo *, LocTy>>()));
948@@ -8027,12 +8227,18 @@
949 }
950
951 /// ConstVCall
952-/// ::= VFuncId, Args
953+/// ::= '(' VFuncId ',' Args ')'
954 bool LLParser::ParseConstVCall(FunctionSummary::ConstVCall &ConstVCall,
955 IdToIndexMapType &IdToIndexMap, unsigned Index) {
956- if (ParseVFuncId(ConstVCall.VFunc, IdToIndexMap, Index) ||
957- ParseToken(lltok::comma, "expected ',' here") ||
958- ParseArgs(ConstVCall.Args))
959+ if (ParseToken(lltok::lparen, "expected '(' here") ||
960+ ParseVFuncId(ConstVCall.VFunc, IdToIndexMap, Index))
961+ return true;
962+
963+ if (EatIfPresent(lltok::comma))
964+ if (ParseArgs(ConstVCall.Args))
965+ return true;
966+
967+ if (ParseToken(lltok::rparen, "expected ')' here"))
968 return true;
969
970 return false;
971@@ -8119,6 +8325,27 @@
972 return false;
973 }
974
975+/// GVarFlags
976+/// ::= 'varFlags' ':' '(' 'readonly' ':' Flag ')'
977+bool LLParser::ParseGVarFlags(GlobalVarSummary::GVarFlags &GVarFlags) {
978+ assert(Lex.getKind() == lltok::kw_varFlags);
979+ Lex.Lex();
980+
981+ unsigned Flag;
982+ if (ParseToken(lltok::colon, "expected ':' here") ||
983+ ParseToken(lltok::lparen, "expected '(' here") ||
984+ ParseToken(lltok::kw_readonly, "expected 'readonly' here") ||
985+ ParseToken(lltok::colon, "expected ':' here"))
986+ return true;
987+
988+ ParseFlag(Flag);
989+ GVarFlags.ReadOnly = Flag;
990+
991+ if (ParseToken(lltok::rparen, "expected ')' here"))
992+ return true;
993+ return false;
994+}
995+
996 /// ModuleReference
997 /// ::= 'module' ':' UInt
998 bool LLParser::ParseModuleReference(StringRef &ModulePath) {
999@@ -8139,18 +8366,20 @@
1000 /// GVReference
1001 /// ::= SummaryID
1002 bool LLParser::ParseGVReference(ValueInfo &VI, unsigned &GVId) {
1003+ bool ReadOnly = EatIfPresent(lltok::kw_readonly);
1004 if (ParseToken(lltok::SummaryID, "expected GV ID"))
1005 return true;
1006
1007 GVId = Lex.getUIntVal();
1008-
1009 // Check if we already have a VI for this GV
1010 if (GVId < NumberedValueInfos.size()) {
1011- assert(NumberedValueInfos[GVId] != EmptyVI);
1012+ assert(NumberedValueInfos[GVId].getRef() != FwdVIRef);
1013 VI = NumberedValueInfos[GVId];
1014 } else
1015 // We will create a forward reference to the stored location.
1016- VI = EmptyVI;
1017+ VI = ValueInfo(false, FwdVIRef);
1018
1019+ if (ReadOnly)
1020+ VI.setReadOnly();
1021 return false;
1022 }
1023diff -r -u llvm-7.0.0.src/lib/AsmParser/LLParser.h llvm-8.0.0.src/lib/AsmParser/LLParser.h
1024--- llvm-7.0.0.src/lib/AsmParser/LLParser.h 2018-07-12 11:03:53.000000000 +0900
1025+++ llvm-8.0.0.src/lib/AsmParser/LLParser.h 2018-11-23 19:54:51.000000000 +0900
1026@@ -202,8 +202,9 @@
1027 /// GetGlobalVal - Get a value with the specified name or ID, creating a
1028 /// forward reference record if needed. This can return null if the value
1029 /// exists but does not have the right type.
1030- GlobalValue *GetGlobalVal(const std::string &Name, Type *Ty, LocTy Loc);
1031- GlobalValue *GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc);
1032+ GlobalValue *GetGlobalVal(const std::string &N, Type *Ty, LocTy Loc,
1033+ bool IsCall);
1034+ GlobalValue *GetGlobalVal(unsigned ID, Type *Ty, LocTy Loc, bool IsCall);
1035
1036 /// Get a Comdat with the specified name, creating a forward reference
1037 /// record if needed.
1038@@ -267,7 +268,11 @@
1039 bool ParseTLSModel(GlobalVariable::ThreadLocalMode &TLM);
1040 bool ParseOptionalThreadLocal(GlobalVariable::ThreadLocalMode &TLM);
1041 bool ParseOptionalUnnamedAddr(GlobalVariable::UnnamedAddr &UnnamedAddr);
1042- bool ParseOptionalAddrSpace(unsigned &AddrSpace);
1043+ bool ParseOptionalAddrSpace(unsigned &AddrSpace, unsigned DefaultAS = 0);
1044+ bool ParseOptionalProgramAddrSpace(unsigned &AddrSpace) {
1045+ return ParseOptionalAddrSpace(
1046+ AddrSpace, M->getDataLayout().getProgramAddressSpace());
1047+ };
1048 bool ParseOptionalParamAttrs(AttrBuilder &B);
1049 bool ParseOptionalReturnAttrs(AttrBuilder &B);
1050 bool ParseOptionalLinkage(unsigned &Res, bool &HasLinkage,
1051@@ -347,6 +352,7 @@
1052 bool ParseVariableSummary(std::string Name, GlobalValue::GUID, unsigned ID);
1053 bool ParseAliasSummary(std::string Name, GlobalValue::GUID, unsigned ID);
1054 bool ParseGVFlags(GlobalValueSummary::GVFlags &GVFlags);
1055+ bool ParseGVarFlags(GlobalVarSummary::GVarFlags &GVarFlags);
1056 bool ParseOptionalFFlags(FunctionSummary::FFlags &FFlags);
1057 bool ParseOptionalCalls(std::vector<FunctionSummary::EdgeTy> &Calls);
1058 bool ParseHotness(CalleeInfo::HotnessType &Hotness);
1059@@ -448,6 +454,9 @@
1060 bool ConvertValIDToValue(Type *Ty, ValID &ID, Value *&V,
1061 PerFunctionState *PFS, bool IsCall);
1062
1063+ Value *checkValidVariableType(LocTy Loc, const Twine &Name, Type *Ty,
1064+ Value *Val, bool IsCall);
1065+
1066 bool parseConstantValue(Type *Ty, Constant *&C);
1067 bool ParseValue(Type *Ty, Value *&V, PerFunctionState *PFS);
1068 bool ParseValue(Type *Ty, Value *&V, PerFunctionState &PFS) {
1069@@ -563,6 +572,8 @@
1070 bool ParseCatchPad(Instruction *&Inst, PerFunctionState &PFS);
1071 bool ParseCleanupPad(Instruction *&Inst, PerFunctionState &PFS);
1072
1073+ bool ParseUnaryOp(Instruction *&Inst, PerFunctionState &PFS, unsigned Opc,
1074+ unsigned OperandType);
1075 bool ParseArithmetic(Instruction *&Inst, PerFunctionState &PFS, unsigned Opc,
1076 unsigned OperandType);
1077 bool ParseLogical(Instruction *&Inst, PerFunctionState &PFS, unsigned Opc);
1078diff -r -u llvm-7.0.0.src/lib/AsmParser/LLToken.h llvm-8.0.0.src/lib/AsmParser/LLToken.h
1079--- llvm-7.0.0.src/lib/AsmParser/LLToken.h 2018-06-26 22:56:49.000000000 +0900
1080+++ llvm-8.0.0.src/lib/AsmParser/LLToken.h 2018-11-29 06:14:32.000000000 +0900
1081@@ -139,6 +139,7 @@
1082 kw_arm_apcscc,
1083 kw_arm_aapcscc,
1084 kw_arm_aapcs_vfpcc,
1085+ kw_aarch64_vector_pcs,
1086 kw_msp430_intrcc,
1087 kw_avr_intrcc,
1088 kw_avr_signalcc,
1089@@ -219,6 +220,7 @@
1090 kw_sret,
1091 kw_sanitize_thread,
1092 kw_sanitize_memory,
1093+ kw_speculative_load_hardening,
1094 kw_strictfp,
1095 kw_swifterror,
1096 kw_swiftself,
1097@@ -268,6 +270,7 @@
1098 kw_umin,
1099
1100 // Instruction Opcodes (Opcode in UIntVal).
1101+ kw_fneg,
1102 kw_add,
1103 kw_fadd,
1104 kw_sub,
1105@@ -367,6 +370,7 @@
1106 kw_readOnly,
1107 kw_noRecurse,
1108 kw_returnDoesNotAlias,
1109+ kw_noInline,
1110 kw_calls,
1111 kw_callee,
1112 kw_hotness,
1113@@ -414,6 +418,7 @@
1114 kw_info,
1115 kw_byte,
1116 kw_bit,
1117+ kw_varFlags,
1118
1119 // Unsigned Valued tokens (UIntVal).
1120 GlobalID, // @42
1121@@ -434,8 +439,10 @@
1122 DwarfLang, // DW_LANG_foo
1123 DwarfCC, // DW_CC_foo
1124 EmissionKind, // lineTablesOnly
1125+ NameTableKind, // GNU
1126 DwarfOp, // DW_OP_foo
1127 DIFlag, // DIFlagFoo
1128+ DISPFlag, // DISPFlagFoo
1129 DwarfMacinfo, // DW_MACINFO_foo
1130 ChecksumKind, // CSK_foo