[polly] r221251 - Use argument type directly from fflush if available in translation unit

Tobias Grosser tobias at grosser.es
Tue Nov 4 01:18:24 PST 2014


Author: grosser
Date: Tue Nov  4 03:18:24 2014
New Revision: 221251

URL: http://llvm.org/viewvc/llvm-project?rev=221251&view=rev
Log:
Use argument type directly from fflush if available in translation unit

When our RuntimeDebugBuilder calles fflush(NULL) to flush all output streams, it
is important that the types we use in the call match the ones used in a
declaration of fflush possible already available in the translation unit.

As we just pass on a NULL pointer, the type of the pointer value does not really
matter. However, as LLVM complains in case of mismatched types, we make sure
to create a NULL pointer of identical type.

No test case, as RuntimeDebugBuilder is not permanently used in Polly. Calls to
it are until now only used to add informative output during debugging sessions.

Modified:
    polly/trunk/lib/CodeGen/RuntimeDebugBuilder.cpp

Modified: polly/trunk/lib/CodeGen/RuntimeDebugBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/RuntimeDebugBuilder.cpp?rev=221251&r1=221250&r2=221251&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/RuntimeDebugBuilder.cpp (original)
+++ polly/trunk/lib/CodeGen/RuntimeDebugBuilder.cpp Tue Nov  4 03:18:24 2014
@@ -43,7 +43,13 @@ void RuntimeDebugBuilder::createFlush(Po
     F = Function::Create(Ty, Linkage, Name, M);
   }
 
-  Builder.CreateCall(F, Constant::getNullValue(Builder.getInt8PtrTy()));
+  // fflush(NULL) flushes _all_ open output streams.
+  //
+  // fflush is declared as 'int fflush(FILE *stream)'. As we only pass on a NULL
+  // pointer, the type we point to does conceptually not matter. However, if
+  // fflush is already declared in this translation unit, we use the very same
+  // type to ensure that LLVM does not complain about mismatching types.
+  Builder.CreateCall(F, Constant::getNullValue(F->arg_begin()->getType()));
 }
 
 void RuntimeDebugBuilder::createStrPrinter(PollyIRBuilder &Builder,





More information about the llvm-commits mailing list