diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-05-12 01:17:38 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-05-12 01:17:38 +0000 |
commit | e0aa414acf9bb455376df4579e244dcca1434e1f (patch) | |
tree | 8104efd7ced9cab63a9c566a3dcf0fe886eb3756 /llvm/lib/IR/Verifier.cpp | |
parent | fe7bba4ee416ffcc1a5439700b230aa94c106957 (diff) | |
download | bcm5719-llvm-e0aa414acf9bb455376df4579e244dcca1434e1f.tar.gz bcm5719-llvm-e0aa414acf9bb455376df4579e244dcca1434e1f.zip |
All llvm.deoptimize declarations must use the same calling convention
This new verifier rule lets us unambigously pick a calling convention
when creating a new declaration for
`@llvm.experimental.deoptimize.<ty>`. It is also congruent with our
lowering strategy -- since all calls to `@llvm.experimental.deoptimize`
are lowered to calls to `__llvm_deoptimize`, it is reasonable to enforce
a unique calling convention.
Some of the tests that were breaking this verifier rule have had to be
split up into different .ll files.
The inliner was violating this rule as well, and has been fixed to avoid
producing invalid IR.
llvm-svn: 269261
Diffstat (limited to 'llvm/lib/IR/Verifier.cpp')
-rw-r--r-- | llvm/lib/IR/Verifier.cpp | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 5621962497a..1b36eb9bd68 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -243,6 +243,9 @@ class Verifier : public InstVisitor<Verifier>, VerifierSupport { /// Cache of constants visited in search of ConstantExprs. SmallPtrSet<const Constant *, 32> ConstantExprVisited; + /// Cache of declarations of the llvm.experimental.deoptimize.<ty> intrinsic. + SmallVector<const Function *, 4> DeoptimizeDeclarations; + // Verify that this GlobalValue is only used in this module. // This map is used to avoid visiting uses twice. We can arrive at a user // twice, if they have multiple operands. In particular for very large @@ -322,8 +325,11 @@ public: visitGlobalValue(F); // Check to make sure function prototypes are okay. - if (F.isDeclaration()) + if (F.isDeclaration()) { visitFunction(F); + if (F.getIntrinsicID() == Intrinsic::experimental_deoptimize) + DeoptimizeDeclarations.push_back(&F); + } } // Now that we've visited every function, verify that we never asked to @@ -346,6 +352,8 @@ public: verifyCompileUnits(); + verifyDeoptimizeCallingConvs(); + return !Broken; } @@ -470,6 +478,10 @@ private: /// Module-level debug info verification... void verifyCompileUnits(); + + /// Module-level verification that all @llvm.experimental.deoptimize + /// declarations share the same calling convention. + void verifyDeoptimizeCallingConvs(); }; } // End anonymous namespace @@ -4396,6 +4408,18 @@ void Verifier::verifyCompileUnits() { CUVisited.clear(); } +void Verifier::verifyDeoptimizeCallingConvs() { + if (DeoptimizeDeclarations.empty()) + return; + + const Function *First = DeoptimizeDeclarations[0]; + for (auto *F : makeArrayRef(DeoptimizeDeclarations).slice(1)) + Assert(First->getCallingConv() == F->getCallingConv(), + "All llvm.experimental.deoptimize declarations must have the same " + "calling convention", + First, F); +} + //===----------------------------------------------------------------------===// // Implement the public interfaces to this file... //===----------------------------------------------------------------------===// |