[PATCH] D154348: Ignore modified attribute list if it yields invalid IR

Manish Kausik H via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 3 07:11:13 PDT 2023


Nirhar created this revision.
Herald added a project: All.
Nirhar requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

If modified attribute list is invalid, reverting the change is a
low-cost maintainence solution as compared to examples like
this <https://github.com/llvm/llvm-project/blob/main/llvm/tools/bugpoint/CrashDebugger.cpp#L368>.
This will ensure that the ListReducer maintains the sanctity of any
new attribute dependencies added in the future/already present.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D154348

Files:
  llvm/tools/bugpoint/CrashDebugger.cpp


Index: llvm/tools/bugpoint/CrashDebugger.cpp
===================================================================
--- llvm/tools/bugpoint/CrashDebugger.cpp
+++ llvm/tools/bugpoint/CrashDebugger.cpp
@@ -368,6 +368,13 @@
   if (F->hasFnAttribute(Attribute::OptimizeNone))
     F->addFnAttr(Attribute::NoInline);
 
+  // If modifying the attribute list leads to invalid IR, revert the change
+  std::vector<std::string> Passes;
+  Passes.push_back("verify");
+  std::unique_ptr<Module> New = BD.runPassesOn(M.get(), Passes);
+  if (!New)
+    return false;
+
   // Try running on the hacked up program...
   if (TestFn(BD, M.get())) {
     BD.setNewProgram(std::move(M)); // It crashed, keep the trimmed version...


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154348.536760.patch
Type: text/x-patch
Size: 711 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230703/95561a32/attachment.bin>


More information about the llvm-commits mailing list