[PATCH] D96361: [flang][fir] Updates to internal name uniquer.
Eric Schweitz via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 9 11:25:37 PST 2021
schweitz created this revision.
schweitz added reviewers: kiranchandramohan, clementval, jeanPerier, SouraVX, svedanayagam.
schweitz added a project: Flang.
Herald added subscribers: mehdi_amini, jdoerfert.
Herald added a reviewer: sscalpone.
schweitz requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
https://github.com/flang-compiler/f18-llvm-project/pull/474
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D96361
Files:
flang/include/flang/Optimizer/Support/InternalNames.h
flang/lib/Optimizer/Support/InternalNames.cpp
flang/unittests/Optimizer/InternalNamesTest.cpp
Index: flang/unittests/Optimizer/InternalNamesTest.cpp
===================================================================
--- flang/unittests/Optimizer/InternalNamesTest.cpp
+++ flang/unittests/Optimizer/InternalNamesTest.cpp
@@ -46,6 +46,16 @@
<< "Possible error: DeconstructedName mismatch";
}
+TEST(InternalNamesTest, doBlockDataTest) {
+ NameUniquer obj;
+ std::string actual = obj.doBlockData("blockdatatest");
+ std::string actualBlank = obj.doBlockData("");
+ std::string expectedMangledName = "_QLblockdatatest";
+ std::string expectedMangledNameBlank = "_QL";
+ ASSERT_EQ(actual, expectedMangledName);
+ ASSERT_EQ(actualBlank, expectedMangledNameBlank);
+}
+
TEST(InternalNamesTest, doCommonBlockTest) {
NameUniquer obj;
std::string actual = obj.doCommonBlock("hello");
Index: flang/lib/Optimizer/Support/InternalNames.cpp
===================================================================
--- flang/lib/Optimizer/Support/InternalNames.cpp
+++ flang/lib/Optimizer/Support/InternalNames.cpp
@@ -7,7 +7,9 @@
//===----------------------------------------------------------------------===//
#include "flang/Optimizer/Support/InternalNames.h"
+#include "flang/Optimizer/Dialect/FIRType.h"
#include "mlir/IR/Diagnostics.h"
+#include "mlir/IR/BuiltinTypes.h"
#include "llvm/Support/CommandLine.h"
static llvm::cl::opt<std::string> mainEntryName(
@@ -97,6 +99,11 @@
return result.append("B").append(toLower(name));
}
+std::string fir::NameUniquer::doBlockData(llvm::StringRef name) {
+ std::string result = prefix();
+ return result.append("L").append(toLower(name));
+}
+
std::string
fir::NameUniquer::doConstant(llvm::ArrayRef<llvm::StringRef> modules,
llvm::Optional<llvm::StringRef> host,
@@ -237,6 +244,10 @@
name = readName(uniq, i, i + 1, end);
}
break;
+ case 'L':
+ nk = NameKind::BLOCK_DATA_NAME;
+ name = readName(uniq, i, i + 1, end);
+ break;
case 'P':
nk = NameKind::PROCEDURE;
name = readName(uniq, i, i + 1, end);
Index: flang/include/flang/Optimizer/Support/InternalNames.h
===================================================================
--- flang/include/flang/Optimizer/Support/InternalNames.h
+++ flang/include/flang/Optimizer/Support/InternalNames.h
@@ -32,6 +32,7 @@
/// The sort of the unique name
enum class NameKind {
NOT_UNIQUED,
+ BLOCK_DATA_NAME,
COMMON,
CONSTANT,
DERIVED_TYPE,
@@ -63,6 +64,9 @@
/// Unique a common block name
std::string doCommonBlock(llvm::StringRef name);
+ /// Unique a block data unit name
+ std::string doBlockData(llvm::StringRef name);
+
/// Unique a (global) constant name
std::string doConstant(llvm::ArrayRef<llvm::StringRef> modules,
llvm::Optional<llvm::StringRef> host,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96361.322454.patch
Type: text/x-patch
Size: 2861 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210209/9cf6da69/attachment.bin>
More information about the llvm-commits
mailing list