Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a test for global vars to mangling. also fix the scope issue with… #87

Merged
merged 1 commit into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions flang/include/flang/Optimizer/Support/InternalNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ struct NameUniquer {

/// Unique a (global) constant name
std::string doConstant(llvm::ArrayRef<llvm::StringRef> modules,
llvm::Optional<llvm::StringRef> host,
llvm::StringRef name);

/// Unique a dispatch table name
Expand Down
10 changes: 5 additions & 5 deletions flang/lib/Lower/Mangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ Fortran::lower::mangle::mangleName(fir::NameUniquer &uniquer,
},
[&](const Fortran::semantics::ObjectEntityDetails &) {
auto modNames = moduleNames(ultimateSymbol);
if (Fortran::semantics::IsNamedConstant(ultimateSymbol)) {
return uniquer.doConstant(modNames, toStringRef(symbolName));
}
return uniquer.doVariable(modNames, hostName(ultimateSymbol),
toStringRef(symbolName));
auto optHost = hostName(ultimateSymbol);
auto symbol = toStringRef(symbolName);
if (Fortran::semantics::IsNamedConstant(ultimateSymbol))
return uniquer.doConstant(modNames, optHost, symbol);
return uniquer.doVariable(modNames, optHost, symbol);
},
[](const auto &) -> std::string {
assert(false);
Expand Down
4 changes: 3 additions & 1 deletion flang/lib/Optimizer/Support/InternalNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ std::string fir::NameUniquer::doCommonBlock(llvm::StringRef name) {

std::string
fir::NameUniquer::doConstant(llvm::ArrayRef<llvm::StringRef> modules,
llvm::Optional<llvm::StringRef> host,
llvm::StringRef name) {
std::string result = prefix();
return result.append(doModules(modules)).append("EC").append(toLower(name));
result.append(doModulesHost(modules, host)).append("EC");
return result.append(toLower(name));
}

std::string
Expand Down
6 changes: 5 additions & 1 deletion flang/test/Lower/program-units-fir-mangling.f90
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@ subroutine AsUbRoUtInE()
! CHECK-LABEL: func @_QPfoo() -> f32 {
function foo()
real(4) :: foo
real :: pi = 3.14159
! CHECK: }
end function

! CHECK-LABEL: fir.global @_QFfooEpi : f32 {

! CHECK-LABEL: func @_QPfunctn() -> f32 {
function functn
! CHECK-LABEL: fir.global @_QECpi
real, parameter :: pi = 3.14
! CHECK: }
end function

! CHECK-LABEL: fir.global @_QFfunctnECpi constant : f32 {

module testMod
contains
! CHECK-LABEL: func @_QMtestmodPsub() {
Expand Down