-msdata=sysv option in clang - clang

The gcc option -msdata=sysv is used in System V.4 and embedded PowerPC systems. It puts small global and static data in the .sdata section, which is pointed to by register r13 and puts small uninitialized global and static data in the .sbss section, which is adjacent to the .sdata section.
Is there an option in clang similar to the option -msdata=sysv in gcc for PowerPC?

Related

How to Write Out of Tree LLVM LTO Pass?

I'm aware of similar questions here and here, however, the LLVM codebase changes so quickly I'm here to ask if the state of things have changed since then.
So, currently I'm trying to write an out-of-tree pass that works on the whole program CFG (hence the need for the merged bitcode). I would prefer to use the legacy PassManager as opposed to the Mixin-based NPM due to some other legacy passes my current pass relies on.
clang is called with these args:
clang -flto -Xclang -O0 -Xclang -load -Xclang ./mvxaa.so -fuse-ld=gold -o ./tests/target_app $(TARGET_SOURCES)
Will this register the pass as an LTO (full) pass? The pass never runs.
static void registerGlobalCollectionPass(const PassManagerBuilder &PB,
legacy::PassManagerBase &PM) {
PM.add(new CollectGlobals());
}
static RegisterStandardPasses
RegisterMyPass(PassManagerBuilder::EP_FullLinkTimeOptimizationEarly,
registerGlobalCollectionPass);
Looking deeper, it seems that PassManagerBuilder::addExtensionsToPM is called by the individual populateXPassManager functions and they will look through the GlobalExtensions list to call the respective callback functions. For other non-LTO ExtensionPointTy like EP_EnabledOnOptLevel0 there are entries, but when populateLTOPassManager is called, there are no longer any entries in the GlobalExtensions smallvector. Why is this the case?
Is it because LTO occurs at a later point after the linker runs and the -load argument given to dlopen the shared libraries only loads the shared objects at the compilation phase?

Equivalent of -ftree-vectorizer-verbose for clang

The question is about how to make clang print information on which loops (or other parts of code) have been vectorized. GCC has a command line switch named -ftree-vectorizer-verbose=6 to do this (or -fopt-info-vec in newer versions of GCC), but I couldn't find anything similar for clang. Does clang support this or my only option is to peek in the disassembly ?
clang has following options to print diagnostics related to vectorization:
-Rpass=loop-vectorize identifies loops that were successfully vectorized.
-Rpass-missed=loop-vectorize identifies loops that failed vectorization and indicates if vectorization was specified.
-Rpass-analysis=loop-vectorize identifies the statements that caused vectorization to fail.
Source: http://llvm.org/docs/Vectorizers.html
Looking through the clang source code, there are a couple vectorization passes in Transforms/Vectorize:
BBVectorize
LoopVectorize
SLPVectorize
The last three don't seem to have any arguments that will print things. But in inside BBVectorize there are a couple of options for printing things when clang is built debug:
bb-vectorize-debug-instruction-examination - When debugging is enabled, output information on the instruction-examination process
bb-vectorize-debug-candidate-selection - When debugging is enabled, output information on the candidate-selection process
bb-vectorize-debug-pair-selection - When debugging is enabled, output information on the pair-selection process
bb-vectorize-debug-cycle-check - When debugging is enabled, output information on the cycle-checking process
bb-vectorize-debug-print-after-every-pair -When debugging is enabled, dump the basic block after every pair is fused
That looks like it's about it.

PowerPC e500 : any "Page Global Enable" flag equivalent?

From the Intel x86 System Programming Guide :
PGE Page Global Enable (bit 7 of CR4) — (Introduced in the P6 family processors.)
Enables the global page feature when set; disables the global page feature when clear. The global page feature allows frequently used or shared pages to be marked as global to all users (done with the global flag, bit 8, in a page-directory or page-table entry). Global pages are not flushed from the translation-lookaside buffer (TLB) on a task switch or a write to register CR3.
Is there any equivalent feature on PowerPC e500 core family ?
Thanks,
Telenn
Looking at the e500 Core Reference Manual (downloadable from freescale.com) I found that the MAS[0-4] registers do roughly what you need (section 2.12). This is part of the Freescale Book E implementation, so further details can also be found on freescale.com.

Sqlite 3.7.10 and static linking in Delphi

Latest version of Sqlite (3.7.10) wanted to link __msize function and since Delphi memory manager can not report the size of a memory block, I had to introduce a hack (d5 compatible)
function __msize(p: pointer): Cardinal;cdecl;
begin
Result:=PInteger(integer(p)-4)^-6;
end;
Are there other solutions inside Sqlite (defines?) or Delphi to fix this so no undocumented features are used.
Around line # 15195 in the source code, comment the following lines:
/*
** Windows systems have malloc_usable_size() but it is called _msize()
*/
#if !defined(HAVE_MALLOC_USABLE_SIZE) && SQLITE_OS_WIN
# define HAVE_MALLOC_USABLE_SIZE 1
# define malloc_usable_size _msize
#endif
into
/*
** Windows systems have malloc_usable_size() but it is called _msize()
#if !defined(HAVE_MALLOC_USABLE_SIZE) && SQLITE_OS_WIN
# define HAVE_MALLOC_USABLE_SIZE 1
# define malloc_usable_size _msize
#endif
*/
It will disable the memory reuse of SQLite3 malloc, and will rely on the better FastMM4 reallocmem() implementation.
See this commit e.g. for our Open Source implementation of SQLite3 static linking.
Additional information:
I think that we'd get rid of this issue in 3.7.11, as stated by this commit: a new SQLITE_WITHOUT_MSIZE global symbol will be added, and will be able to build the amalgamation source code without changing its content, just by setting the appropriate SQLITE_WITHOUT_MSIZE define. In the meanwhile, the easiest is to comment the above lines.
You can use SizeOfMem from JCL JclSysUtils unit.

How to output variable contents to "LogCat" window in Android-ndk

I am using Android-sdk-ndk in an Eclipse+ADT environment. In Android-sdk Java development, I could use "Log.i", "Log.w", ... statements to output messages and variable contents to the "LogCat" window. However, in Android-ndk C/C++ development, is there any similar C/C++ "print-like" statement that outputs messages / variable contents from a JNI C/C++ module to the "LogCat" window so that I could have some debug informations for my program.
Thanks for any suggestion.
Lawrence
From this guide: http://www.srombauts.fr/2011/03/06/standalone-toolchain/
You can #define the logging methods like this:
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "hello-ndk", __VA_ARGS__))
And you need to make sure you're linking to liblog by compiling similar to this (just add -l log):
arm-linux-androideabi-gcc hello-ndk.c -l log -o hello-ndk

Resources