[llvm-commits] [dragonegg] r153253 - in /dragonegg/trunk: src/Types.cpp test/validator/fortran/2012-03-22-NoAlias.f
Duncan Sands
baldrick at free.fr
Thu Mar 22 07:19:12 PDT 2012
Author: baldrick
Date: Thu Mar 22 09:19:11 2012
New Revision: 153253
URL: http://llvm.org/viewvc/llvm-project?rev=153253&view=rev
Log:
Fortran scalar arguments are passed as pointers with "restrict" semantics,
which is just as well because otherwise the optimizers would have a hard time
due to everything in sight potentially aliasing. Unfortunately the parameters
weren't getting the corresponding "noalias" attribute because Fortran functions
aren't converted usual the normal code path (they use ConvertArgListToFnType in
order to work around front-end bugs) and the codepath they use didn't have the
necessary logic. Fixed by adding the logic there. This should improve Fortran
code generation hugely. Problem pointed out by Dmitry Mikushin.
Added:
dragonegg/trunk/test/validator/fortran/2012-03-22-NoAlias.f
Modified:
dragonegg/trunk/src/Types.cpp
Modified: dragonegg/trunk/src/Types.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Types.cpp?rev=153253&r1=153252&r2=153253&view=diff
==============================================================================
--- dragonegg/trunk/src/Types.cpp (original)
+++ dragonegg/trunk/src/Types.cpp Thu Mar 22 09:19:11 2012
@@ -709,6 +709,10 @@
// Compute zext/sext attributes.
PAttributes |= HandleArgumentExtension(ArgTy);
+ // Compute noalias attributes.
+ if (POINTER_TYPE_P(ArgTy) && TYPE_RESTRICT(ArgTy))
+ PAttributes |= Attribute::NoAlias;
+
if (PAttributes != Attribute::None)
Attrs.push_back(AttributeWithIndex::get(ArgTys.size(), PAttributes));
}
@@ -848,11 +852,8 @@
// inspect it for restrict qualifiers, otherwise try the argument
// types.
tree RestrictArgTy = (DeclArgs) ? TREE_TYPE(DeclArgs) : ArgTy;
- if (TREE_CODE(RestrictArgTy) == POINTER_TYPE ||
- TREE_CODE(RestrictArgTy) == REFERENCE_TYPE) {
- if (TYPE_RESTRICT(RestrictArgTy))
- PAttributes |= Attribute::NoAlias;
- }
+ if (POINTER_TYPE_P(RestrictArgTy) && TYPE_RESTRICT(RestrictArgTy))
+ PAttributes |= Attribute::NoAlias;
#ifdef LLVM_TARGET_ENABLE_REGPARM
// Allow the target to mark this as inreg.
Added: dragonegg/trunk/test/validator/fortran/2012-03-22-NoAlias.f
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/test/validator/fortran/2012-03-22-NoAlias.f?rev=153253&view=auto
==============================================================================
--- dragonegg/trunk/test/validator/fortran/2012-03-22-NoAlias.f (added)
+++ dragonegg/trunk/test/validator/fortran/2012-03-22-NoAlias.f Thu Mar 22 09:19:11 2012
@@ -0,0 +1,13 @@
+C RUN: %dragonegg -S %s -o - | FileCheck %s
+ subroutine sincos(nx, ny)
+C CHECK: (i32* noalias %nx, i32* noalias %ny)
+
+ implicit none
+
+ integer, intent(inout) :: nx
+ integer, intent(in) :: ny
+
+ nx = nx + ny
+ nx = nx + ny
+
+ end subroutine sincos
More information about the llvm-commits
mailing list