<div dir="ltr">Explicitly listing files is not possible because the name is created at runtime. Can you help test 'REQUIRES: shell' solution?<div><br></div><div>thanks,</div><div><br></div><div>David</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 9, 2016 at 2:30 PM, Michael Spencer <span dir="ltr"><<a href="mailto:bigcheesegs@gmail.com" target="_blank">bigcheesegs@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Thu, Jun 9, 2016 at 2:20 PM, Xinliang David Li <<a href="mailto:xinliangli@gmail.com">xinliangli@gmail.com</a>> wrote:<br>
> What is the portable way to do force remove?<br>
><br>
> I can move this test to be linux only for now.<br>
><br>
> David<br>
<br>
</span>The -f works. The issue is the globbing. You either need to explicitly<br>
list the files, or use REQUIRES: shell (I think).<br>
<span class="HOEnZb"><font color="#888888"><br>
- Michael Spencer<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
><br>
> On Thu, Jun 9, 2016 at 2:18 PM, Michael Spencer via llvm-commits<br>
> <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
>><br>
>> On Wed, Jun 8, 2016 at 4:43 PM, Xinliang David Li via llvm-commits<br>
>> <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br>
>> > Author: davidxl<br>
>> > Date: Wed Jun  8 18:43:56 2016<br>
>> > New Revision: 272227<br>
>> ><br>
>> > URL: <a href="http://llvm.org/viewvc/llvm-project?rev=272227&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=272227&view=rev</a><br>
>> > Log:<br>
>> > [profile] in-process merging support part-3<br>
>> ><br>
>> > Differential Revision: <a href="http://reviews.llvm.org/D21056" rel="noreferrer" target="_blank">http://reviews.llvm.org/D21056</a><br>
>> ><br>
>> ><br>
>> > Modified:<br>
>> >     compiler-rt/trunk/lib/profile/InstrProfilingFile.c<br>
>> >     compiler-rt/trunk/lib/profile/InstrProfilingInternal.h<br>
>> >     compiler-rt/trunk/lib/profile/InstrProfilingMerge.c<br>
>> >     compiler-rt/trunk/lib/profile/InstrProfilingPort.h<br>
>> >     compiler-rt/trunk/test/profile/instrprof-basic.c<br>
>> ><br>
>> > Modified: compiler-rt/trunk/lib/profile/InstrProfilingFile.c<br>
>> > URL:<br>
>> > <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingFile.c?rev=272227&r1=272226&r2=272227&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingFile.c?rev=272227&r1=272226&r2=272227&view=diff</a><br>
>> ><br>
>> > ==============================================================================<br>
>> > --- compiler-rt/trunk/lib/profile/InstrProfilingFile.c (original)<br>
>> > +++ compiler-rt/trunk/lib/profile/InstrProfilingFile.c Wed Jun  8<br>
>> > 18:43:56 2016<br>
>> > @@ -18,6 +18,18 @@<br>
>> >  /* For _alloca. */<br>
>> >  #include <malloc.h><br>
>> >  #endif<br>
>> > +#if defined(_WIN32)<br>
>> > +#include "WindowsMMap.h"<br>
>> > +/* For _chsize_s */<br>
>> > +#include <io.h><br>
>> > +#else<br>
>> > +#include <sys/file.h><br>
>> > +#include <sys/mman.h><br>
>> > +#include <unistd.h><br>
>> > +#if defined(__linux__)<br>
>> > +#include <sys/types.h><br>
>> > +#endif<br>
>> > +#endif<br>
>> ><br>
>> >  #define MAX_PID_SIZE 16<br>
>> >  /* Data structure holding the result of parsed filename pattern.  */<br>
>> > @@ -28,13 +40,22 @@ typedef struct lprofFilename {<br>
>> >    char Hostname[COMPILER_RT_MAX_HOSTLEN];<br>
>> >    unsigned NumPids;<br>
>> >    unsigned NumHosts;<br>
>> > +  /* When in-process merging is enabled, this parameter specifies<br>
>> > +   * the total number of profile data files shared by all the processes<br>
>> > +   * spawned from the same binary. By default the value is 1. If<br>
>> > merging<br>
>> > +   * is not enabled, its value should be 0. This parameter is specified<br>
>> > +   * by the %[0-9]m specifier. For instance %2m enables merging using<br>
>> > +   * 2 profile data files. %1m is equivalent to %m. Also %m specifier<br>
>> > +   * can only appear once at the end of the name pattern. */<br>
>> > +  unsigned MergePoolSize;<br>
>> >  } lprofFilename;<br>
>> ><br>
>> > -lprofFilename lprofCurFilename = {0, {0}, {0}, 0, 0};<br>
>> > +lprofFilename lprofCurFilename = {0, {0}, {0}, 0, 0, 0};<br>
>> ><br>
>> >  int getpid(void);<br>
>> >  static int getCurFilenameLength();<br>
>> >  static const char *getCurFilename(char *FilenameBuf);<br>
>> > +static unsigned doMerging() { return lprofCurFilename.MergePoolSize; }<br>
>> ><br>
>> >  /* Return 1 if there is an error, otherwise return  0.  */<br>
>> >  static uint32_t fileWriter(ProfDataIOVec *IOVecs, uint32_t NumIOVecs,<br>
>> > @@ -66,13 +87,96 @@ static void setupIOBuffer() {<br>
>> >    }<br>
>> >  }<br>
>> ><br>
>> > +/* Read profile data in \c ProfileFile and merge with in-memory<br>
>> > +   profile counters. Returns -1 if there is fatal error, otheriwse<br>
>> > +   0 is returned.<br>
>> > +*/<br>
>> > +static int doProfileMerging(FILE *ProfileFile) {<br>
>> > +  uint64_t ProfileFileSize;<br>
>> > +  char *ProfileBuffer;<br>
>> > +<br>
>> > +  if (fseek(ProfileFile, 0L, SEEK_END) == -1) {<br>
>> > +    PROF_ERR("Unable to merge profile data, unable to get size: %s\n",<br>
>> > +             strerror(errno));<br>
>> > +    return -1;<br>
>> > +  }<br>
>> > +  ProfileFileSize = ftell(ProfileFile);<br>
>> > +<br>
>> > +  /* Restore file offset.  */<br>
>> > +  if (fseek(ProfileFile, 0L, SEEK_SET) == -1) {<br>
>> > +    PROF_ERR("Unable to merge profile data, unable to rewind: %s\n",<br>
>> > +             strerror(errno));<br>
>> > +    return -1;<br>
>> > +  }<br>
>> > +<br>
>> > +  /* Nothing to merge.  */<br>
>> > +  if (ProfileFileSize < sizeof(__llvm_profile_header)) {<br>
>> > +    if (ProfileFileSize)<br>
>> > +      PROF_WARN("Unable to merge profile data: %s\n",<br>
>> > +                "source profile file is too small.");<br>
>> > +    return 0;<br>
>> > +  }<br>
>> > +<br>
>> > +  ProfileBuffer = mmap(NULL, ProfileFileSize, PROT_READ, MAP_SHARED |<br>
>> > MAP_FILE,<br>
>> > +                       fileno(ProfileFile), 0);<br>
>> > +  if (ProfileBuffer == MAP_FAILED) {<br>
>> > +    PROF_ERR("Unable to merge profile data, mmap failed: %s\n",<br>
>> > +             strerror(errno));<br>
>> > +    return -1;<br>
>> > +  }<br>
>> > +<br>
>> > +  if (__llvm_profile_check_compatibility(ProfileBuffer,<br>
>> > ProfileFileSize)) {<br>
>> > +    (void)munmap(ProfileBuffer, ProfileFileSize);<br>
>> > +    PROF_WARN("Unable to merge profile data: %s\n",<br>
>> > +              "source profile file is not compatible.");<br>
>> > +    return 0;<br>
>> > +  }<br>
>> > +<br>
>> > +  /* Now start merging */<br>
>> > +  __llvm_profile_merge_from_buffer(ProfileBuffer, ProfileFileSize);<br>
>> > +  (void)munmap(ProfileBuffer, ProfileFileSize);<br>
>> > +<br>
>> > +  return 0;<br>
>> > +}<br>
>> > +<br>
>> > +/* Open the profile data for merging. It opens the file in r+b mode<br>
>> > with<br>
>> > + * file locking.  If the file has content which is compatible with the<br>
>> > + * current process, it also reads in the profile data in the file and<br>
>> > merge<br>
>> > + * it with in-memory counters. After the profile data is merged in<br>
>> > memory,<br>
>> > + * the original profile data is truncated and gets ready for the<br>
>> > profile<br>
>> > + * dumper. With profile merging enabled, each executable as well as any<br>
>> > of<br>
>> > + * its instrumented shared libraries dump profile data into their own<br>
>> > data file.<br>
>> > +*/<br>
>> > +static FILE *openFileForMerging(const char *ProfileFileName) {<br>
>> > +  FILE *ProfileFile;<br>
>> > +  int rc;<br>
>> > +<br>
>> > +  ProfileFile = lprofOpenFileEx(ProfileFileName);<br>
>> > +  if (!ProfileFile)<br>
>> > +    return NULL;<br>
>> > +<br>
>> > +  rc = doProfileMerging(ProfileFile);<br>
>> > +  if (rc || COMPILER_RT_FTRUNCATE(ProfileFile, 0L) ||<br>
>> > +      fseek(ProfileFile, 0L, SEEK_SET) == -1) {<br>
>> > +    PROF_ERR("Profile Merging of file %s failed: %s\n",<br>
>> > ProfileFileName,<br>
>> > +             strerror(errno));<br>
>> > +    fclose(ProfileFile);<br>
>> > +    return NULL;<br>
>> > +  }<br>
>> > +  fseek(ProfileFile, 0L, SEEK_SET);<br>
>> > +  return ProfileFile;<br>
>> > +}<br>
>> > +<br>
>> >  /* Write profile data to file \c OutputName.  */<br>
>> >  static int writeFile(const char *OutputName) {<br>
>> >    int RetVal;<br>
>> >    FILE *OutputFile;<br>
>> ><br>
>> > -  /* Append to the file to support profiling multiple shared objects.<br>
>> > */<br>
>> > -  OutputFile = fopen(OutputName, "ab");<br>
>> > +  if (!doMerging())<br>
>> > +    OutputFile = fopen(OutputName, "ab");<br>
>> > +  else<br>
>> > +    OutputFile = openFileForMerging(OutputName);<br>
>> > +<br>
>> >    if (!OutputFile)<br>
>> >      return -1;<br>
>> ><br>
>> > @@ -115,13 +219,21 @@ static void resetFilenameToDefault(void)<br>
>> >    lprofCurFilename.FilenamePat = "default.profraw";<br>
>> >  }<br>
>> ><br>
>> > -/* Parses the pattern string \p FilenamePat and store the result to<br>
>> > - * lprofcurFilename structure. */<br>
>> > +static int containsMergeSpecifier(const char *FilenamePat, int I) {<br>
>> > +  return (FilenamePat[I] == 'm' ||<br>
>> > +          (FilenamePat[I] >= '1' && FilenamePat[I] <= '9' &&<br>
>> > +           /* If FilenamePat[I] is not '\0', the next byte is<br>
>> > guaranteed<br>
>> > +            * to be in-bound as the string is null terminated. */<br>
>> > +           FilenamePat[I + 1] == 'm'));<br>
>> > +}<br>
>> ><br>
>> > +/* Parses the pattern string \p FilenamePat and stores the result to<br>
>> > + * lprofcurFilename structure. */<br>
>> >  static int parseFilenamePattern(const char *FilenamePat) {<br>
>> >    int NumPids = 0, NumHosts = 0, I;<br>
>> >    char *PidChars = &lprofCurFilename.PidChars[0];<br>
>> >    char *Hostname = &lprofCurFilename.Hostname[0];<br>
>> > +  int MergingEnabled = 0;<br>
>> ><br>
>> >    lprofCurFilename.FilenamePat = FilenamePat;<br>
>> >    /* Check the filename for "%p", which indicates a pid-substitution.<br>
>> > */<br>
>> > @@ -144,6 +256,20 @@ static int parseFilenamePattern(const ch<br>
>> >                  FilenamePat);<br>
>> >              return -1;<br>
>> >            }<br>
>> > +      } else if (containsMergeSpecifier(FilenamePat, I)) {<br>
>> > +        if (MergingEnabled) {<br>
>> > +          PROF_WARN(<br>
>> > +              "%%m specifier can only be specified once at the end of<br>
>> > %s.\n",<br>
>> > +              FilenamePat);<br>
>> > +          return -1;<br>
>> > +        }<br>
>> > +        MergingEnabled = 1;<br>
>> > +        if (FilenamePat[I] == 'm')<br>
>> > +          lprofCurFilename.MergePoolSize = 1;<br>
>> > +        else {<br>
>> > +          lprofCurFilename.MergePoolSize = FilenamePat[I] - '0';<br>
>> > +          I++; /* advance to 'm' */<br>
>> > +        }<br>
>> >        }<br>
>> >      }<br>
>> ><br>
>> > @@ -162,22 +288,29 @@ static void parseAndSetFilename(const ch<br>
>> >    NewFile =<br>
>> >        !OldFilenamePat || (strcmp(OldFilenamePat,<br>
>> > lprofCurFilename.FilenamePat));<br>
>> ><br>
>> > -  if (NewFile)<br>
>> > +  if (NewFile && !lprofCurFilename.MergePoolSize)<br>
>> >      truncateCurrentFile();<br>
>> >  }<br>
>> ><br>
>> >  /* Return buffer length that is required to store the current profile<br>
>> >   * filename with PID and hostname substitutions. */<br>
>> > +/* The length to hold uint64_t followed by 2 digit pool id including<br>
>> > '_' */<br>
>> > +#define SIGLEN 24<br>
>> >  static int getCurFilenameLength() {<br>
>> > +  int Len;<br>
>> >    if (!lprofCurFilename.FilenamePat ||<br>
>> > !lprofCurFilename.FilenamePat[0])<br>
>> >      return 0;<br>
>> ><br>
>> > -  if (!(lprofCurFilename.NumPids || lprofCurFilename.NumHosts))<br>
>> > +  if (!(lprofCurFilename.NumPids || lprofCurFilename.NumHosts ||<br>
>> > +        lprofCurFilename.MergePoolSize))<br>
>> >      return strlen(lprofCurFilename.FilenamePat);<br>
>> ><br>
>> > -  return strlen(lprofCurFilename.FilenamePat) +<br>
>> > -         lprofCurFilename.NumPids * (strlen(lprofCurFilename.PidChars)<br>
>> > - 2) +<br>
>> > -         lprofCurFilename.NumHosts * (strlen(lprofCurFilename.Hostname)<br>
>> > - 2);<br>
>> > +  Len = strlen(lprofCurFilename.FilenamePat) +<br>
>> > +        lprofCurFilename.NumPids * (strlen(lprofCurFilename.PidChars) -<br>
>> > 2) +<br>
>> > +        lprofCurFilename.NumHosts * (strlen(lprofCurFilename.Hostname)<br>
>> > - 2);<br>
>> > +  if (lprofCurFilename.MergePoolSize)<br>
>> > +    Len += SIGLEN;<br>
>> > +  return Len;<br>
>> >  }<br>
>> ><br>
>> >  /* Return the pointer to the current profile file name (after<br>
>> > substituting<br>
>> > @@ -191,7 +324,8 @@ static const char *getCurFilename(char *<br>
>> >    if (!lprofCurFilename.FilenamePat ||<br>
>> > !lprofCurFilename.FilenamePat[0])<br>
>> >      return 0;<br>
>> ><br>
>> > -  if (!(lprofCurFilename.NumPids || lprofCurFilename.NumHosts))<br>
>> > +  if (!(lprofCurFilename.NumPids || lprofCurFilename.NumHosts ||<br>
>> > +        lprofCurFilename.MergePoolSize))<br>
>> >      return lprofCurFilename.FilenamePat;<br>
>> ><br>
>> >    PidLength = strlen(lprofCurFilename.PidChars);<br>
>> > @@ -205,6 +339,18 @@ static const char *getCurFilename(char *<br>
>> >        } else if (FilenamePat[I] == 'h') {<br>
>> >          memcpy(FilenameBuf + J, lprofCurFilename.Hostname,<br>
>> > HostNameLength);<br>
>> >          J += HostNameLength;<br>
>> > +      } else if (containsMergeSpecifier(FilenamePat, I)) {<br>
>> > +        char LoadModuleSignature[SIGLEN];<br>
>> > +        int S;<br>
>> > +        int ProfilePoolId = getpid() % lprofCurFilename.MergePoolSize;<br>
>> > +        S = snprintf(LoadModuleSignature, SIGLEN, "%" PRIu64 "_%d",<br>
>> > +                     lprofGetLoadModuleSignature(), ProfilePoolId);<br>
>> > +        if (S == -1 || S > SIGLEN)<br>
>> > +          S = SIGLEN;<br>
>> > +        memcpy(FilenameBuf + J, LoadModuleSignature, S);<br>
>> > +        J += S;<br>
>> > +        if (FilenamePat[I] != 'm')<br>
>> > +          I++;<br>
>> >        }<br>
>> >        /* Drop any unknown substitutions. */<br>
>> >      } else<br>
>> ><br>
>> > Modified: compiler-rt/trunk/lib/profile/InstrProfilingInternal.h<br>
>> > URL:<br>
>> > <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingInternal.h?rev=272227&r1=272226&r2=272227&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingInternal.h?rev=272227&r1=272226&r2=272227&view=diff</a><br>
>> ><br>
>> > ==============================================================================<br>
>> > --- compiler-rt/trunk/lib/profile/InstrProfilingInternal.h (original)<br>
>> > +++ compiler-rt/trunk/lib/profile/InstrProfilingInternal.h Wed Jun  8<br>
>> > 18:43:56 2016<br>
>> > @@ -156,6 +156,13 @@ VPDataReaderType *lprofGetVPDataReader()<br>
>> >  void lprofSetMaxValsPerSite(uint32_t MaxVals);<br>
>> >  void lprofSetupValueProfiler();<br>
>> ><br>
>> > +/* Return the profile header 'signature' value associated with the<br>
>> > current<br>
>> > + * executable or shared library. The signature value can be used to for<br>
>> > + * a profile name that is unique to this load module so that it does<br>
>> > not<br>
>> > + * collide with profiles from other binaries. It also allows shared<br>
>> > libraries<br>
>> > + * to dump merged profile data into its own profile file. */<br>
>> > +uint64_t lprofGetLoadModuleSignature();<br>
>> > +<br>
>> >  COMPILER_RT_VISIBILITY extern char *(*GetEnvHook)(const char *);<br>
>> >  COMPILER_RT_VISIBILITY extern void (*FreeHook)(void *);<br>
>> >  COMPILER_RT_VISIBILITY extern uint8_t *DynamicBufferIOBuffer;<br>
>> ><br>
>> > Modified: compiler-rt/trunk/lib/profile/InstrProfilingMerge.c<br>
>> > URL:<br>
>> > <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingMerge.c?rev=272227&r1=272226&r2=272227&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingMerge.c?rev=272227&r1=272226&r2=272227&view=diff</a><br>
>> ><br>
>> > ==============================================================================<br>
>> > --- compiler-rt/trunk/lib/profile/InstrProfilingMerge.c (original)<br>
>> > +++ compiler-rt/trunk/lib/profile/InstrProfilingMerge.c Wed Jun  8<br>
>> > 18:43:56 2016<br>
>> > @@ -19,6 +19,22 @@<br>
>> ><br>
>> >  COMPILER_RT_WEAK void (*VPMergeHook)(ValueProfData *,<br>
>> >                                       __llvm_profile_data *) = NULL;<br>
>> > +COMPILER_RT_VISIBILITY<br>
>> > +uint64_t lprofGetLoadModuleSignature() {<br>
>> > +  /* A very fast way to compute a module signature.  */<br>
>> > +  uint64_t CounterSize = (uint64_t)(__llvm_profile_end_counters() -<br>
>> > +                                    __llvm_profile_begin_counters());<br>
>> > +  uint64_t DataSize =<br>
>> > __llvm_profile_get_data_size(__llvm_profile_begin_data(),<br>
>> > +<br>
>> > __llvm_profile_end_data());<br>
>> > +  uint64_t NamesSize =<br>
>> > +      (uint64_t)(__llvm_profile_end_names() -<br>
>> > __llvm_profile_begin_names());<br>
>> > +  uint64_t NumVnodes =<br>
>> > +      (uint64_t)(__llvm_profile_end_vnodes() -<br>
>> > __llvm_profile_begin_vnodes());<br>
>> > +  const __llvm_profile_data *FirstD = __llvm_profile_begin_data();<br>
>> > +<br>
>> > +  return (NamesSize << 40) + (CounterSize << 30) + (DataSize << 20) +<br>
>> > +         (NumVnodes << 10) + (DataSize > 0 ? FirstD->NameRef : 0);<br>
>> > +}<br>
>> ><br>
>> >  /* Returns 1 if profile is not structurally compatible.  */<br>
>> >  COMPILER_RT_VISIBILITY<br>
>> > @@ -31,6 +47,9 @@ int __llvm_profile_check_compatibility(c<br>
>> >        (__llvm_profile_data *)(ProfileData +<br>
>> > sizeof(__llvm_profile_header));<br>
>> >    SrcDataEnd = SrcDataStart + Header->DataSize;<br>
>> ><br>
>> > +  if (ProfileSize < sizeof(__llvm_profile_header))<br>
>> > +    return 1;<br>
>> > +<br>
>> >    /* Check the header first.  */<br>
>> >    if (Header->Magic != __llvm_profile_get_magic() ||<br>
>> >        Header->Version != __llvm_profile_get_version() ||<br>
>> ><br>
>> > Modified: compiler-rt/trunk/lib/profile/InstrProfilingPort.h<br>
>> > URL:<br>
>> > <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingPort.h?rev=272227&r1=272226&r2=272227&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfilingPort.h?rev=272227&r1=272226&r2=272227&view=diff</a><br>
>> ><br>
>> > ==============================================================================<br>
>> > --- compiler-rt/trunk/lib/profile/InstrProfilingPort.h (original)<br>
>> > +++ compiler-rt/trunk/lib/profile/InstrProfilingPort.h Wed Jun  8<br>
>> > 18:43:56 2016<br>
>> > @@ -14,12 +14,16 @@<br>
>> >  #define COMPILER_RT_ALIGNAS(x) __declspec(align(x))<br>
>> >  #define COMPILER_RT_VISIBILITY<br>
>> >  #define COMPILER_RT_WEAK __declspec(selectany)<br>
>> > +/* Need to include <windows.h> */<br>
>> >  #define COMPILER_RT_ALLOCA _alloca<br>
>> > +/* Need to include <stdio.h> and <io.h> */<br>
>> > +#define COMPILER_RT_FTRUNCATE(f,l) _chsize(_fileno(f),l)<br>
>> >  #elif __GNUC__<br>
>> >  #define COMPILER_RT_ALIGNAS(x) __attribute__((aligned(x)))<br>
>> >  #define COMPILER_RT_VISIBILITY __attribute__((visibility("hidden")))<br>
>> >  #define COMPILER_RT_WEAK __attribute__((weak))<br>
>> >  #define COMPILER_RT_ALLOCA __builtin_alloca<br>
>> > +#define COMPILER_RT_FTRUNCATE(f,l) ftruncate(fileno(f),l)<br>
>> >  #endif<br>
>> ><br>
>> >  #if defined(__APPLE__)<br>
>> ><br>
>> > Modified: compiler-rt/trunk/test/profile/instrprof-basic.c<br>
>> > URL:<br>
>> > <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/instrprof-basic.c?rev=272227&r1=272226&r2=272227&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/profile/instrprof-basic.c?rev=272227&r1=272226&r2=272227&view=diff</a><br>
>> ><br>
>> > ==============================================================================<br>
>> > --- compiler-rt/trunk/test/profile/instrprof-basic.c (original)<br>
>> > +++ compiler-rt/trunk/test/profile/instrprof-basic.c Wed Jun  8 18:43:56<br>
>> > 2016<br>
>> > @@ -1,17 +1,30 @@<br>
>> >  // RUN: %clang_profgen -o %t -O3 %s<br>
>> >  // RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t<br>
>> >  // RUN: llvm-profdata merge -o %t.profdata %t.profraw<br>
>> > -// RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s<br>
>> > +// RUN: %clang_profuse=%t.profdata -o - -S -emit-llvm %s | FileCheck %s<br>
>> > --check-prefix=COMMON --check-prefix=ORIG<br>
>> > +//<br>
>> > +// RUN: rm -f %t.profraw_e_*<br>
>> > +// RUN: env LLVM_PROFILE_FILE=%t.profraw_e_%1m %run %t<br>
>> > +// RUN: env LLVM_PROFILE_FILE=%t.profraw_e_%1m %run %t<br>
>> > +// RUN: llvm-profdata merge -o %t.em.profdata %t.profraw_e_*<br>
>> > +// RUN: %clang_profuse=%t.em.profdata -o - -S -emit-llvm %s | FileCheck<br>
>> > %s --check-prefix=COMMON --check-prefix=MERGE<br>
>> > +//<br>
>> > +// RUN: %clang -o %t.merge -fprofile-instr-generate=%t.%m.profraw -O3<br>
>> > %s<br>
>> > +// RUN: rm -f %t.*.profraw*<br>
>> > +// RUN: %run %t.merge<br>
>> > +// RUN: %run %t.merge<br>
>> > +// RUN: llvm-profdata merge -o %t.m.profdata %t.*.profraw<br>
>> > +// RUN: %clang_profuse=%t.m.profdata -o - -S -emit-llvm %s | FileCheck<br>
>> > %s --check-prefix=COMMON --check-prefix=MERGE<br>
>> ><br>
>> >  int begin(int i) {<br>
>> > -  // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof<br>
>> > ![[PD1:[0-9]+]]<br>
>> > +  // COMMON: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof<br>
>> > ![[PD1:[0-9]+]]<br>
>> >    if (i)<br>
>> >      return 0;<br>
>> >    return 1;<br>
>> >  }<br>
>> ><br>
>> >  int end(int i) {<br>
>> > -  // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof<br>
>> > ![[PD2:[0-9]+]]<br>
>> > +  // COMMON: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof<br>
>> > ![[PD2:[0-9]+]]<br>
>> >    if (i)<br>
>> >      return 0;<br>
>> >    return 1;<br>
>> > @@ -21,11 +34,13 @@ int main(int argc, const char *argv[]) {<br>
>> >    begin(0);<br>
>> >    end(1);<br>
>> ><br>
>> > -  // CHECK: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof<br>
>> > ![[PD2:[0-9]+]]<br>
>> > +  // COMMON: br i1 %{{.*}}, label %{{.*}}, label %{{.*}}, !prof<br>
>> > ![[PD2:[0-9]+]]<br>
>> >    if (argc)<br>
>> >      return 0;<br>
>> >    return 1;<br>
>> >  }<br>
>> ><br>
>> > -// CHECK: ![[PD1]] = !{!"branch_weights", i32 1, i32 2}<br>
>> > -// CHECK: ![[PD2]] = !{!"branch_weights", i32 2, i32 1}<br>
>> > +// ORIG: ![[PD1]] = !{!"branch_weights", i32 1, i32 2}<br>
>> > +// ORIG: ![[PD2]] = !{!"branch_weights", i32 2, i32 1}<br>
>> > +// MERGE: ![[PD1]] = !{!"branch_weights", i32 1, i32 3}<br>
>> > +// MERGE: ![[PD2]] = !{!"branch_weights", i32 3, i32 1}<br>
>> ><br>
>> ><br>
>> > _______________________________________________<br>
>> > llvm-commits mailing list<br>
>> > <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
>> > <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
>><br>
>> This breaks on Windows:<br>
>><br>
>> $ "FileCheck"<br>
>> "C:\self-support.src\compiler-rt\test\profile\instrprof-basic.c"<br>
>> "--check-prefix=COMMON" "--check-prefix=ORIG"<br>
>> $ "rm" "-f"<br>
>> "C:\self-support-compilerrt.obj\test\profile\Profile-x86_64\Output\instrprof-basic.c.tmp.profraw_e_*"<br>
>> # command stderr:<br>
>> rm: cannot remove<br>
>><br>
>> `C:\\self-support-compilerrt.obj\\test\\profile\\Profile-x86_64\\Output\\instrprof-basic.c.tmp.profraw_e_*':<br>
>> Invalid argument<br>
>><br>
>><br>
>> error: command failed with exit status: 1<br>
>><br>
>> - Michael Spencer<br>
>> _______________________________________________<br>
>> llvm-commits mailing list<br>
>> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
><br>
><br>
</div></div></blockquote></div><br></div>