[PATCH] D76058: Validate declaration types against the expected types
Hamilton Tobon-Mosquera via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 12 04:30:18 PDT 2020
hamax97 created this revision.
hamax97 added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D76058
Files:
llvm/lib/Transforms/IPO/OpenMPOpt.cpp
Index: llvm/lib/Transforms/IPO/OpenMPOpt.cpp
===================================================================
--- llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -388,6 +388,30 @@
/// Helper to initialize all runtime function information for those defined in
/// OpenMPKinds.def.
void initializeRuntimeFunctions() {
+ // Helper to check the types in the declaration against the expected types.
+ auto CheckTypes = [&](RuntimeFunctionInfo &RFI) {
+ if (!RFI.Declaration)
+ return true;
+
+ Function *F = RFI.Declaration;
+ if (F->getReturnType()->getTypeID() != RFI.ReturnType->getTypeID())
+ return false;
+
+ if (F->arg_size() != RFI.getNumArgs())
+ return false;
+
+ SmallVector<Type *, 8>::iterator RTFTyIt;
+ RTFTyIt = RFI.ArgumentTypes.begin();
+ for (Argument &Arg : F->args()) {
+ if (Arg.getType()->getTypeID() != (*RTFTyIt)->getTypeID())
+ return false;
+
+ ++RTFTyIt;
+ }
+
+ return true;
+ };
+
// Helper to collect all uses of the decleration in the UsesMap.
auto CollectUses = [&](RuntimeFunctionInfo &RFI) {
unsigned NumUses = 0;
@@ -422,6 +446,8 @@
RFI.ReturnType = _ReturnType; \
RFI.ArgumentTypes = SmallVector<Type *, 8>({__VA_ARGS__}); \
RFI.Declaration = M.getFunction(_Name); \
+ bool TypesMatch = CheckTypes(RFI); \
+ (void)TypesMatch; \
unsigned NumUses = CollectUses(RFI); \
(void)NumUses; \
LLVM_DEBUG({ \
@@ -434,7 +460,6 @@
}
#include "llvm/Frontend/OpenMP/OMPKinds.def"
- // TODO: We should validate the declaration agains the types we expect.
// TODO: We should attach the attributes defined in OMPKinds.def.
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76058.249893.patch
Type: text/x-patch
Size: 2117 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200312/285304f2/attachment.bin>
More information about the llvm-commits
mailing list