Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update llir/llvm to support LLVM 10.0 #128

Closed
mewmew opened this issue Feb 14, 2020 · 11 comments
Closed

update llir/llvm to support LLVM 10.0 #128

mewmew opened this issue Feb 14, 2020 · 11 comments

Comments

@mewmew
Copy link
Member

mewmew commented Feb 14, 2020

This is a meta issue tracking the progress to support LLVM 10.0 in llir/llvm.

For reference, it will be very similar to the work done to support LLVM 9.0.

In particular, we need to:

Release candidate 2 of LLVM 10.0 was tagged on the 11th of February, and the final release is scheduled for the 26th of February.

cc: @dannypsnl would you care to take a look at this? I can help out if you get stuck anywhere. I tried to write in the issues (#101, #105 and #106 and associated PRs) how we did this last time :) Just let me know if anything feels unclear.

Cheers,
Robin

@dannypsnl

This comment has been minimized.

@mewmew
Copy link
Member Author

mewmew commented Feb 16, 2020

Just take a look, seems like LLVM 10 haven't released yet.

Yeah, lets wait until 10.0 is released. I was just excited :)

@mewmew
Copy link
Member Author

mewmew commented Mar 19, 2020

LLVM release candidate 5 is out. We are getting closer :)

@mewmew
Copy link
Member Author

mewmew commented Mar 24, 2020

LLVM 10.0 has finally been released!

@dannypsnl, do you wanna take a look at updating llir/llvm? I'd be happy to support you and help if you get stuck :)

@dannypsnl

This comment has been minimized.

@dannypsnl
Copy link
Member

dannypsnl commented Mar 26, 2020

LLVM 10.0 Changes Report

reference document

Changes to the LLVM IR

  • Unnamed function arguments now get printed with their automatically generated name (e.g. “i32 %0”) in definitions.
    This may require front-ends to update their tests;
    if so there is a script utils/add_argument_names.py that correctly converted 80-90% of Clang tests.
    Some manual work will almost certainly still be needed.
  • A new freeze instruction is added.
    The freeze instruction is used to stop IR-level propagation of undef and poison values.
    Currently its support is preliminary; a freeze-equivalent operation for SelDag/MIR needs to be added.

TODO:

  • give parameter default name
  • provide freeze instruction

freeze instruction

@@ -5788,8 +5815,21 @@ int LLParser::ParseInstruction(Instruction *&Inst, BasicBlock *BB,
   case lltok::kw_extractelement: return ParseExtractElement(Inst, PFS);
   case lltok::kw_insertelement:  return ParseInsertElement(Inst, PFS);
   case lltok::kw_shufflevector:  return ParseShuffleVector(Inst, PFS);
-  case lltok::kw_phi:            return ParsePHI(Inst, PFS);
+  case lltok::kw_phi: {
+    FastMathFlags FMF = EatFastMathFlagsIfPresent();
+    int Res = ParsePHI(Inst, PFS);
+    if (Res != 0)
+      return Res;
+    if (FMF.any()) {
+      if (!isa<FPMathOperator>(Inst))
+        return Error(Loc, "fast-math-flags specified for phi without "
+                          "floating-point scalar or vector return type");
+      Inst->setFastMathFlags(FMF);
+    }
+    return 0;
+  }
   case lltok::kw_landingpad:     return ParseLandingPad(Inst, PFS);
+  case lltok::kw_freeze:         return ParseFreeze(Inst, PFS);
   // Call.
   case lltok::kw_call:     return ParseCall(Inst, PFS, CallInst::TCK_None);
   case lltok::kw_tail:     return ParseCall(Inst, PFS, CallInst::TCK_Tail);

+/// ParseFreeze
+///   ::= 'freeze' Type Value
+bool LLParser::ParseFreeze(Instruction *&Inst, PerFunctionState &PFS) {
+  LocTy Loc;
+  Value *Op;
+  if (ParseTypeAndValue(Op, Loc, PFS))
+    return true;
+
+  Inst = new FreezeInst(Op);
+  return false;
+}

@mewmew
Copy link
Member Author

mewmew commented Mar 26, 2020

From the "Parse errors" section of #132 (comment) a couple of test cases are listed for which we need to update the grammar to LLVM 10.0.

They include:

  • FastMathFlag used in phi instructions
  • !DIModule metadata

mewmew pushed a commit that referenced this issue Mar 27, 2020
* (#128) show parameter default name

* remove func has no usage

* (#128) fix selected test
@mewmew
Copy link
Member Author

mewmew commented Apr 13, 2020

@dannypsnl, is it only the freeze instruction left for LLVM 10.0? Let me know if you get stuck or want to bounce a few ideas on how to implement the last few things for 10.0.

mewmew added a commit to llir/grammar that referenced this issue Apr 14, 2020
mewmew pushed a commit to llir/ll that referenced this issue Apr 14, 2020
* (llir/llvm#128) instruction: freeze

TODO: update grammar repo once PR merged

* (llir/llvm#128) update grammar
mewmew added a commit that referenced this issue Apr 15, 2020
* (#128) instruction: freeze

TODO: update submodule ll once PR merged.

* apply suggestions from code review

These suggestions are obviously correct. The rest of suggestions I would take a look at tonight.

Co-Authored-By: Robin Eklind <[email protected]>

* (#128) update submodule: ll

* (#128) move freeze instruction and add Typ field

Co-authored-by: Robin Eklind <[email protected]>
@mewmew
Copy link
Member Author

mewmew commented Apr 15, 2020

With #137 merged, all new language concepts of LLVM 10.0 have been added to llir/llvm. Thanks @dannypsnl! :)

What remains to add for LLVM 10.0 is only enum values.

From #132 (comment)

  • New calling conventions:
@@ -585,6 +585,7 @@ lltok::Kind LLLexer::LexIdentifier() {
   KEYWORD(ccc);
   KEYWORD(fastcc);
   KEYWORD(coldcc);
+  KEYWORD(cfguard_checkcc);
   KEYWORD(x86_stdcallcc);
   KEYWORD(x86_fastcallcc);
   KEYWORD(x86_thiscallcc);
@@ -593,6 +594,7 @@ lltok::Kind LLLexer::LexIdentifier() {
   KEYWORD(arm_aapcscc);
   KEYWORD(arm_aapcs_vfpcc);
   KEYWORD(aarch64_vector_pcs);
+  KEYWORD(aarch64_sve_vector_pcs);
   KEYWORD(msp430_intrcc);
   KEYWORD(avr_intrcc);
   KEYWORD(avr_signalcc);
@@ -622,6 +624,7 @@ lltok::Kind LLLexer::LexIdentifier() {
   KEYWORD(amdgpu_ps);
   KEYWORD(amdgpu_cs);
   KEYWORD(amdgpu_kernel);
+  KEYWORD(tailcc);
  • alwaysInline keyword. It is only used in module summaries (grammar: add module summary (introduced in LLVM 7.0) #43). We can skip this for now. Adding modules summaries is an old issue, and so far noone has needed this?

  • nofree as parameter attribute (currently only used for FuncAttr in grammar).

dannypsnl added a commit that referenced this issue Apr 22, 2020
* (#128) parameter attribute: nofree

* (#128) update ll dependency
@mewmew
Copy link
Member Author

mewmew commented Apr 22, 2020

After merging #128 and llir/testdata#6, the only test case remaining for LLVM 10.0 integration is testdata/llvm/test/Bitcode/calling-conventions.3.2.ll.

--- FAIL: TestParseFile (40.55s)
    asm_test.go:516: unable to parse "../testdata/llvm/test/Bitcode/calling-conventions.3.2.ll" into AST; syntax error at line 29
        unable to parse "../testdata/llvm/test/Bitcode/calling-conventions.3.2.ll" into an AST

mewmew added a commit to llir/grammar that referenced this issue Apr 24, 2020
dannypsnl added a commit to llir/ll that referenced this issue Apr 25, 2020
mewmew pushed a commit that referenced this issue Apr 25, 2020
* (#128) new calling conventions

* (#128) bump ll to latest version

* (#128) calling convention: cfguard_checkcc
@mewmew
Copy link
Member Author

mewmew commented Apr 25, 2020

@dannypsnl I think with #140 merged, we are now ready to close this issue as llir/llvm is now udpated to LLVM 10.0. Is there anything else you can think of that should be worked on? Otherwise, feel free to close this issue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants