[PATCH] D33436: [ARM] Create relocation for Thumb functions calling ARM fns.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue May 23 10:42:41 PDT 2017


> I had to update the thumb-far-jump.s  test case, because it branches to
> a label instead of a function symbol and such symbols are not marked
> Thumb functions. This means Asm.isThumbFunc returns false for labels in
> such functions, meaning we may produce unnecessary relocations for branches
> inside Thumb functions, but we should not miss cases where ARM functions are
> called from Thumb functions.

Are the extra relocations really harmless? My understanding is that the
lsb is used to mark if something is thumb or not and it may not match in
function internal labels (.L...).

It seems we have to accurately track if any label is thumb or not.

> +    :TargetCodeGenInfo(new ARMABIInfo(CGT, K)) {
> +      srand((int)time(0));
> +    }

I guess this is a leftover.

>
>   const ARMABIInfo &getABIInfo() const {
>     return static_cast<const ARMABIInfo&>(TargetCodeGenInfo::getABIInfo());
>
> @@ -5421,6 +5425,27 @@ public:
>
>   if (!FD)
>     return;
>
> +    llvm::Function *Fn = cast<llvm::Function>(GV);
> +
> +    int x = rand() % 2;
> +    if (x == 0) {
> +      llvm::Attribute targetFeatures;
> +      if (Fn->hasFnAttribute("target-features")) {
> +        targetFeatures = Fn->getFnAttribute("target-features");
> +      }
> +
> +      std::string newFeatures = targetFeatures.getValueAsString();
> +      // Do not add thumb-mode if it is already part of the target-features.
> +      if (newFeatures.find("thumb-mode") != std::string::npos)
> +        return;
> +
> +      if (newFeatures.size() > 0)
> +        newFeatures += ",";
> +
> +      newFeatures += "+thumb-mode";
> +      Fn->addFnAttr("target-features", newFeatures);
> +    }

As is this.

Cheers,
Rafael


More information about the llvm-commits mailing list