I was trying to get the C65 LLVM-Backend (https://github.com/Peppar/llvm-C65) to work with LLVM 8.0.1 (the original version if made for LLVM 3).
After a few fixes, everything compiled properly, but there are a few error generated by TableGen.
The error messages are all like this:
add_frag(dst, src1, src2): (set node:{}:$dst, (add:{} node:{}:$src1, node:{}:$src2))
Included from F:/Projects/llvm-65816/lib/Target/C65/C65.td:59:
F:/Projects/llvm-65816/lib/Target/C65\C65InstrInfo.td:1353:1: error: In add_frag: Node transform 'set' requires one operand! (got 2)
def add_frag : PatFrag<(ops node:$dst, node:$src1, node:$src2),
^
This is the line causing it (At https://github.com/Peppar/llvm-C65/blob/master/C65InstrInfo.td#L1353):
def add_frag : PatFrag<(ops node:$dst, node:$src1, node:$src2),
(set node:$dst, (add node:$src1, node:$src2))>;
The TableGen Language is not that well documented as the LLVM IR is, so I am struggling to find out what the problem is, but I think it is caused by the type.
I have following questions:
How to fix it?
What does node mean and why is this a problem in this case (if it is)?
Related
I'm would like to be able to detect which part of a program has been modified by a previous LLVM pass.
How can I tag instruction / basic blocks and function such as I can retrieve that a pass P1 has previously modified this part of the code ?
I would like to achieve something like:
// First pass
...
tag<bool>(instruction, "modified");
// Second pass
if(has_tag<bool>(instruction, "modified"))
do_something...
Is there a feature in LLVM allowing to make such tag system ?
You may wish to look at the LLVM diff engine in its the toolset:
https://github.com/llvm/llvm-project/blob/main/llvm/tools/llvm-diff/llvm-diff.cpp
I have a custom set of passes created using LLVM to run on some bitcode.
I've managed to get it to compile, but whenever I try to run it with a pass that calls getAnalysis() on another pass type it fails with:
Assertion `ResultPass && "getAnalysis*() called on an analysis that was not " "'required' by pass!"' failed.
The custom pass that is calling getAnalysis() requires its type, specifically;
bool Operators::doInitialization(){
ParseConfig &parseConfig = getAnalysis<ParseConfig>(); // Fails here.
}
.
.
.
void Operators::getAnalysisUsage(AnalysisUsage &AU) const{
AU.addRequired<ParseConfig>();
return;
}
I've spent a few days on this and am quite lost. I know the following is true:
ParseConfig is registered successfully via the RegisterPass<> template, and I have stepped through it in GDB to find that it does get registered.
Also using GDB I have found that when looking into getAnalysis() that the list of registered passes is always empty (which causes the assertion).
Important Note: I will eventually be using this on a Fortran project which is compiled with Flang, thus the LLVM library version I'm using is the Flang fork (found here). That fork is right around LLVM 7.1, but the specific files associated with registering passes seems to not be different from the current LLVM library.
Move getAnalysis function from doInitialization to runOnFunction would make it work.
From LLVM page
This method call getAnalysis* returns a reference to the pass desired. You may get a runtime assertion failure if you attempt to get an analysis that you did not declare as required in your getAnalysisUsage implementation. This method can be called by your run* method implementation, or by any other local method invoked by your run* method.
I'm new to LLVM. I am using the clang c++ API to compile multiple stub files (in c) to IR, and then stick them together using IR builder (after linking them) to eventually run via JIT.
All this works great, unless I add a functionInlining pass to my optimizations, at which point one of these function calls made in IR builder will trigger the following exception when the pass manager is run:
Assertion failed: (New->getType() == getType() && "replaceAllUses of value with new value of different type!"), function replaceAllUsesWith, file /Users/mike/Development/llvm/llvm/lib/IR/Value.cpp, line 356.
This is how I make the call instruction (pretty straight forward):
Function *kernelFunc = mModule->getFunction( (kernel->Name() + StringRef("_") + StringRef(funcName)).str());
if (kernelFunc){
CallInst* newInst = builder.CreateCall(kernelFunc, args);
}
Later the module is optimized:
legacy::PassManager passMan;
PassManagerBuilder Builder;
Builder.OptLevel = 3;
//Builder.Inliner = llvm::createFunctionInliningPass(); //commenting this back in trigger the exception
Builder.populateModulePassManager(passMan);
passMan.run( *mModule ); //exception occurs before this call returns
Any ideas what to look for?
Try running llvm::verifyModule on your module to see if it's correct. You might have an error and have been getting lucky beforehand but it tripped something up in the inliner.
In general assertions check a subset of things that can be wrong with your module but verify checks a lot more.
It could be a bug in LLVM but more than likely it's a bad module, it's easy to happen.
So I finally setup my dev environment so I could inspect the assertion call in the debugger. I turns out the basic block being replaced had a different context set than the one it was being replaced with. going back and making sure IRBuilder was using the same context as the IR parsers solved the problem.
I am trying to make vtkOBJWriter (second part in trying to convert from a vtk file to an obj file, as advised from http://www.vtk.org/pipermail/vtkusers/2012-April/122774.html). The files are at https://github.com/daviddoria/vtkOBJWriter . When I try to cmake .. and then make, I get an error that vtkOBJWriterExample.cxx:59:11: error: ‘class vtkOBJWriter’ has no member named ‘SetInputData’ . This makes sense because I don't see any such member in the vtkOBJWriter file. I was wondering if anyone was able to correct this without deleting vtkOBJWriterExample completely.
Reading the documentation and the exemple, as you can say, neither vtkOBJWriter nor vtkPolyDataAlgorithm (mother class) has SetInputData methods, but vtkPolyDataAlgorithm has a SetInput method.
What is your VTK version ? SetInput methods has been replaced by SetInputData() in VTK6.
2 solutions :
change your VTK version: download the latest VTK6, replace your old version with it and try to rebuild.
Modify the example using the methods of the version 5
I am facing a weird error within my codebase currently. You can see the full ZF2s project code on my github right here. <- there's a link
I'm having a Module set up with two Entities (X and Y). Entity_X contains a reference to Entity_Y via (targetEntity="Entity_Y"). The Error persist with the FQCN or just the CN itself.
Entity_X:
id int PK,
id_Y int FK,
text varchar
Entity_Y:
id int PK,
text varchar
When loading Entity_Y first and then Entity_X everything is working fine. This remains true for both StandardAutoloader and ClassMapAutoloader. However: when loading Entity_X first with ClassMapAutoloader present, i will be seeing the following error:
Fatal error: Cannot redeclare class Kennzahlen\Entity\Referenzwert (Entity_Y)
in \module\Kennzahlen\src\Kennzahlen\Entity\Referenzwert.php
on line 13
Loading Entity_X first with StandardAutoloader works without any problems, too.
Update
The Problem appears to be within ZF2s ClassMapAutoloader (or Autoloading-Mechanism in General). My Module used the ClassMapAutoloader and using this i've gotten the above mentioned error. When removing the ClassMapAutoloader and simply using the StandardAutoloader, the error vanished into thin air. Thanks to #ocramius and all others i've botheres with this :)
I'm writing a failing test case to try and solve this in doctrine/common. The problem seems to be that silent autoloaders (as explained by #Xerkus) are not compatible with doctrine/common itself. To solve that, use a StandardAutoloader from ZF2 (or from composer) instead of using the ClassMapAutoloader. This will solve the issue until a patch is ready.
Update: patch is being suggested at doctrine/common#216
i have no knowledge of doctrine, but i browsed through source and i think i found issue:
https://github.com/doctrine/common/blob/master/lib/Doctrine/Common/ClassLoader.php#L224
here, this code expects that autoloader will return value evaluated to true, but that is not requirement of spl autoload mechanism, therefore autoloader can return NULL,
To check if i am correct, in in your project in doctrine replace line 224 in Doctrine/Common/ClassLoader.php
} else if ($loader[0]->{$loader[1]}($className)) {
with
} else if ($loader[0]->{$loader[1]}($className) && class_exists($className, false)) {
Ans see if issue is fixed, if i am correct - then report bug to doctrine project