Signed-off-by: Itay Bookstein <ibookstein@gmail.com>
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
One thing that surprises me is that the test changes are in Sema but the code changes are in CodeGen. I see that this test actually emits LLVM IR. Should it be moved (as an NFC change)?
clang/lib/CodeGen/CodeGenModule.cpp | ||
---|---|---|
320–321 | Can you explain a bit better how this change here works? The previous version appears to have done quite a bit of work in the loop to look through aliases/ifuncs, and it seems we don't do that anymore? | |
398 | What is the purpose of changing this from checking the declaration to the IR? It seems that this is something we should be able to catch at the AST level and not have to revert to IR checks like this. | |
clang/test/Sema/attr-ifunc.c | ||
16 | Did we lose this previous error? We still want that to happen, right? |
clang/lib/CodeGen/CodeGenModule.cpp | ||
---|---|---|
320–321 | Previously this function would have drilled through an arbitrary ifunc->alias->ifunc->alias interleaving structure. This is sort of peculiar since for alias->ifunc it would return the resolver (rather than the aliasee, which is the ifunc itself), and for ifunc->ifunc (which is invalid anyway) it would return the second ifunc's resolver. In essence, in an alias->ifunc->alias->... chain there should always be 0 or 1 ifuncs, and if there's an ifunc the last object should be a resolver function (and not a global variable or an ifunc). int g_var; void foo(void) __attribute__((ifunc("g_var"))); | |
398 | Inside checkAliasedGlobal I wanted to save on a parameter (D) since then I would just be passing it redundantly because the information is already available on the Alias. Here I wanted the check to be an exact copy of the check inside checkAliasedGlobal for consistency. I don't mind changing that at at all, I guess I just don't see why I should prefer one over the other :) | |
clang/test/Sema/attr-ifunc.c | ||
16 | One of the two errors (the one on f2_b) is enough, IMO. |
Explanations make sense to me, I'm generally in favor with the 1 concern.
clang/lib/CodeGen/CodeGenModule.cpp | ||
---|---|---|
398 | The CFE (particularly when doing checks, but even when generating code) should be doing as much based on the AST rather than the IR, as it makes us a bit more fragile/dependent on the form of the IR. So typcially we try to avoid determining types/etc from IR. Note we break this rule a bunch, but it is currently burning us on opaque-ptr for example. |
Changed to using D->hasAttr<IFuncAttr>() and passing that
bool into the checkAliasedGlobal function.
move test from Sema to CodeGen (trying to make arcanist send multiple
separate commits..?)
I assume that dancing with GlobalValue makes this difficult to implement in lib/Sema.
Yeah, it's real ugly from a CFE/LLVM separation POV. I also can't avoid seeing it as a duplication of the verifier's logic. But emitting diagnoses is better than asserting/crashing...
For the recursion, maybe an equivalent of getAliaseeObject on GlobalDecl-s could work? For the rest - not steeped in the code enough to say...
Can you explain a bit better how this change here works? The previous version appears to have done quite a bit of work in the loop to look through aliases/ifuncs, and it seems we don't do that anymore?