building PET with -O0 causes PPCG coredump

5 views
Skip to first unread message

Leo Yin

unread,
Oct 9, 2025, 11:50:32 PM (6 days ago) Oct 9
to isl Development
I changed compiler option -O2 in pet/Makefile to -O0 and build PPCG. When run ppcg with the following simple case, it coredumped.

#define UNIT 1024

float a[UNIT];
float b[UNIT];
float c[UNIT];


int main() {

  #pragma scop
   for (int i = 0; i < UNIT; i+=1)
     c[i] = a[i] + b[i];
  #pragma endscop


  return 0;
}

Sometimes, it reported error "fatal error: sorry, this include generates a translation unit too large for Clang to process."

Thanks,
-Leo


Sven Verdoolaege

unread,
Oct 12, 2025, 6:17:57 PM (3 days ago) Oct 12
to Leo Yin, isl Development
On Thu, Oct 09, 2025 at 08:50:30PM -0700, Leo Yin wrote:
> I changed compiler option -O2 in pet/Makefile to -O0 and build PPCG. When
> run ppcg with the following simple case, it coredumped.

Thanks for the report. It seems I didn't handle the return value
of getFileRef correctly, but this got masked when compiling with
optimizations.

This should fix it:

diff --git a/pet.cc b/pet.cc
index 1970777..b157861 100644
--- a/pet.cc
+++ b/pet.cc
@@ -1111,22 +1111,15 @@ struct HasGetFileRef<T, ::void_t<decltype(&T::getFileRef)>> :
template <typename T,
typename std::enable_if<HasGetFileRef<T>::value, bool>::type = true>
static auto getFile(T& obj, const std::string &filename)
- -> llvm::ErrorOr<decltype(*obj.getFileRef(filename))>
{
- auto file = obj.getFileRef(filename);
- if (!file)
- return std::error_code();
- return *file;
+ return obj.getFileRef(filename);
}
template <typename T,
typename std::enable_if<!HasGetFileRef<T>::value, bool>::type = true>
static llvm::ErrorOr<const FileEntry *> getFile(T& obj,
const std::string &filename)
{
- const FileEntry *file = ignore_error(obj.getFile(filename));
- if (!file)
- return std::error_code();
- return file;
+ return ignore_error(obj.getFile(filename));
}

/* Return the ownership of "buffer".

I'll clean it up and do some further testing later this week.
The other issue will have to wait a bit.

skimo
Reply all
Reply to author
Forward
0 new messages