-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Closed
Labels
clang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.extension:gnu
Description
For small enough return types (not sret), ptr arguments are readonly because the function is annotated memory(read):
struct NotSret {
double x[2];
};
[[gnu::pure]] NotSret make_not_sret(void*);
; Function Attrs: mustprogress nofree nounwind willreturn memory(read)
declare dso_local { double, double } @_Z13make_not_sretPv(ptr noundef) local_unnamed_addr #39500
For larger return types, if the function generates a sret argument, then the function is annotated memory(read, argmem: readwrite) and the optimizer cannot assume arguments other than the sret pointer cannot be written to. To leads to missed optimizations.
struct Sret {
double x[3];
};
[[gnu::pure]] Sret make_sret(void*);
; Function Attrs: mustprogress nounwind willreturn memory(read, argmem: readwrite)
declare dso_local void @_Z9make_sretPv(ptr dead_on_unwind writable sret(%struct.Sret) align 8, ptr noundef) local_unnamed_addr #1
^ could add "readonly" here
Metadata
Metadata
Assignees
Labels
clang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.extension:gnu